mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Merge remote branch 'gnarf37/ticket-7067'
This commit is contained in:
commit
b546f316be
@ -14,12 +14,14 @@ $(function() {
|
|||||||
|
|
||||||
$(el).bind("click", function() {
|
$(el).bind("click", function() {
|
||||||
|
|
||||||
$(this).addClass("current").hide(n, o, duration, function() {
|
$(this).addClass("current")
|
||||||
var self = this;
|
// delaying the initial animation makes sure that the queue stays in tact
|
||||||
window.setTimeout(function() {
|
.delay( 10 )
|
||||||
$(self).show(n, o, duration, function() { $(this).removeClass("current"); });
|
.hide( n, o, duration )
|
||||||
}, wait);
|
.delay( wait )
|
||||||
});
|
.show( n, o, duration, function() {
|
||||||
|
$( this ).removeClass("current");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
144
ui/jquery.effects.bounce.js
vendored
144
ui/jquery.effects.bounce.js
vendored
@ -12,89 +12,107 @@
|
|||||||
*/
|
*/
|
||||||
(function( $, undefined ) {
|
(function( $, undefined ) {
|
||||||
|
|
||||||
var rshowhide = /show|hide/;
|
|
||||||
|
|
||||||
$.effects.effect.bounce = function(o) {
|
$.effects.effect.bounce = function(o) {
|
||||||
|
|
||||||
return this.queue(function() {
|
return this.queue( function( next ) {
|
||||||
|
|
||||||
// Create element
|
|
||||||
var el = $( this ),
|
var el = $( this ),
|
||||||
props = [ 'position', 'top', 'bottom', 'left', 'right' ],
|
props = [ "position", "top", "bottom", "left", "right" ],
|
||||||
|
|
||||||
// defaults:
|
// defaults:
|
||||||
mode = $.effects.setMode( el, o.mode || 'effect' ),
|
mode = $.effects.setMode( el, o.mode || "effect" ),
|
||||||
direction = o.direction || 'up',
|
hide = mode === "hide",
|
||||||
distance = o.distance || 20,
|
show = mode === "show",
|
||||||
|
direction = o.direction || "up",
|
||||||
|
distance = o.distance,
|
||||||
times = o.times || 5,
|
times = o.times || 5,
|
||||||
speed = (o.duration || 250),
|
|
||||||
|
// number of internal animations
|
||||||
|
anims = times * 2 + ( show || hide ? 1 : 0 ),
|
||||||
|
speed = o.duration / anims,
|
||||||
|
easing = o.easing,
|
||||||
|
|
||||||
// utility:
|
// utility:
|
||||||
ref = ( direction == 'up' || direction == 'down' ) ? 'top' : 'left',
|
ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
|
||||||
motion = ( direction == 'up' || direction == 'left' ), // true is positive
|
motion = ( direction === "up" || direction === "left" ),
|
||||||
i, animation, animation1, animation2;
|
i,
|
||||||
|
upAnim,
|
||||||
|
downAnim,
|
||||||
|
|
||||||
|
// we will need to re-assemble the queue to stack our animations in place
|
||||||
|
queue = el.queue(),
|
||||||
|
queuelen = queue.length;
|
||||||
|
|
||||||
// Avoid touching opacity to prevent clearType and PNG issues in IE
|
// Avoid touching opacity to prevent clearType and PNG issues in IE
|
||||||
if ( rshowhide.test( mode ) ) {
|
if ( show || hide ) {
|
||||||
props.push( 'opacity' );
|
props.push( "opacity" );
|
||||||
}
|
}
|
||||||
|
|
||||||
$.effects.save( el, props );
|
$.effects.save( el, props );
|
||||||
el.show();
|
el.show();
|
||||||
$.effects.createWrapper( el ); // Create Wrapper
|
$.effects.createWrapper( el ); // Create Wrapper
|
||||||
|
|
||||||
|
// default distance for the BIGGEST bounce is the outer Distance / 3
|
||||||
if ( !distance ) {
|
if ( !distance ) {
|
||||||
distance = el[ ref == 'top' ? 'outerHeight' : 'outerWidth' ]({ margin:true }) / 3;
|
distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
|
||||||
}
|
|
||||||
if ( mode == 'show' ) el.css( 'opacity', 0 ).css( ref, motion ? -distance : distance ); // Shift
|
|
||||||
if ( mode == 'hide' ) distance = distance / (times * 2);
|
|
||||||
if ( mode != 'hide' ) times--;
|
|
||||||
|
|
||||||
// Animate
|
|
||||||
if ( mode == 'show' ) {
|
|
||||||
animation = {
|
|
||||||
opacity: 1
|
|
||||||
};
|
|
||||||
animation[ ref ] = ( motion ? '+=' : '-=' ) + distance;
|
|
||||||
el.animate( animation, speed / 2, o.easing);
|
|
||||||
distance = distance / 2;
|
|
||||||
times--;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Bounces
|
|
||||||
for (i = 0; i < times; i++) {
|
|
||||||
animation1 = {};
|
|
||||||
animation2 = {};
|
|
||||||
animation1[ ref ] = ( motion ? '-=' : '+=' ) + distance;
|
|
||||||
animation2[ ref ] = ( motion ? '+=' : '-=' ) + distance;
|
|
||||||
el.animate( animation1, speed / 2, o.easing ).animate( animation2, speed / 2, o.easing );
|
|
||||||
distance = ( mode == 'hide' ) ? distance * 2 : distance / 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last Bounce
|
if ( show ) {
|
||||||
if ( mode == 'hide' ) {
|
downAnim = { opacity: 1 };
|
||||||
animation = {
|
downAnim[ ref ] = 0;
|
||||||
opacity: 0
|
|
||||||
};
|
// if we are showing, force opacity 0 and set the initial position
|
||||||
animation[ ref ] = ( motion ? '-=' : '+=' ) + distance;
|
// then do the "first" animation
|
||||||
el.animate( animation, speed / 2, o.easing, function(){
|
el.css( "opacity", 0 )
|
||||||
|
.css( ref, motion ? -distance*2 : distance*2 )
|
||||||
|
.animate( downAnim, speed, easing );
|
||||||
|
}
|
||||||
|
|
||||||
|
// start at the smallest distance if we are hiding
|
||||||
|
if ( hide ) {
|
||||||
|
distance = distance / Math.pow( 2, times - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
downAnim = {};
|
||||||
|
downAnim[ ref ] = 0;
|
||||||
|
// Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
|
||||||
|
for ( i = 0; i < times; i++ ) {
|
||||||
|
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 );
|
||||||
|
|
||||||
|
distance = hide ? distance * 2 : distance / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Last Bounce when Hiding
|
||||||
|
if ( hide ) {
|
||||||
|
upAnim = { opacity: 0 };
|
||||||
|
upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
|
||||||
|
|
||||||
|
el.animate( upAnim, speed, easing, function(){
|
||||||
el.hide();
|
el.hide();
|
||||||
$.effects.restore( el, props );
|
finish();
|
||||||
$.effects.removeWrapper( el );
|
|
||||||
$.isFunction( o.complete ) && o.complete.apply( this, arguments );
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
animation1 = {};
|
|
||||||
animation2 = {};
|
|
||||||
animation1[ ref ] = ( motion ? '-=' : '+=' ) + distance;
|
|
||||||
animation2[ ref ] = ( motion ? '+=' : '-=' ) + distance;
|
|
||||||
el
|
|
||||||
.animate( animation1, speed / 2, o.easing )
|
|
||||||
.animate( animation2, speed / 2, o.easing, function() {
|
|
||||||
$.effects.restore( el, props );
|
|
||||||
$.effects.removeWrapper( el );
|
|
||||||
$.isFunction( o.complete ) && o.complete.apply( this, arguments );
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
el.dequeue();
|
|
||||||
|
function finish() {
|
||||||
|
$.effects.restore( el, props );
|
||||||
|
$.effects.removeWrapper( el );
|
||||||
|
if ( o.complete ) {
|
||||||
|
o.complete.apply( el[ 0 ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 ) ) );
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
43
ui/jquery.effects.pulsate.js
vendored
43
ui/jquery.effects.pulsate.js
vendored
@ -13,39 +13,50 @@
|
|||||||
(function( $, undefined ) {
|
(function( $, undefined ) {
|
||||||
|
|
||||||
$.effects.effect.pulsate = function( o ) {
|
$.effects.effect.pulsate = function( o ) {
|
||||||
return this.queue( function() {
|
return this.queue( function( next ) {
|
||||||
var elem = $( this ),
|
var elem = $( this ),
|
||||||
mode = $.effects.setMode( elem, o.mode || 'show' ),
|
mode = $.effects.setMode( elem, o.mode || "effect" ),
|
||||||
times = ( ( o.times || 5 ) * 2 ) - 1,
|
show = mode === "show" || elem.is( ":hidden" ),
|
||||||
duration = o.duration / 2,
|
showhide = ( show || mode === "hide" ),
|
||||||
isVisible = elem.is( ':visible' ),
|
|
||||||
|
// showing or hiding adds an extra "half" animation
|
||||||
|
anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
|
||||||
|
duration = o.duration / anims,
|
||||||
animateTo = 0,
|
animateTo = 0,
|
||||||
|
queue = elem.queue(),
|
||||||
|
queuelen = queue.length,
|
||||||
i;
|
i;
|
||||||
|
|
||||||
if ( !isVisible ) {
|
if ( show ) {
|
||||||
elem.css('opacity', 0).show();
|
elem.css( "opacity", 0 ).show();
|
||||||
animateTo = 1;
|
animateTo = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( mode == 'hide' && isVisible ) || ( mode == 'show' && !isVisible ) ) {
|
// anims - 1 opacity "toggles"
|
||||||
times--;
|
for ( i = 1; i < anims; i++ ) {
|
||||||
}
|
|
||||||
|
|
||||||
for ( i = 0; i < times; i++ ) {
|
|
||||||
elem.animate({
|
elem.animate({
|
||||||
opacity: animateTo
|
opacity: animateTo
|
||||||
}, duration, o.easing );
|
}, duration, o.easing );
|
||||||
animateTo = ( animateTo + 1 ) % 2;
|
animateTo = 1 - animateTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
elem.animate({
|
elem.animate({
|
||||||
opacity: animateTo
|
opacity: animateTo
|
||||||
}, duration, o.easing, function() {
|
}, duration, o.easing, function() {
|
||||||
if (animateTo == 0) {
|
if ( animateTo === 0 ) {
|
||||||
elem.hide();
|
elem.hide();
|
||||||
}
|
}
|
||||||
(o.complete && o.complete.apply(this, arguments));
|
if ( o.complete ) {
|
||||||
}).dequeue();
|
o.complete.apply( this );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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 ) ) );
|
||||||
|
}
|
||||||
|
next();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user