2 * jQuery UI Effects Fold 1.12.1
5 * Copyright jQuery Foundation and other contributors
6 * Released under the MIT license.
7 * http://jquery.org/license
10 //>>label: Fold Effect
12 //>>description: Folds an element first horizontally and then vertically.
13 //>>docs: http://api.jqueryui.com/fold-effect/
14 //>>demos: http://jqueryui.com/effect/
16 ( function( factory ) {
17 if ( typeof define === "function" && define.amd ) {
19 // AMD. Register as an anonymous module.
32 return $.effects.define( "fold", "hide", function( options, done ) {
35 var element = $( this ),
37 show = mode === "show",
38 hide = mode === "hide",
39 size = options.size || 15,
40 percent = /([0-9]+)%/.exec( size ),
41 horizFirst = !!options.horizFirst,
42 ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
43 duration = options.duration / 2,
45 placeholder = $.effects.createPlaceholder( element ),
47 start = element.cssClip(),
48 animation1 = { clip: $.extend( {}, start ) },
49 animation2 = { clip: $.extend( {}, start ) },
51 distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
53 queuelen = element.queue().length;
56 size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
58 animation1.clip[ ref[ 0 ] ] = size;
59 animation2.clip[ ref[ 0 ] ] = size;
60 animation2.clip[ ref[ 1 ] ] = 0;
63 element.cssClip( animation2.clip );
65 placeholder.css( $.effects.clipToBox( animation2 ) );
68 animation2.clip = start;
73 .queue( function( next ) {
76 .animate( $.effects.clipToBox( animation1 ), duration, options.easing )
77 .animate( $.effects.clipToBox( animation2 ), duration, options.easing );
82 .animate( animation1, duration, options.easing )
83 .animate( animation2, duration, options.easing )
86 $.effects.unshift( element, queuelen, 4 );