Note that there are some explanatory texts on larger screens.

plurals
  1. POJs Animation using setInterval getting slow over time
    text
    copied!<p>I have a web site which displays a portfolio using this scrollbar <a href="http://manos.malihu.gr/jquery-custom-content-scroller/" rel="nofollow">http://manos.malihu.gr/jquery-custom-content-scroller/</a> .</p> <p>I want to have an automatic scroll when the page is fully loaded. When a user pass over the portfolio it stops the scroll and whe, he leaves it starts moving again.</p> <p>It currently works well but sometimes it's getting slow or sluggish randomly. Is there something wrong with my js function?</p> <p>Here's the page having problems : <a href="http://www.lecarreau.net/new/spip.php?rubrique5" rel="nofollow">http://www.lecarreau.net/new/spip.php?rubrique5</a> (I need the change the hosting provider, I know the site is slow).</p> <p>This is the function:</p> <pre><code>(function($){ var timerId = 0; $(window).load(function(){ $("#carousel").show().mCustomScrollbar( { mouseWheel:false, mouseWheelPixels:50, horizontalScroll:true, setHeight:370, scrollButtons:{ enable: true, scrollSpeed:50 }, advanced:{ updateOnContentResize:true } }); timerId = setInterval(function(){myTimer()},50); $('#carousel').mouseenter(function () { clearInterval(timerId); }); $('#carousel').mouseleave(function () { timerId = setInterval(function(){myTimer()},50); }); }); })(jQuery); function myTimer() { var width = $(".mCSB_container").width(); var left = $(".mCSB_container").position().left; if (width-left&gt;0) { var scrollTo = -left+4; $("#carousel").mCustomScrollbar("scrollTo", scrollTo); } } </code></pre> <p>Is there something obvious I'm missing?</p>
 

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