How to determine if the user is at the bottom of a scroll view?


#1

I’m building an application where content is dynamically added to a scroll view at the bottom and I am using scrollToBottom to automatically adjust the view so that new content is shown whenever an element is added. The issue is that I’d like to not automatically scroll to the bottom when the user has scrolled up away from the bottom. In that case I’d rather just show an indicator letting the user know there is more content at the bottom.

I’ve tried poking around the properties of the scroll view itself looking at the container and content heights to try and determine if the scroll position is at the bottom, but I’m not seeing any numbers that match up.

Any help would be appreciated!


#2

It’s labelled as private but this will get you the total height and the current position

var currentPosition = $ionicScrollDelegate.getScrollPosition().top;
var scrollHeight = $ionicScrollDelegate.getScrollView().__maxScrollTop;

So you should be able to say if the user is a certain distance away from scrollHeight to show the notification rather than scroll.

HTH


#3

Awesome. That did it! Thanks.