Bug Tracker

Opened 11 years ago

Closed 10 years ago

#6150 closed bug (fixed)

.stop sometimes doesn't clear .delay

Reported by: cowboy Owned by: gnarf
Priority: blocker Milestone: 1.7
Component: effects Version: 1.4.1
Keywords: delay, stop, setTimeout, 1.7-discuss Cc:
Blocked by: Blocking:

Description

If .stop is called after the setTimeout in .delay has executed, there's no way for that setTimeout to be stopped, so the callback executes after "time" milliseconds, no matter what.

Change History (25)

comment:1 Changed 11 years ago by dmethvin

Component: unfiledfx

comment:2 Changed 11 years ago by addyosmani

Owner: set to cowboy
Priority: undecided
Status: newpending

Please submit a valid test case that reproduces this issue.

comment:3 Changed 11 years ago by cowboy

Status: pendingnew

Here you go, sorry I never added this into the ticket!

http://jsfiddle.net/cowboy/xxvFa/

comment:4 Changed 11 years ago by SlexAxton

Keywords: delay stop setTimeout added
Milestone: 1.4.21.5
Priority: undecidedlow
Status: newopen

Appreciate the test case, ben.

comment:5 Changed 10 years ago by cowboy

Owner: changed from cowboy to john
Status: openassigned

comment:6 Changed 10 years ago by john

Milestone: 1.next
Priority: lowblocker

comment:7 Changed 10 years ago by john

#6576 is a duplicate of this ticket.

comment:8 Changed 10 years ago by T.J. Crowder

Just "me too"-ing. stop() should stop delays. It seems like it should be really easy to implement delay() as an animation of the given duration that doesn't actually change anything (if, unlike me, you already understand how jQuery's animation infrastructure works). That would make it play nicely with the various other animation functions (like stop()).

comment:9 Changed 10 years ago by john

Keywords: 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:10 Changed 10 years ago by gnarf

You could just animate a non-property

$.fn.delay = function( duration ) {
    return this.animate({
       _: 0
    }, duration);

However, This brings up a great point.... stopHooks...

There are a lot of UI effects that CANT be .stop()'ed because they don't actually use the queue... It might be nice to create some sort of method that non-standard animates can provide a function to be called on stop...

Imagine:

$.fn.delay = function( duration ) {
    return this.queue( function( next, onstop ) {
       var timer = setTimeout( next, duration );
       onstop( function( gotoEnd ) {
         clearTimeout( timer );
         if ( gotoEnd ) {
            next();
          }
       });
    });
};

comment:11 Changed 10 years ago by Rick Waldron

+1, Sounds like a bug, should be fixed

comment:12 Changed 10 years ago by jaubourg

+1, Sounds like a nasty little bug

comment:13 Changed 10 years ago by ajpiano

+1, Exterminate!

comment:14 Changed 10 years ago by timmywil

+1, could this be fixed by simply adding the setTimeout timer to jQuery.timers?

comment:15 Changed 10 years ago by danheberden

+1

comment:16 Changed 10 years ago by dmethvin

+1, Do not annoy the cowboy.

comment:17 Changed 10 years ago by john

+1

comment:18 Changed 10 years ago by scottgonzalez

+1, clearly just an implementation bug

comment:19 Changed 10 years ago by jzaefferer

+1

comment:20 Changed 10 years ago by cowboy

+1, heh

comment:21 Changed 10 years ago by john

Milestone: 1.next1.7

comment:22 Changed 10 years ago by john

Owner: changed from john to gnarf

comment:23 Changed 10 years ago by john

Milestone: 1.71.6.3

comment:24 Changed 10 years ago by timmywil

Milestone: 1.6.31.7

We are currently favoring a fix for this that would include an additional parameter for delay and considering delay has always behaved this way, we're going to push this to 1.7.

comment:25 Changed 10 years ago by Corey Frang

Resolution: fixed
Status: assignedclosed

Landing pull request 514. 1.7 - queue refactoring to handle delay stop - Fixes #6150.

More Details:

Note: See TracTickets for help on using tickets.