|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
( function( factory ) { |
|
"use strict"; |
|
|
|
if ( typeof define === "function" && define.amd ) { |
|
|
|
|
|
define( [ |
|
"jquery", |
|
"../version", |
|
"../effect" |
|
], factory ); |
|
} else { |
|
|
|
|
|
factory( jQuery ); |
|
} |
|
} )( function( $ ) { |
|
"use strict"; |
|
|
|
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 |
|
} ); |
|
} ); |
|
|
|
} ); |
|
|