Watching scroll position


First of all, I’d like to create a directive, which is complete, and does not depend on any external controllers, which implement on-scroll handler.
Thus, I’m trying to scope.$watch($ionicScrollDelegate.getScrollPosition, function(new, old){});

But, I’ve got Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!

PS For some reason an alternate $watch($(element).offset().top, ...) is not fired in spite it is changed.

Can someone help me either to realize how to handle scrolling events within an isolated directive inside <ion-content/>, or what’s wrong with $(element).offset().top please?


This sample might get you started in the right direction.

If its not what you are looking for, put together a sample that we can try to help with.


Thank you for the suggestion, but I’d like to avoid using event listener on ion-content. I try to implement indexed list as a directive, and no scrolling events are raised on this directive element. It’s a matter of ion-content.
I wonder whether $apply is used internal ‘on-scroll’ handler? I have no idea about the implementation of $ionicScrollDelegate. Instead I used pulling timer and element’s offset property.