Reputation: 9217
we usually use $(window).scrollTop()
to detect how far the page has been scrolled. Is there a equivalent for scrollable elements?
Say I set html to overflow hidden, and body to overflow scroll, now I want to detect $('body').scrollTop()
I will always get 0.
P.S. this is useful for mobile site development.
Here is a plunker:
http://embed.plnkr.co/jZH3zCiMSfk5bIZIoDEp/
Upvotes: 1
Views: 164
Reputation: 1912
Common issue with Angular. Instead of making the body scrollable, you should wrap everything inside a div and make the div an Angular controller. Then use the ng-scroll
to detect scrolling position.
Upvotes: 1
Reputation: 1909
I think you want to get top offset of an element.
Like so with jQuery
$('body').offset().top
Upvotes: 0