Ionic detect “back” for better Native Page Transitions

I am trying to implement native page transition into my Ionic project after reading great tutorial from

However, I found the problem that sometimes the page is changed after the page transition is made. Meaning, it will animate transition from page A to page A. Only then, page A become page B. The solution provided by the article and also the plugin is by estimate setting the delay before the animation begin. But this way of doing isn’t very reliable.

So, I am thinking instead of using delay, but apply the animation on entering that page with this:

$scope.$on('$ionicView.enter', function (event, viewData) {
            "direction": "left"

It works great when navigate from other page to this page. But it will be animation problem when navigate BACK from other page to this page.

How can I know user is BACK to this page so that I can perform different direction of animation?