JScrollPane will not maintain its position when dynamic content is added or sent (jQuery)

I dynamically add content to my jScrollPane DIV, and finally I increased its height or got rid of it, depending on the amount of content, however I need that in this case I do not need to scroll back to the top every time that it is added or called. I need him to stay.

Here is the code I'm using to reinitialize jScrollPane at the moment:

function refreshNav() { var top = $('#my_scroller').css('top'); $('#infohome').jScrollPaneRemove(); if (page == "enquiryform"){ $('#infohome').css('height','550px') } else { $('#infohome').css('height','284px') } $('#infohome').jScrollPane(); $('#infohome').css('top',top); $('.jScrollPane').css('height','100%'); } 

I already tried to get rid of all the code related to "top", but that does not seem to matter.

+4
source share
1 answer

I think the best solution is to stop using jScrollPane and nanoScroller instead. :)

0
source

Source: https://habr.com/ru/post/1389764/


All Articles