Sometimes when using the jScrollPane plugin, you might want to know when the user has reached the maximum scroll height. This can be useful for determining when to load more content or to trigger other actions.
There are a few different ways to determine when the user has reached the maximum scroll height. One solution you could try is to simulate a Bottom()
and then compare the resulting PositionY()
with the value before the simulation. If it hasn't changed, then the user was already at the bottom, so call Bottom()
"for real" after appending the response content.
var pane = chatPane').clone();
simulatedPane.jScrollPane();
var simulatedApi = pane.data('jsp');
Then, in the success() function, use simulatedApi
for the simulation.
Another approach might be to add a listener for the jsp-scroll-y
event:
http://jscroll.kelvinluck.com/events.html
This listener gets passed boolean values for isAtTop
and isAtBottom
. You could store this in a variable and check the state of the variable before reinitialising the scroll.
Longer term, it would be great if you could add a feature request to add some additional methods to the API: isAtTop
, isAtBottom
, isAtLeft
and isAtRight
- if you add that to the github issues list then I will add it when I get a chance.