mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
effects: Updating bounce/pulsate/shake to fire callbacks before the next anim starts
This commit is contained in:
parent
27a7deebf2
commit
783f134aaa
19
ui/jquery.effects.bounce.js
vendored
19
ui/jquery.effects.bounce.js
vendored
@ -79,10 +79,8 @@ $.effects.effect.bounce = function(o) {
|
||||
upAnim = {};
|
||||
upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
|
||||
|
||||
// add the finish callback to the last animation if we aren't hiding
|
||||
el.animate( upAnim, speed, easing )
|
||||
.animate( downAnim, speed, easing,
|
||||
( ( i === times - 1 ) && !hide ) ? finish : undefined );
|
||||
.animate( downAnim, speed, easing );
|
||||
|
||||
distance = hide ? distance * 2 : distance / 2;
|
||||
}
|
||||
@ -92,24 +90,25 @@ $.effects.effect.bounce = function(o) {
|
||||
upAnim = { opacity: 0 };
|
||||
upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
|
||||
|
||||
el.animate( upAnim, speed, easing, function(){
|
||||
el.hide();
|
||||
finish();
|
||||
});
|
||||
el.animate( upAnim, speed, easing );
|
||||
}
|
||||
|
||||
function finish() {
|
||||
el.queue( function( next ) {
|
||||
if ( hide ) {
|
||||
el.hide();
|
||||
}
|
||||
$.effects.restore( el, props );
|
||||
$.effects.removeWrapper( el );
|
||||
if ( o.complete ) {
|
||||
o.complete.apply( el[ 0 ] );
|
||||
}
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
// inject all the animations we just queued to be first in line (after "inprogress")
|
||||
if ( queuelen > 1) {
|
||||
queue.splice.apply( queue,
|
||||
[ 1, 0 ].concat( queue.splice( queuelen, anims ) ) );
|
||||
[ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
|
||||
}
|
||||
next();
|
||||
|
||||
|
7
ui/jquery.effects.pulsate.js
vendored
7
ui/jquery.effects.pulsate.js
vendored
@ -43,19 +43,22 @@ $.effects.effect.pulsate = function( o ) {
|
||||
|
||||
elem.animate({
|
||||
opacity: animateTo
|
||||
}, duration, o.easing, function() {
|
||||
}, duration, o.easing);
|
||||
|
||||
elem.queue( function( next ) {
|
||||
if ( hide ) {
|
||||
elem.hide();
|
||||
}
|
||||
if ( o.complete ) {
|
||||
o.complete.apply( this );
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
// We just queued up "anims" animations, we need to put them next in the queue
|
||||
if ( queuelen > 1) {
|
||||
queue.splice.apply( queue,
|
||||
[ 1, 0 ].concat( queue.splice( queuelen, anims ) ) );
|
||||
[ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
7
ui/jquery.effects.shake.js
vendored
7
ui/jquery.effects.shake.js
vendored
@ -54,20 +54,21 @@ $.effects.effect.shake = function( o ) {
|
||||
};
|
||||
el
|
||||
.animate( animation1, speed, o.easing )
|
||||
.animate( animation, speed / 2, o.easing, function() {
|
||||
.animate( animation, speed / 2, o.easing )
|
||||
.queue( function( next ) {
|
||||
if ( mode === "hide" ) {
|
||||
el.hide();
|
||||
}
|
||||
// Last shake
|
||||
$.effects.restore( el, props );
|
||||
$.effects.removeWrapper( el );
|
||||
$.isFunction( o.complete ) && o.complete.apply( this, arguments );
|
||||
next();
|
||||
});
|
||||
|
||||
// inject all the animations we just queued to be first in line (after "inprogress")
|
||||
if ( queuelen > 1) {
|
||||
queue.splice.apply( queue,
|
||||
[ 1, 0 ].concat( queue.splice( queuelen, anims ) ) );
|
||||
[ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
|
||||
}
|
||||
el.dequeue();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user