0

Here's what I'm trying to do

  1. There is a delete button, on clicking of which, an undo button drops down into view.
  2. The undo button stays in view for 5 seconds and then retreats partially, so about a third of the button is still visible at the top of the page. Hovering over the button reveals the full button and the user can still click it to undo the delete operation.
  3. Only after undo-ing, the undo button completely retreats and disappears completely from view, as it was when the page loaded.

JSBin test case: http://jsbin.com/IzIqAPOZ/1/

It works pretty well, for the most part. The problem is (also described in the test case) if the delete button, undo button, delete button again are clicked within those 5 seconds, the undo button that appears after the second click on delete button retreats before the 5 seconds.

I've added a progress bar to the undo button in the test case so you can see. Click delete, undo and delete quickly and you'll see that the undo button retreats before the progress bar hits full.

However if you click the delete button and let it be, the undo button retreats only after the progress is complete.

I think the problem lies with the clearQueue call on line 21. I tried replacing it with stop but nothing helped. Does anyone know what I'm doing wrong here?

2
  • Did you try stop(true)? The first argument is the clearqueue bool
    – Johan
    Jan 1, 2014 at 16:36
  • Yes, I've tried all combinations of both the arguments to stop.
    – sharat87
    Jan 1, 2014 at 16:37

1 Answer 1

0

It works better for me if I use .finish() instead of .clearQueue(), but I can't say why (yet).

2
  • Yes! This works. I never knew of the finish method. Still don't understand what's going on, but hey, it works :). Thank you very much!
    – sharat87
    Jan 1, 2014 at 17:07
  • @ShrikantSharat it must be something about the internal management of the queue; it may also be a jQuery bug. I just tried .finish() on a hunch.
    – Pointy
    Jan 1, 2014 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.