| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
( function( factory ) { |
| 17 |
"use strict"; |
| 18 |
|
| 19 |
if ( typeof define === "function" && define.amd ) { |
| 20 |
|
| 21 |
|
| 22 |
define( [ |
| 23 |
"jquery", |
| 24 |
"../version", |
| 25 |
"../effect" |
| 26 |
], factory ); |
| 27 |
} else { |
| 28 |
|
| 29 |
|
| 30 |
factory( jQuery ); |
| 31 |
} |
| 32 |
} )( function( $ ) { |
| 33 |
"use strict"; |
| 34 |
|
| 35 |
return $.effects.define( "fold", "hide", function( options, done ) { |
| 36 |
|
| 37 |
|
| 38 |
var element = $( this ), |
| 39 |
mode = options.mode, |
| 40 |
show = mode === "show", |
| 41 |
hide = mode === "hide", |
| 42 |
size = options.size || 15, |
| 43 |
percent = /([0-9]+)%/.exec( size ), |
| 44 |
horizFirst = !!options.horizFirst, |
| 45 |
ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ], |
| 46 |
duration = options.duration / 2, |
| 47 |
|
| 48 |
placeholder = $.effects.createPlaceholder( element ), |
| 49 |
|
| 50 |
start = element.cssClip(), |
| 51 |
animation1 = { clip: $.extend( {}, start ) }, |
| 52 |
animation2 = { clip: $.extend( {}, start ) }, |
| 53 |
|
| 54 |
distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ], |
| 55 |
|
| 56 |
queuelen = element.queue().length; |
| 57 |
|
| 58 |
if ( percent ) { |
| 59 |
size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ]; |
| 60 |
} |
| 61 |
animation1.clip[ ref[ 0 ] ] = size; |
| 62 |
animation2.clip[ ref[ 0 ] ] = size; |
| 63 |
animation2.clip[ ref[ 1 ] ] = 0; |
| 64 |
|
| 65 |
if ( show ) { |
| 66 |
element.cssClip( animation2.clip ); |
| 67 |
if ( placeholder ) { |
| 68 |
placeholder.css( $.effects.clipToBox( animation2 ) ); |
| 69 |
} |
| 70 |
|
| 71 |
animation2.clip = start; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
element |
| 76 |
.queue( function( next ) { |
| 77 |
if ( placeholder ) { |
| 78 |
placeholder |
| 79 |
.animate( $.effects.clipToBox( animation1 ), duration, options.easing ) |
| 80 |
.animate( $.effects.clipToBox( animation2 ), duration, options.easing ); |
| 81 |
} |
| 82 |
|
| 83 |
next(); |
| 84 |
} ) |
| 85 |
.animate( animation1, duration, options.easing ) |
| 86 |
.animate( animation2, duration, options.easing ) |
| 87 |
.queue( done ); |
| 88 |
|
| 89 |
$.effects.unshift( element, queuelen, 4 ); |
| 90 |
} ); |
| 91 |
|
| 92 |
} ); |