One possible solution for obtaining the maximum scroll height in jScrollPane is to simulate a scrollToBottom()
operation and compare the resulting getContentPositionY()
with the value before the simulation. If there's no change, it indicates that the user was already at the bottom. In this case, you can proceed to call scrollToBottom()
"for real" after appending the response content.
To run the simulation, consider cloning the original object and modifying it in memory. Refer to http://api.jquery.com/clone/ for more information. An example of how to do this is provided below:
var simulatedPane = $('#chatPane').clone(); simulatedPane.jScrollPane(); var simulatedApi = simulatedPane.data('jsp');
In the success()
function, utilize simulatedApi
for the simulation.
An alternative approach involves adding a listener for the jsp-scroll-y
event. This event provides boolean values for isAtTop
and isAtBottom
. You can store this information in a variable and check the state of the variable before reinitializing the scroll pane. Refer to http://jscrollpane.kelvinluck.com/events.html for more details.
Additionally, it would be beneficial to add a feature request to the jScrollPane project on GitHub for additional methods like isAtTop
, isAtBottom
, isAtLeft
, and isAtRight
. This can be done by creating an issue on the GitHub issues list. If you do so, the developer will work on implementing these features when possible.