Fx.cancel() should clear animation so Fx.resume() will not continue it #2207

Closed
ibolmo opened this Issue Jan 19, 2012 · 3 comments

Comments

Projects
None yet
3 participants
@ibolmo
Member

ibolmo commented Jan 19, 2012

(from Lighthouse)

When Fx.resume() is called after Fx.cancel(), the animation is resumed as if it were paused, rather than cancelled.

Really simple test case:

$('test').set('tween', {duration: 2000}).tween('width', 100);
$('test').get('tween').cancel();
$('test').get('tween').resume();

The animation should be cancelled almost immediately, but in fact it continues and finishes.


(from a follow-up)

Correct, the element shouldn't be returned to its starting position. What I mean is that the animation starts, then is stopped via Fx.cancel(), which is all well and good. Then if Fx.resume() is called after, the animation actually continues and completes itself.
Surely Fx.cancel() should stop the animation and clear it so it can't be resumed, otherwise Fx.pause() and Fx.cancel() serve the same purpose, the only difference being the onCancel event being fired? If this is the intended functionality, I think this should be made clear in the docs as the function names would imply otherwise.

$('test').set('tween', {duration: 2000}).tween('width', 100);
(function(){
    $('test').get('tween').cancel();
    $('test').get('tween').resume();
}).delay(1000);

Expected functionality: Animation stops half-way through
Actual functionality: Animation pauses half-way through then is resumed and completes

@MrPrime

This comment has been minimized.

Show comment Hide comment
@MrPrime

MrPrime Feb 1, 2012

personally, I agree with the idea, Fx.cancel() should clear the following animation steps. in jquery, it provides a method called "stop" which take two arguments for stopping animation. but we can do something as follows, I guess:

// if jumpToEnd is true, then just let the element jump to the end of its animation.
// if jumpToEnd is not provided or false, do nothing but stop the animation.
Fx.cancel(/*jumpToEnd type:boolean*/);

what do you say, guys?

MrPrime commented Feb 1, 2012

personally, I agree with the idea, Fx.cancel() should clear the following animation steps. in jquery, it provides a method called "stop" which take two arguments for stopping animation. but we can do something as follows, I guess:

// if jumpToEnd is true, then just let the element jump to the end of its animation.
// if jumpToEnd is not provided or false, do nothing but stop the animation.
Fx.cancel(/*jumpToEnd type:boolean*/);

what do you say, guys?

@ibolmo

This comment has been minimized.

Show comment Hide comment
@ibolmo

ibolmo Feb 1, 2012

Member

Rather let cancel means stop and reset, and for pause to be .. well pause.

Btw, http://silkandspinach.net/2004/07/15/avoid-boolean-parameters/

Member

ibolmo commented Feb 1, 2012

Rather let cancel means stop and reset, and for pause to be .. well pause.

Btw, http://silkandspinach.net/2004/07/15/avoid-boolean-parameters/

@kentaromiura

This comment has been minimized.

Show comment Hide comment
@kentaromiura

kentaromiura Sep 2, 2012

Member

tested with 1.4.5 and:

The animation should be cancelled almost immediately, but in fact it continues and finishes.

the animation is cancelled immediatly.

http://jsfiddle.net/kentaromiura/UeRNE/

Member

kentaromiura commented Sep 2, 2012

tested with 1.4.5 and:

The animation should be cancelled almost immediately, but in fact it continues and finishes.

the animation is cancelled immediatly.

http://jsfiddle.net/kentaromiura/UeRNE/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment