Ticket #10364 (closed bug: invalid)
Animate and stop on a object
| Reported by: | anonymous | Owned by: | anonymous |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | effects | Version: | 1.6.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Hi,
I animate an object. When the animation finish, i stop all animations on this object (to be sure that no other animation are still running), and set an other animation on this object: it doesn't work.
A script example:
$(function($) {
o={i:1}
oW=$(o);
oH=$(o);
oW.animate({i:10},{duration:2000,complete:function(){
alert('first animate complete');
oW.stop(true);
oW.animate({i:20},{duration:2000,complete:function(){
alert('second animate never complete')
}});
}});
});
Change History
comment:2 Changed 19 months ago by timmywil
- Owner set to anonymous
- Priority changed from undecided to low
- Status changed from new to pending
- Component changed from unfiled to effects
Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.
Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.
comment:3 Changed 18 months ago by kiplaic
Thanks!
It's ok for the complete function from animate.
But the trigger function is not also asynchronous. Please see the following example.
I understand that this change is not possible on the current trigger functions: The behavior should be very too different. But is it possible to add a new trigger function that would be asynchronous. You can call it triggerAsync or triggerAsyncrone or else
Thank you in advance
comment:4 Changed 18 months ago by kiplaic
oh sorry!
I have upadted your link: http://jsfiddle.net/FrKyN/129/ The result for the complete function in animate is correct for jQuery(edge)and jQuery 1.7.
thanks
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

The problem is in the step function. The complete function is called in synchronous mode. The first complete function is executed when the current step function is not finished. So the stop function stop the next animation.
To solve this problem:
line 8543 of jquery-1.6.4.js source in the step function, don't call directly the complete function but use a setTimeout to have an asynchronous call:
In the same way the trigger function is not asynchronous. Normally events are asynchronous, so it would be interressant to do the same way as before. A suggestion:
$.fn.triggerH=function(eventType, extraParameters) { setTimeout($.proxy(this.triggerHandler,this), 2, eventType, extraParameters); }