12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- ( function( factory ) {
- if ( typeof define === "function" && define.amd ) {
-
- define( [
- "jquery",
- "../version",
- "../effect"
- ], factory );
- } else {
-
- factory( jQuery );
- }
- }( function( $ ) {
- 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 = {};
- $.effects.createPlaceholder( element );
- startClip = element.cssClip();
- startRef = element.position()[ ref ];
-
- animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
- animation.clip = element.cssClip();
- animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
-
- if ( mode === "show" ) {
- element.cssClip( animation.clip );
- element.css( ref, animation[ ref ] );
- animation.clip = startClip;
- animation[ ref ] = startRef;
- }
-
- element.animate( animation, {
- queue: false,
- duration: options.duration,
- easing: options.easing,
- complete: done
- } );
- } );
- } ) );
|