Bug Tracker

Opened 8 years ago

Closed 8 years ago

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

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 (5)

comment:1 Changed 8 years ago by palickil@…

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:

setTimeout($.proxy(options.complete,elem),2);

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);
}

comment:2 Changed 8 years ago by timmywil

Component: unfiledeffects
Owner: set to anonymous
Priority: undecidedlow
Status: newpending

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 8 years 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.

http://jsfiddle.net/rD9at/

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 8 years 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

comment:5 Changed 8 years ago by timmywil

Resolution: invalid
Status: pendingclosed

Thank you for investigating the issue further.

Note: See TracTickets for help on using tickets.