setTimeout speeds up with multiple tabs

后端 未结 7 1614
慢半拍i
慢半拍i 2020-12-10 07:47

I’m having a setTimeout problem similar to this one. But that solution doesn\'t help me since I can’t use php in my file.

My site has a slider with a list of images

7条回答
  •  情深已故
    2020-12-10 08:11

    You must also think you use clearTimeout.

    As you call setTimeout function it returns an ID you can save this ID in a variable like

    timeoutID = setTimeout(function () {
                    spotlight.animate(spotlight.i);
                }, 8000);
    

    and before setting a new timeout you can call the function like

    clearTimeout(timeoutID)
    

提交回复
热议问题