aboutsummaryrefslogtreecommitdiffstats
path: root/ui/effect-drop.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/effect-drop.js')
-rw-r--r--ui/effect-drop.js57
1 files changed, 22 insertions, 35 deletions
diff --git a/ui/effect-drop.js b/ui/effect-drop.js
index 0b3f85557..a990c48e7 100644
--- a/ui/effect-drop.js
+++ b/ui/effect-drop.js
@@ -28,53 +28,40 @@
}
}(function( $ ) {
-return $.effects.effect.drop = function( o, done ) {
+return $.effects.define( "drop", "hide", function( options, done ) {
- var el = $( this ),
- props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
- mode = $.effects.setMode( el, o.mode || "hide" ),
+ var distance,
+ element = $( this ),
+ mode = options.mode,
show = mode === "show",
- direction = o.direction || "left",
+ direction = options.direction || "left",
ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
- motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
+ motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
+ oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
animation = {
- opacity: show ? 1 : 0
- },
- distance;
+ opacity: 0
+ };
- // Adjust
- $.effects.save( el, props );
- el.show();
- $.effects.createWrapper( el );
+ $.effects.createPlaceholder( element );
- distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
+ distance = options.distance || element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
+
+ animation[ ref ] = motion + distance;
if ( show ) {
- el
- .css( "opacity", 0 )
- .css( ref, motion === "pos" ? -distance : distance );
- }
+ element.css( animation );
- // Animation
- animation[ ref ] = ( show ?
- ( motion === "pos" ? "+=" : "-=" ) :
- ( motion === "pos" ? "-=" : "+=" ) ) +
- distance;
+ animation[ ref ] = oppositeMotion + distance;
+ animation.opacity = 1;
+ }
// Animate
- el.animate( animation, {
+ element.animate( animation, {
queue: false,
- duration: o.duration,
- easing: o.easing,
- complete: function() {
- if ( mode === "hide" ) {
- el.hide();
- }
- $.effects.restore( el, props );
- $.effects.removeWrapper( el );
- done();
- }
+ duration: options.duration,
+ easing: options.easing,
+ complete: done
});
-};
+});
}));