Search code examples
javascripthtmltypescriptnpmperfect-scrollbar

Inject divs into perfect-scroll without changing scroll position


Is there a way to add div containers into perfect-scrollbar (https://www.npmjs.com/package/perfect-scrollbar) once loaded without shifting the current location. Similar to how Android does their recycler-view.

IE if i have a scrollable DIV with elements from 10 - 100 and im at scroll position 30 and i add elements from 0 - 10 to the top (so total list would be 0 - 100) i notice when i do that while on 30 it reshift everything to point 0. Is there a way to add elements without reshifting everything?

Or is there another package i could use for the web to act similar to recycler-view?
Thanks.


Solution

  • I have found the solution. Thank you for everyone looking into this. Solution was to :

    setTimeout(() => {$('#select__ps').scrollTop = 200}, 0);