| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
( function( factory ) { |
| 17 |
"use strict"; |
| 18 |
|
| 19 |
if ( typeof define === "function" && define.amd ) { |
| 20 |
|
| 21 |
|
| 22 |
define( [ |
| 23 |
"jquery", |
| 24 |
"../version", |
| 25 |
"../effect" |
| 26 |
], factory ); |
| 27 |
} else { |
| 28 |
|
| 29 |
|
| 30 |
factory( jQuery ); |
| 31 |
} |
| 32 |
} )( function( $ ) { |
| 33 |
"use strict"; |
| 34 |
|
| 35 |
return $.effects.define( "slide", "show", function( options, done ) { |
| 36 |
var startClip, startRef, |
| 37 |
element = $( this ), |
| 38 |
map = { |
| 39 |
up: [ "bottom", "top" ], |
| 40 |
down: [ "top", "bottom" ], |
| 41 |
left: [ "right", "left" ], |
| 42 |
right: [ "left", "right" ] |
| 43 |
}, |
| 44 |
mode = options.mode, |
| 45 |
direction = options.direction || "left", |
| 46 |
ref = ( direction === "up" || direction === "down" ) ? "top" : "left", |
| 47 |
positiveMotion = ( direction === "up" || direction === "left" ), |
| 48 |
distance = options.distance || |
| 49 |
element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ), |
| 50 |
animation = {}; |
| 51 |
|
| 52 |
$.effects.createPlaceholder( element ); |
| 53 |
|
| 54 |
startClip = element.cssClip(); |
| 55 |
startRef = element.position()[ ref ]; |
| 56 |
|
| 57 |
|
| 58 |
animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef; |
| 59 |
animation.clip = element.cssClip(); |
| 60 |
animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ]; |
| 61 |
|
| 62 |
|
| 63 |
if ( mode === "show" ) { |
| 64 |
element.cssClip( animation.clip ); |
| 65 |
element.css( ref, animation[ ref ] ); |
| 66 |
animation.clip = startClip; |
| 67 |
animation[ ref ] = startRef; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
element.animate( animation, { |
| 72 |
queue: false, |
| 73 |
duration: options.duration, |
| 74 |
easing: options.easing, |
| 75 |
complete: done |
| 76 |
} ); |
| 77 |
} ); |
| 78 |
|
| 79 |
} ); |