Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Animation depends on timed interrupts. There is no guarantee of exact timings, and so depending on implementation, the timing of your two sliders may diverge.</p> <p>If you just use one slider element, you won't run into that issue. It also simplifies the code quite a bit. The way to do this is to replicate your slider elements (using jQuery) and then animate half the width (the pre-duped width) and start over:</p> <pre><code>$(window).load(function() { var speed = 75; //px per sec // Get the width of the slider before you duplicate it var width = $('#slider').outerWidth(); // Repeat the inner content by cloning and appending it to the end $('#slider').append($('#slider').children().clone()); function slide() { // The duration takes into account the current position // in case you are starting from a hover-pause var curleft = $('#slider').position().left; var duration = (width+curleft) * 1000 / speed; $("#slider").animate({ // Animate until original width slides off to left left: "-" + width + "px" }, duration, "linear", function() { // Reset to original position and start over $(this).css("left", "0px"); slide(); }); } $("#slider").hover(function() { $('#slider').stop(); }, function() { slide(); }); slide(); }); </code></pre> <p>You can also change your hover to just do <code>.stop()</code> and <code>slide()</code> as long as you do a little extra math in your <code>slide()</code> call to see where you currently are.</p> <p>Demo: <a href="http://jsfiddle.net/6Dxg6/" rel="nofollow">http://jsfiddle.net/6Dxg6/</a></p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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