Skip to main content

Bug Tracker

Side navigation

#1827 closed bug (fixed)

Opened October 19, 2007 10:01PM UTC

Closed November 16, 2007 09:53PM UTC

Last modified March 15, 2012 12:15AM UTC

calling stop() can cause extra setInterval calls slowing down animations

Reported by: davidserduke Owned by: davidserduke
Priority: major Milestone: 1.2.2
Component: effects Version: 1.2.1
Keywords: Cc:
Blocked by: Blocking:

I noticed on the wiki Effects/stop page that if you queued up a bunch of animations then start calling stop() the animation starts to slow down. (more noticeable in FF)

It appears the reason is stop removes the timer call then immediately queues another one. This results in the timers list going from a length of 1 to a length of 0, THEN calls eventually calls custom() which pushes a new animation on the timers to create a length of 1. At this point it calls setInterval (since timers.length == 1) even though the previous interval is still running. So now you have more intervals running. To test this I set up a page with setInterval and clearInterval overwritten to count how many times they are called. This test case will be attached.

I think the easiest fix is to make the timerId for the setInterval global instead of in closure then just check to see if it isn't null before starting a new one. Attached is a patch that fixes the test case this way.

Attachments (2)
  • 1827.diff (0.8 KB) - added by davidserduke October 19, 2007 10:03PM UTC.


  • jquery_test.html (1.3 KB) - added by davidserduke October 19, 2007 10:02PM UTC.

    test case

Change History (2)

Changed November 15, 2007 01:52PM UTC by brandon comment:1

need: ReviewCommit
owner: → davidserduke

Changed November 16, 2007 09:53PM UTC by davidserduke comment:2

resolution: → fixed
status: newclosed

Fix in [3837].