aboutsummaryrefslogtreecommitdiffstats
path: root/ui/effect-slide.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/effect-slide.js')
-rw-r--r--ui/effect-slide.js73
1 files changed, 34 insertions, 39 deletions
diff --git a/ui/effect-slide.js b/ui/effect-slide.js
index ec1fec629..03086a928 100644
--- a/ui/effect-slide.js
+++ b/ui/effect-slide.js
@@ -28,52 +28,47 @@
}
}(function( $ ) {
-return $.effects.effect.slide = function( o, done ) {
-
- // Create element
- var el = $( this ),
- props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
- mode = $.effects.setMode( el, o.mode || "show" ),
- show = mode === "show",
- direction = o.direction || "left",
- ref = (direction === "up" || direction === "down") ? "top" : "left",
- positiveMotion = (direction === "up" || direction === "left"),
- distance,
+return $.effects.define( "slide", "show", function( options, done ) {
+ var startClip, startRef,
+ element = $( this ),
+ map = {
+ up: [ "bottom", "top" ],
+ down: [ "top", "bottom" ],
+ left: [ "right", "left" ],
+ right: [ "left", "right" ]
+ },
+ mode = options.mode,
+ direction = options.direction || "left",
+ ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
+ positiveMotion = ( direction === "up" || direction === "left" ),
+ distance = options.distance || element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ),
animation = {};
- // Adjust
- $.effects.save( el, props );
- el.show();
- distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
+ $.effects.createPlaceholder( element );
- $.effects.createWrapper( el ).css({
- overflow: "hidden"
- });
+ startClip = element.cssClip();
+ startRef = element.position()[ ref ];
- if ( show ) {
- el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
- }
+ // Define hide animation
+ animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
+ animation.clip = element.cssClip();
+ animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
- // Animation
- animation[ ref ] = ( show ?
- ( positiveMotion ? "+=" : "-=") :
- ( positiveMotion ? "-=" : "+=")) +
- distance;
+ // Reverse the animation if we're showing
+ if ( mode === "show" ) {
+ element.cssClip( animation.clip );
+ element.css( ref, animation[ ref ] );
+ animation.clip = startClip;
+ animation[ ref ] = startRef;
+ }
- // Animate
- el.animate( animation, {
+ // Actually animate
+ 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
});
-};
+});
}));