Accessing scroll position


#1

In older versions of ionic I was able to do the following to access the current scroll position:

$ionicScrollDelegate.getScrollView(SCOPE).__scrollTop

How do i do the same with the latest version?

Thanks.


#2

I haven’t used any of the scroll delegates but the best place to find out would be the docs

http://ionicframework.com/docs/api/service/$ionicScrollDelegate/


#3

No luck mhartington. I can’t figure out from the docs how to access the scroll data anymore?


#4

Are you wanting to GET the scroll position or just scroll to the top? In your sample, it looks like you were just telling it to scroll to the top.

If all you really want to do is scroll, then :

$ionicScrollDelegate.scrollTop();

I don’t think it exposes an API for getting the positions though. If you need that, perhaps open a feature request.


Content scrolling questions
#5

I’m looking to get the scroll position, I was able to do it in previous versions. I guess I’ll just downgrade ionic

EDIT: All I needed todo was use ion-scroll instead, it is exposing scrollView via the parent controller.Thanks


#6

Can you post a sample of what you mean?


#7

Would really like to see your sample.

In the mean time, I’ve opened Issue 1117 : https://github.com/driftyco/ionic/issues/1117


#8

FYI : The nightlies expose scroll information again via getScrollView() along with getScrollPosition().


#9

I’m trying to get the scroll position from the top using $ionicScrollDelegate.getScrollPosition().top and all I get is 0. Am I missing something?


#10

See this sample : http://codepen.io/calendee/pen/wygBi


#11

Thank you! I’ve found my mistake: I needed to use $getByHandle because I had more than One ion-scroll container!


#12

Having similar issues using $ionicScrollDelegate.$getByHandle(‘product’).getScrollPosition().top; within a directive. In the browsers, it works fine, but on Android, it returns zero.


#13

same here, do you have any solution?

I found something by myself, it works: