Search code examples
javascriptjqueryjscrollpane

Prevent "jump to Top" on jScrollPane


I am using the jScrollPane jQuery-Plugin on a -Box which is dynamically filled with content.

My problem is that on adding new content to the front of the old content, the maintainPosition option does not work. So I wrote my own code that moves the Scrollhandle back to it's original position. The code works fine, but calling reinitialise() after adding the new content moves the handle to the top of the container just before my code reverts it's position. This results in a short flicker of the displayed content which is very disturbing.

Does anyone know a method to prevent the scroll handler to move to the top after calling "reinitialise()"?


Solution

  • I didn't find any integrated solution to this, so I created a workaround: 1. calculate height of prepending elements 2. prepeding new elements 3. instantly scrolling down a distance equal to the height of the new prepended elements