WordPress/wp-includes/js/jquery/ui/effect-fold.js
Clorith 7ea33988e9 External libraries: Update jQuery UI to 1.13.1
Some regressions happened alongside the release of jQuery UI 1.13.0, this brings the fixes from 1.13.1 downstream to WordPress, notably relating to Widget, Autocomplete, Sortable, and Tooltip modules.

See the changelog between version 1.13.0 and 1.13.1 at https://github.com/jquery/jquery-ui/compare/1.13.0...1.13.1

Props blogaid, linux4me2, mgol.
Fixes #54902.
Built from https://develop.svn.wordpress.org/trunk@52648


git-svn-id: http://core.svn.wordpress.org/trunk@52237 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-01-28 16:44:05 +00:00

92 lines
2.1 KiB
JavaScript

/*!
* jQuery UI Effects Fold 1.13.1
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*/
//>>label: Fold Effect
//>>group: Effects
//>>description: Folds an element first horizontally and then vertically.
//>>docs: http://api.jqueryui.com/fold-effect/
//>>demos: http://jqueryui.com/effect/
( function( factory ) {
"use strict";
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
define( [
"jquery",
"./effect"
], factory );
} else {
// Browser globals
factory( jQuery );
}
} )( function( $ ) {
"use strict";
return $.effects.define( "fold", "hide", function( options, done ) {
// Create element
var element = $( this ),
mode = options.mode,
show = mode === "show",
hide = mode === "hide",
size = options.size || 15,
percent = /([0-9]+)%/.exec( size ),
horizFirst = !!options.horizFirst,
ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
duration = options.duration / 2,
placeholder = $.effects.createPlaceholder( element ),
start = element.cssClip(),
animation1 = { clip: $.extend( {}, start ) },
animation2 = { clip: $.extend( {}, start ) },
distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
queuelen = element.queue().length;
if ( percent ) {
size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
}
animation1.clip[ ref[ 0 ] ] = size;
animation2.clip[ ref[ 0 ] ] = size;
animation2.clip[ ref[ 1 ] ] = 0;
if ( show ) {
element.cssClip( animation2.clip );
if ( placeholder ) {
placeholder.css( $.effects.clipToBox( animation2 ) );
}
animation2.clip = start;
}
// Animate
element
.queue( function( next ) {
if ( placeholder ) {
placeholder
.animate( $.effects.clipToBox( animation1 ), duration, options.easing )
.animate( $.effects.clipToBox( animation2 ), duration, options.easing );
}
next();
} )
.animate( animation1, duration, options.easing )
.animate( animation2, duration, options.easing )
.queue( done );
$.effects.unshift( element, queuelen, 4 );
} );
} );