malihu / malihu-custom-scrollbar-plugin

Highly customizable custom scrollbar jQuery plugin, featuring vertical/horizontal scrollbars, scrolling momentum, mouse-wheel, keyboard and touch support etc.
http://manos.malihu.gr/jquery-custom-content-scroller
MIT License
4.11k stars 1.51k forks source link

Wrong scroll position when delete some items from list #594

Open AndrusovaK opened 6 years ago

AndrusovaK commented 6 years ago

Hello! I need your help. I'm trying to create an infinite scroll with your plugin. It is assumed that there will be a lot of elements, so we need to limit the number of items in DOM.

On totalScroll I check if my list of elements longer than number of elements I want to place in DOM. If true - I delete the extra elements from the beginning of the list (they will be inserted back into the list onTotalScrollBack). At this point, scroll becomes incorrect.

I've made a small jsfiddle to demonstrate this behaviour. You can see, that first time onTotalScroll scroll keeps right position, but in the second time, when we delete elements, it jumps to bottom. https://jsfiddle.net/Ksenia_Andrusova/jry3kkjv/

Also, when I try to insert elements at the top of the list and remove the extra elements from its end, scroll becomes incorrect too.