Skip to main content

Bug Tracker

Side navigation

#6255 closed feature (worksforme)

Opened March 10, 2010 10:30AM UTC

Closed October 04, 2010 01:40AM UTC

Last modified December 15, 2010 04:36PM UTC

.delay() is not stopped by .stop(true,true)

Reported by: ffx Owned by:
Priority: undecided Milestone: 1.4.3
Component: effects Version: 1.4.2
Keywords: delay stop Cc:
Blocked by: Blocking:
Description

.delay() is implemented with a setTimeout() without remembering the return value. So the timeout cannot be stopped once started.

Could you implement it in one of these ways:

1. The user can manually remove the timeout with clearTimeout()

2. Nicer would be, if .delay would be also stopped by .stop() / .clearQueue()

Attachments (0)
Change History (3)

Changed October 04, 2010 01:40AM UTC by addyosmani comment:1

priority: → undecided
resolution: → worksforme
status: newclosed

Please note that in reference to .delay():

(from our documentation)

jQuery.delay() is best for delaying between queued jQuery effects and such, and is not a replacement for JavaScript's native setTimeout function, which may be more appropriate for certain use cases.

In the above case if you were to require access to the complete setTimeout() function with a callback it would make more sense to use that rather than .delay() however..

.delay() *can* actually already be stopped using clearQueue as follows:

$("#element").delay(800).fadeOut(400);

$("#element").clearQueue();

You can see this working below:

Live test: http://jsfiddle.net/k4853/

If you have further comments or would like to submit a further explanation as to the benefits of allowing .stop() to be used here (as well as how it would behave) please feel free to submit a new ticket.

Changed December 15, 2010 04:34PM UTC by JurekRaben comment:2

addyosmani: Sorry, that's not true!

See this extended example: http://jsfiddle.net/k4853/9/

clearQueue() just clears the queue instructions but NOT the setTimeout. So next usage of delay will then cause wrong behaviour and wrong results.

This has to be fixed. I already did this with a patch for the jquery core, but maybe it needs some review and improvements.

jquery delay patch

Changed December 15, 2010 04:36PM UTC by anonymous comment:3

See this bug report here: http://bugs.jquery.com/ticket/6576