Why is jQuery animation accelerated after the first run?

I create a base area that takes a set of list items and scrolls them (this is for a sports site, they want to use a news ticker).

Everything works, except that after the first start, the duration increases.

var duration = 10000;
var textScroll = function(toScroll, time)
   {
      toScroll.animate({left:"-"+toScroll.children().text().length+"px"},time,"linear", function()
      {
         $(this).css({left:toScroll.children().text().length});
         textScroll($(this),duration);
      });
   };
   textScroll($('.textScroll ul'), duration);

As I said, it scrolls great. It just gets faster after the first scroll.

Any ideas?

+3
source share
1 answer

, left , , . , left CSS toScroll.children().text().length, . left ?

+1

Source: https://habr.com/ru/post/1757213/


All Articles