Bug Tracker

Ticket #6150 (closed bug: fixed)

Opened 5 years ago

Last modified 3 years ago

.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:
Blocking: Blocked by:

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

comment:1 Changed 4 years ago by dmethvin

  • Component changed from unfiled to fx

comment:2 Changed 4 years ago by addyosmani

  • Owner set to cowboy
  • Priority set to undecided
  • Status changed from new to pending

Please submit a valid test case that reproduces this issue.

comment:3 Changed 4 years ago by cowboy

  • Status changed from pending to new

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

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

comment:4 Changed 4 years ago by SlexAxton

  • Keywords delay stop setTimeout added
  • Priority changed from undecided to low
  • Status changed from new to open
  • Milestone changed from 1.4.2 to 1.5

Appreciate the test case, ben.

comment:5 Changed 4 years ago by cowboy

  • Owner changed from cowboy to john
  • Status changed from open to assigned

comment:6 Changed 4 years ago by john

  • Priority changed from low to blocker
  • Milestone set to 1.next

comment:7 Changed 4 years ago by john

#6576 is a duplicate of this ticket.

comment:8 Changed 3 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 3 years ago by john

  • Keywords delay,stop,setTimeout,1.7-discuss added; delay stop setTimeout removed

Nominating ticket for 1.7 discussion.

comment:10 Changed 3 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 3 years ago by rwaldron

+1, Sounds like a bug, should be fixed

comment:12 Changed 3 years ago by jaubourg

+1, Sounds like a nasty little bug

comment:13 Changed 3 years ago by ajpiano

+1, Exterminate!

comment:14 Changed 3 years ago by timmywil

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

comment:15 Changed 3 years ago by danheberden

+1

comment:16 Changed 3 years ago by dmethvin

+1, Do not annoy the cowboy.

comment:17 Changed 3 years ago by john

+1

comment:18 Changed 3 years ago by scott.gonzalez

+1, clearly just an implementation bug

comment:19 Changed 3 years ago by jzaefferer

+1

comment:20 Changed 3 years ago by cowboy

+1, heh

comment:21 Changed 3 years ago by john

  • Milestone changed from 1.next to 1.7

comment:22 Changed 3 years ago by john

  • Owner changed from john to gnarf

comment:23 Changed 3 years ago by john

  • Milestone changed from 1.7 to 1.6.3

comment:24 Changed 3 years ago by timmywil

  • Milestone changed from 1.6.3 to 1.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 3 years ago by Corey Frang

  • Status changed from assigned to closed
  • Resolution set to fixed

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

More Details:

Note: See TracTickets for help on using tickets.