I'm developing an infinite list using HTML5 on iPad with Retina. The idea is to render two pages then remove the first page and append next one to the bottom of the list. It works fine on Desktop Safari and Chrome but not on iPad.
There are two pages in the example. All the messages are the same 120px height but the very first one with 300px height. To reproduce the issue scroll to the very bottom and press a LoadMore button and you should notice that it jumps up and then to the correct position. It looks like there is a slight delay between scrolling and removing. Now all the messages are the same 120px height and if you scroll at the bottom and click button again there won't be any jumps and it will behave as expected. Press restart button to start again.
The layout:
<div class="container"><div class="innerContainer">
<div class="page">
<div class="message" style="height:300px">...</div>
<div class="message">...</div>
<div class="message">...</div>
<div class="message">...</div>
<div class="message">...</div>
</div>
<div class="page">
...
</div>
</div>
</div>
Please note the behaviour is exactly the same if I use UL and LIs instead of DIVs.
The code of LoadMore button:
newScrollPosition = container.scrollTop()-firstPage.outerHeight();
container.scrollTop(newScrollPosition);
innerContainer.append(newPage);
firstPage.remove();
It works fine when all the messages are the same height, but when any message has different height it jumps ugly.
Just remember that issue occurs only at the very bottom of the list.
I've tried the following ways of removing the firstPage but the outcome is always the same:
- display:none
- jquery remove
- elem.parentNode.removeChild( elem )
- absolute position with top and left outside of the screen