Infinite Scrolling scrollbar position jump
I've got a checkScroll
handler attached to a div's scroll event (soon to be implemented as a timer instead), which checks to see if the user is nearing the bottom and fetches more data to display. The UI is smooth and works well when used with the mouse scroll wheel, but when dragging the scrollb开发者_开发百科ar the following occurs:
checkScroll
handler determines user is near the bottom (and for example, let's sayscrollTop
is 800)- an AJAX request is sent in the background to fetch more data
- data is returned and appended to the div
- if the scrollbar is still in drag mode, but the mouse hasn't moved since the data has been appended the scrollbar has now changed size and jumped up a bit,
scrollTop
is still set to 800 and the data is in the same position - once the mouse is dragged 1px in any direction, the scrollbar jumps back under the mouse and all the data has shifted, the user has lost their original position
Is there a way to prevent this from happening, a la Twitter?
This is standard browser behaviour, Firefox will make the content jump but Chrome keeps the current position when increasing the scrollHeight
PS. How do you close a question as invalid?
精彩评论