2012-02-27 00:49:51 +00:00
|
|
|
/*!
|
2008-09-04 22:03:30 +00:00
|
|
|
* jQuery UI Effects Slide @VERSION
|
2012-07-04 13:08:08 +00:00
|
|
|
* http://jqueryui.com
|
2008-06-06 20:08:52 +00:00
|
|
|
*
|
2014-12-21 18:27:43 +00:00
|
|
|
* Copyright jQuery Foundation and other contributors
|
2012-08-09 14:13:24 +00:00
|
|
|
* Released under the MIT license.
|
2010-07-09 13:01:04 +00:00
|
|
|
* http://jquery.org/license
|
2008-06-06 20:08:52 +00:00
|
|
|
*/
|
2014-10-30 19:55:08 +00:00
|
|
|
|
|
|
|
//>>label: Slide Effect
|
|
|
|
//>>group: Effects
|
|
|
|
//>>description: Slides an element in and out of the viewport.
|
|
|
|
//>>docs: http://api.jqueryui.com/slide-effect/
|
|
|
|
//>>demos: http://jqueryui.com/effect/
|
|
|
|
|
2013-07-12 16:40:48 +00:00
|
|
|
(function( factory ) {
|
|
|
|
if ( typeof define === "function" && define.amd ) {
|
2008-06-04 02:34:33 +00:00
|
|
|
|
2013-07-12 16:40:48 +00:00
|
|
|
// AMD. Register as an anonymous module.
|
|
|
|
define([
|
|
|
|
"jquery",
|
2013-12-02 18:36:12 +00:00
|
|
|
"./effect"
|
2013-07-12 16:40:48 +00:00
|
|
|
], factory );
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Browser globals
|
|
|
|
factory( jQuery );
|
|
|
|
}
|
|
|
|
}(function( $ ) {
|
|
|
|
|
2012-12-26 13:35:42 +00:00
|
|
|
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 ),
|
2012-04-28 21:36:38 +00:00
|
|
|
animation = {};
|
2008-06-06 19:47:31 +00:00
|
|
|
|
2012-12-26 13:35:42 +00:00
|
|
|
$.effects.createPlaceholder( element );
|
2012-04-19 01:57:51 +00:00
|
|
|
|
2012-12-26 13:35:42 +00:00
|
|
|
startClip = element.cssClip();
|
|
|
|
startRef = element.position()[ ref ];
|
2012-04-19 01:57:51 +00:00
|
|
|
|
2012-12-26 13:35:42 +00:00
|
|
|
// Define hide animation
|
|
|
|
animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
|
|
|
|
animation.clip = element.cssClip();
|
|
|
|
animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2012-12-26 13:35:42 +00:00
|
|
|
// 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;
|
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2012-12-26 13:35:42 +00:00
|
|
|
// Actually animate
|
|
|
|
element.animate( animation, {
|
2012-04-19 01:57:51 +00:00
|
|
|
queue: false,
|
2012-12-26 13:35:42 +00:00
|
|
|
duration: options.duration,
|
|
|
|
easing: options.easing,
|
|
|
|
complete: done
|
2008-06-06 19:47:31 +00:00
|
|
|
});
|
2012-12-26 13:35:42 +00:00
|
|
|
});
|
2008-06-06 19:47:31 +00:00
|
|
|
|
2013-07-12 16:40:48 +00:00
|
|
|
}));
|