Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent mobile-safari from jumping when unloading pages from a list on iPad?
    primarykey
    data
    text
    <p>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.</p> <p>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.</p> <p><a href="http://jsfiddle.net/Xrr3y/" rel="nofollow">Link to the example.</a> </p> <p>The layout:</p> <pre><code>&lt;div class="container"&gt;&lt;div class="innerContainer"&gt; &lt;div class="page"&gt; &lt;div class="message" style="height:300px"&gt;...&lt;/div&gt; &lt;div class="message"&gt;...&lt;/div&gt; &lt;div class="message"&gt;...&lt;/div&gt; &lt;div class="message"&gt;...&lt;/div&gt; &lt;div class="message"&gt;...&lt;/div&gt; &lt;/div&gt; &lt;div class="page"&gt; ... &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Please note the behaviour is exactly the same if I use UL and LIs instead of DIVs.</p> <p>The code of LoadMore button:</p> <pre><code>newScrollPosition = container.scrollTop()-firstPage.outerHeight(); container.scrollTop(newScrollPosition); innerContainer.append(newPage); firstPage.remove(); </code></pre> <p>It works fine when all the messages are the same height, but when any message has different height it jumps ugly.</p> <p>Just remember that issue occurs only at the very bottom of the list. </p> <p>I've tried the following ways of removing the firstPage but the outcome is always the same:</p> <ul> <li>display:none</li> <li>jquery remove</li> <li>elem.parentNode.removeChild( elem )</li> <li>absolute position with top and left outside of the screen</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload