diff options
author | Alexander Schmitz <arschmitz@gmail.com> | 2015-07-14 22:01:41 -0400 |
---|---|---|
committer | Alexander Schmitz <arschmitz@gmail.com> | 2015-08-08 00:29:38 -0400 |
commit | 59ea81003da93d74414989a6c49498183e501289 (patch) | |
tree | d31adff0bfafbde19994e55c634a53bbcf599dc2 /ui/effects/effect-fold.js | |
parent | 3b2db14b3beb1d5abbb2b9d102b1afa14733fef2 (diff) | |
download | jquery-ui-59ea81003da93d74414989a6c49498183e501289.tar.gz jquery-ui-59ea81003da93d74414989a6c49498183e501289.zip |
Effects: Move individual effects into effects folder
Ref #13885
Diffstat (limited to 'ui/effects/effect-fold.js')
-rw-r--r-- | ui/effects/effect-fold.js | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/ui/effects/effect-fold.js b/ui/effects/effect-fold.js new file mode 100644 index 000000000..2214a1cf3 --- /dev/null +++ b/ui/effects/effect-fold.js @@ -0,0 +1,89 @@ +/*! + * jQuery UI Effects Fold @VERSION + * 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 ) { + if ( typeof define === "function" && define.amd ) { + + // AMD. Register as an anonymous module. + define( [ + "jquery", + "../version", + "../effect" + ], factory ); + } else { + + // Browser globals + factory( jQuery ); + } +}( function( $ ) { + +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 ); +} ); + +} ) ); |