Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 8 years ago

#1827 closed bug (fixed)

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:

Description

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)

jquery_test.html (1.3 KB) - added by davidserduke 13 years ago.
test case
1827.diff (808 bytes) - added by davidserduke 13 years ago.
patch

Download all attachments as: .zip

Change History (4)

Changed 13 years ago by davidserduke

Attachment: jquery_test.html added

test case

Changed 13 years ago by davidserduke

Attachment: 1827.diff added

patch

comment:1 Changed 13 years ago by brandon

need: ReviewCommit
Owner: set to davidserduke

comment:2 Changed 13 years ago by davidserduke

Resolution: fixed
Status: newclosed

Fix in [3837].

Note: See TracTickets for help on using tickets.