Bug Tracker

Modify

Ticket #9846 (closed bug: worksforme)

Opened 3 years ago

Last modified 3 years ago

.done() does not fire when animation has complete callback

Reported by: KarlG Owned by:
Priority: low Milestone: 1.next
Component: deferred Version: 1.6.2
Keywords: Cc:
Blocking: Blocked by:

Description

I'm not completely sure this is a bug, but it does seem to be an unexpected change in behavior from 1.6.1 to 1.6.2. Here is the test case:

<!DOCTYPE html>
<html>
  <head>

    <script type="text/javascript" src="/js/jquery-1.6.2.js"></script>

    <script type="text/javascript">
    
    $(document).ready(function() {
    
      var slideUpAndRemove = function() {
        $(this).slideUp(function() { 
          $(this).remove(); 
        });
      }
      
      var box = $("#box"); 
      box.animate({
        opacity : 0.0
      }, {
        duration : 2000,
        complete : slideUpAndRemove
      });
      
      $.when(box).done(function() {
        alert('done!');
      });
    });
      
    </script>

  </head>
  <body>
    <div id="box" style="color:white;background-color:green;position:absolute;height:200px;width:200px">This is a test box</div>
    <div>Below the animated box</div>
  </body>
</html>

In 1.6.1, the 'done!' alert box consistently appears. It does not in 1.6.2.

I have tested in FF 5 and Chrome 14 (Ubuntu 10.04).

Change History

comment:1 Changed 3 years ago by anonymous

Here's the test case in jsFiddle:

 http://jsfiddle.net/yXPBY/

Toggle between loading the two versions to see the bug occur/not occur.

comment:2 Changed 3 years ago by anonymous

The issue seems to be related to the fact that the elements are getting removed in the complete callback. This version accomplishes the same thing and works in 1.6.2:

 http://jsfiddle.net/YRfJB/

So, like I said, I'm not sure if this counts as a bug but it is a change in behavior. I can live with the second alternative just fine.

comment:3 Changed 3 years ago by anonymous

Sorry, I seem to have faddled that last fiddle. Here's the alternative I meant to post:

 http://jsfiddle.net/DTALV/

comment:4 Changed 3 years ago by rwaldron

  • Priority changed from undecided to low
  • Resolution set to worksforme
  • Status changed from new to closed
  • Component changed from unfiled to deferred

Closing per OPs test case

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.