(function( $, undefined ) {
$.effects.effect.bounce = function( o, done ) {
- var el = $( this ),
+ var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
// defaults:
mode = $.effects.setMode( el, o.mode || "effect" ),
hide = mode === "hide",
show = mode === "show",
- direction = o.direction || "up",
+ direction = o.direction || "up",
distance = o.distance,
times = o.times || 5,
// utility:
ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
- motion = ( direction === "up" || direction === "left" ),
+ motion = ( direction === "up" || direction === "left" ),
i,
upAnim,
downAnim,
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 ( show || hide ) {
props.push( "opacity" );
- }
+ }
- $.effects.save( el, props );
- el.show();
+ $.effects.save( el, props );
+ el.show();
$.effects.createWrapper( el ); // Create Wrapper
// default distance for the BIGGEST bounce is the outer Distance / 3
el.animate( upAnim, speed, easing );
}
-
+
el.queue(function() {
if ( hide ) {
el.hide();
$.effects.effect.drop = function( o, done ) {
- var el = $( this ),
+ var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
mode = $.effects.setMode( el, o.mode || "hide" ),
show = mode === "show",
distance;
// Adjust
- $.effects.save( el, props );
- el.show();
- $.effects.createWrapper( el );
+ $.effects.save( el, props );
+ el.show();
+ $.effects.createWrapper( el );
distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]({ margin: true }) / 2;
}
// Animation
- animation[ ref ] = ( show ?
- ( motion === "pos" ? "+=" : "-=" ) :
+ animation[ ref ] = ( show ?
+ ( motion === "pos" ? "+=" : "-=" ) :
( motion === "pos" ? "-=" : "+=" ) ) +
distance;
// Animate
- el.animate( animation, {
- queue: false,
- duration: o.duration,
- easing: o.easing,
+ el.animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
complete: function() {
if ( mode === "hide" ) {
el.hide();
}
- $.effects.restore( el, props );
- $.effects.removeWrapper( el );
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
done();
}
});
hide = mode === "hide",
percent = parseInt( o.percent, 10 ) || 150,
factor = percent / 100,
- original = {
- height: elem.height(),
- width: elem.width()
+ original = {
+ height: elem.height(),
+ width: elem.width()
};
$.extend( o, {
( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
direction = o.direction || "both",
origin = o.origin,
- original = {
- height: el.height(),
+ original = {
+ height: el.height(),
width: el.width(),
outerHeight: el.outerHeight(),
outerWidth: el.outerWidth()
factor = {
y: direction !== "horizontal" ? (percent / 100) : 1,
x: direction !== "vertical" ? (percent / 100) : 1
- };
+ };
// We are going to pass this effect to the size effect:
options.effect = "size";
options.complete = done;
// Set default origin and restore for show/hide
- if ( mode !== "effect" ) {
+ if ( mode !== "effect" ) {
options.origin = origin || ["middle","center"];
options.restore = true;
}
- options.from = o.from || ( mode === "show" ? { height: 0, width: 0 } : original );
+ options.from = o.from || ( mode === "show" ? { height: 0, width: 0 } : original );
options.to = {
- height: original.height * factor.y,
+ height: original.height * factor.y,
width: original.width * factor.x,
- outerHeight: original.outerHeight * factor.y,
+ outerHeight: original.outerHeight * factor.y,
outerWidth: original.outerWidth * factor.x
- };
+ };
// Fade option to support puff
if ( options.fade ) {
if ( mode === "show" ) {
- options.from.opacity = 0;
+ options.from.opacity = 0;
options.to.opacity = 1;
}
if ( mode === "hide" ) {
- options.from.opacity = 1;
+ options.from.opacity = 1;
options.to.opacity = 0;
}
}
$.effects.effect.size = function( o, done ) {
// Create element
- var el = $( this ),
+ var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
// Always restore
el.show();
}
original = {
- height: el.height(),
+ height: el.height(),
width: el.width(),
outerHeight: el.outerHeight(),
outerWidth: el.outerWidth()
// Set scaling factor
factor = {
from: {
- y: el.from.height / original.height,
+ y: el.from.height / original.height,
x: el.from.width / original.width
},
to: {
- y: el.to.height / original.height,
+ y: el.to.height / original.height,
x: el.to.width / original.width
}
};
if ( scale === "box" || scale === "both" ) {
// Vertical props scaling
- if ( factor.from.y !== factor.to.y ) {
+ if ( factor.from.y !== factor.to.y ) {
props = props.concat( vProps );
el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
}
// Horizontal props scaling
- if ( factor.from.x !== factor.to.x ) {
+ if ( factor.from.x !== factor.to.x ) {
props = props.concat( hProps );
el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
}
// Scale the content
- if ( scale === "content" || scale === "both" ) {
+ if ( scale === "content" || scale === "both" ) {
// Vertical props scaling
- if ( factor.from.y !== factor.to.y ) {
+ if ( factor.from.y !== factor.to.y ) {
props = props.concat( cProps );
el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
}
}
- $.effects.save( el, restore ? props : props1 );
- el.show();
+ $.effects.save( el, restore ? props : props1 );
+ el.show();
$.effects.createWrapper( el );
- el.css( "overflow", "hidden" ).css( el.from );
+ el.css( "overflow", "hidden" ).css( el.from );
// Adjust
if (origin) { // Calculate baseline shifts
el.find( "*[width]" ).each( function(){
var child = $( this ),
- c_original = {
- height: child.height(),
+ c_original = {
+ height: child.height(),
width: child.width()
};
if (restore) {
}
child.from = {
- height: c_original.height * factor.from.y,
+ height: c_original.height * factor.from.y,
width: c_original.width * factor.from.x
};
child.to = {
- height: c_original.height * factor.to.y,
+ height: c_original.height * factor.to.y,
width: c_original.width * factor.to.x
};
// Vertical props scaling
- if ( factor.from.y !== factor.to.y ) {
+ if ( factor.from.y !== factor.to.y ) {
child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
}
}
// Animate
- el.animate( el.to, {
- queue: false,
- duration: o.duration,
- easing: o.easing,
+ el.animate( el.to, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
complete: function() {
if ( el.to.opacity === 0 ) {
el.css( "opacity", el.from.opacity );
return toRef + "px";
}
- return val + toRef + "px";
+ return val + toRef + "px";
});
});
}