jquery-ui/ui/effects/effect-blind.js

74 lines
1.6 KiB
JavaScript
Raw Normal View History

/*!
* jQuery UI Effects Blind @VERSION
* https://jqueryui.com
*
* Copyright OpenJS Foundation and other contributors
2012-08-09 14:13:24 +00:00
* Released under the MIT license.
* https://jquery.org/license
*/
//>>label: Blind Effect
//>>group: Effects
//>>description: Blinds the element.
//>>docs: https://api.jqueryui.com/blind-effect/
//>>demos: https://jqueryui.com/effect/
( function( factory ) {
"use strict";
if ( typeof define === "function" && define.amd ) {
2011-06-21 06:15:42 +00:00
// AMD. Register as an anonymous module.
define( [
"jquery",
"../version",
"../effect"
], factory );
} else {
// Browser globals
factory( jQuery );
}
} )( function( $ ) {
"use strict";
return $.effects.define( "blind", "hide", function( options, done ) {
var map = {
up: [ "bottom", "top" ],
vertical: [ "bottom", "top" ],
down: [ "top", "bottom" ],
left: [ "right", "left" ],
horizontal: [ "right", "left" ],
right: [ "left", "right" ]
},
element = $( this ),
direction = options.direction || "up",
start = element.cssClip(),
animate = { clip: $.extend( {}, start ) },
placeholder = $.effects.createPlaceholder( element );
2011-03-07 00:48:14 +00:00
animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
2011-03-07 00:48:14 +00:00
if ( options.mode === "show" ) {
element.cssClip( animate.clip );
if ( placeholder ) {
placeholder.css( $.effects.clipToBox( animate ) );
}
animate.clip = start;
}
if ( placeholder ) {
placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
}
element.animate( animate, {
queue: false,
duration: options.duration,
easing: options.easing,
complete: done
} );
} );
} );