AJAX load + DOM manipulation + scroll in the same moment are impossible?
Hello!
I'm developing a small web-app with infinite scroll. And I meet strange problem with Safari.
Trying to achieve the next: we have 3 blocks on the page.
As we scrolling page down and middle point of browser view is crossing top position of last block, app making AJAX-request and when it's complete it's remove first block, appends new one after the last, and shifting scroll bottom on deleted block's height (to make a feeling that the scroll was not at all).
The same behavior is when we scrolling to top: when we cross bottom position of first block, AJAX-request, after it's completion removing bottom block, add new block at the top, and scrolling down to height of added block's height.
Let's play here (source code is a rather readable)
It works great on Chrome or Firefox. But when we run it on Safari, we can meet one strange thing.
Focus on these seconds: 0:11, 0:26, 0:50, 0:53, 1:00, 1:05 and some after...
It seems that after loading AJAX and making described DOM manipulations there's small timeout before scrollTop's firing.
Have no idea what to do...
MacBook Pro, OS X Mountain Lion (10.8.3)