Note that there are some explanatory texts on larger screens.

plurals
  1. POContent flicker/jump on infinite scroll/loop
    primarykey
    data
    text
    <p>I am looking for help / a point in the right direction / or a solution for a flicker/jump, when scrolling on a looping/infinite website, which can be seen in <a href="http://jsfiddle.net/djsbaker/j3d8r/1/" rel="nofollow">this fiddle</a>.</p> <p>What seems to be causing the jump is:</p> <p>"<code>$(window).scrollTop(half_way - child_height);</code>", and what could also be a Chrome windows scrollTop bug, but it is happening in all browsers at the moment.</p> <p>If I remove "<code>- child_height</code>" there is no longer a flicker but the page no longer scrolls correctly, which can be seen in <a href="http://jsfiddle.net/djsbaker/x5Tsp/3/" rel="nofollow">this fiddle</a>.</p> <p>Also, on the very first scroll the right hand column jumps up by three boxes - also because of '<code>half_way</code>', which I can fix by giving it a "<code>bottom: -600px;</code>"</p> <p>The full code:</p> <p><a href="http://jsfiddle.net/djsbaker/j3d8r/1/" rel="nofollow">http://jsfiddle.net/djsbaker/j3d8r/1/</a></p> <pre><code>var num_children = $('#up-left').children().length; var child_height = $('#up-left').height() / num_children; var half_way = num_children * child_height / 2; $(window).scrollTop(half_way); function crisscross() { $('#up-left').css('bottom', '-' + window.scrollY + 'px'); $('#down-right').css('bottom', '-' + window.scrollY + 'px'); var firstLeft = $('#up-left').children().first(); var lastLeft = $('#up-left').children().last(); var lastRight = $('#down-right').children().last(); var firstRight = $('#down-right').children().first(); if (window.scrollY &gt; half_way ) { $(window).scrollTop(half_way - child_height); lastRight.appendTo('#up-left'); firstLeft.prependTo('#down-right'); } else if (window.scrollY &lt; half_way - child_height) { $(window).scrollTop(half_way); lastLeft.appendTo('#down-right'); firstRight.prependTo('#up-left'); } } $(window).scroll(crisscross); </code></pre>
    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.
 

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