Slide to the top of js to load history messages?

the scroll event used now, when sliding up, inserts elements with prepend, and it will go to the top, and this event will also be triggered when sliding downwards. How to make sure that the event will not be triggered when sliding?!

Mar.02,2021

needs to record the position of the last time, and judge whether to dash up or down according to the difference


just judge whether to go up or down,

compare the initial scrollTop, with the scrollTop after sliding


this can be written entirely on your own, without any plug-ins. In fact, it is to record the position when sliding, determine whether to slide up or down, and then deal with


has been solved. When prepend inserts an element, record the height before the parent element is inserted, and then record the height after insertion minus the height before insertion, and the scollTop setting value is subtracted.

Menu