|
12 | 12 | */
|
13 | 13 | (function( $, undefined ) {
|
14 | 14 |
|
15 |
| -$.effects.fold = function(o) { |
| 15 | +$.effects.fold = function( o ) { |
16 | 16 |
|
17 |
| - return this.queue(function() { |
| 17 | + return this.queue( function() { |
18 | 18 |
|
19 | 19 | // Create element
|
20 |
| - var el = $(this), props = ['position','top','bottom','left','right']; |
21 |
| - |
22 |
| - // Set options |
23 |
| - var mode = $.effects.setMode(el, o.mode || 'hide'); // Set Mode |
24 |
| - var size = o.size || 15; // Default fold size |
25 |
| - var horizFirst = !(!o.horizFirst); // Ensure a boolean value |
26 |
| - var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2; |
27 |
| - |
28 |
| - // Adjust |
29 |
| - $.effects.save(el, props); el.show(); // Save & Show |
30 |
| - var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper |
31 |
| - var widthFirst = ((mode == 'show') != horizFirst); |
32 |
| - var ref = widthFirst ? ['width', 'height'] : ['height', 'width']; |
33 |
| - var distance = widthFirst ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()]; |
34 |
| - var percent = /([0-9]+)%/.exec(size); |
35 |
| - if(percent) size = parseInt(percent[1],10) / 100 * distance[mode == 'hide' ? 0 : 1]; |
36 |
| - if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift |
| 20 | + var el = $( this ), |
| 21 | + props = ['position','top','bottom','left','right'], |
| 22 | + mode = $.effects.setMode(el, o.mode || 'hide'), |
| 23 | + size = o.size || 15, |
| 24 | + percent = /([0-9]+)%/.exec(size), |
| 25 | + horizFirst = !!o.horizFirst, |
| 26 | + widthFirst = ((mode == 'show') != horizFirst), |
| 27 | + ref = widthFirst ? ['width', 'height'] : ['height', 'width'], |
| 28 | + duration = o.duration / 2, |
| 29 | + wrapper, distance; |
| 30 | + |
| 31 | + $.effects.save( el, props ); |
| 32 | + el.show(); |
| 33 | + |
| 34 | + // Create Wrapper |
| 35 | + wrapper = $.effects.createWrapper( el ).css({ |
| 36 | + overflow: 'hidden' |
| 37 | + }); |
| 38 | + distance = widthFirst ? |
| 39 | + [ wrapper.width(), wrapper.height() ] : |
| 40 | + [ wrapper.height(), wrapper.width() ]; |
| 41 | + |
| 42 | + if ( percent ) { |
| 43 | + size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ ( mode == 'hide') ? 0 : 1 ]; |
| 44 | + } |
| 45 | + mode == 'show' && wrapper.css( horizFirst ? { |
| 46 | + height: 0, |
| 47 | + width: size |
| 48 | + } : { |
| 49 | + height: size, |
| 50 | + width: 0 |
| 51 | + }); |
37 | 52 |
|
38 | 53 | // Animation
|
39 | 54 | var animation1 = {}, animation2 = {};
|
40 |
| - animation1[ref[0]] = mode == 'show' ? distance[0] : size; |
41 |
| - animation2[ref[1]] = mode == 'show' ? distance[1] : 0; |
| 55 | + animation1[ ref[ 0 ] ] = mode == 'show' ? distance[ 0 ] : size; |
| 56 | + animation2[ ref[ 1 ] ] = mode == 'show' ? distance[ 1 ] : 0; |
42 | 57 |
|
43 | 58 | // Animate
|
44 |
| - wrapper.animate(animation1, duration, o.easing) |
45 |
| - .animate(animation2, duration, o.easing, function() { |
46 |
| - if(mode == 'hide') el.hide(); // Hide |
47 |
| - $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
48 |
| - if(o.complete) o.complete.apply(el[0], arguments); // Callback |
49 |
| - el.dequeue(); |
50 |
| - }); |
| 59 | + wrapper |
| 60 | + .animate( animation1, duration, o.easing ) |
| 61 | + .animate( animation2, duration, o.easing, function() { |
| 62 | + (mode == 'hide') && el.hide(); |
| 63 | + $.effects.restore( el, props ); |
| 64 | + $.effects.removeWrapper( el ); |
| 65 | + jQuery.isFunction(o.complete) && o.complete.apply( el[ 0 ], arguments ); |
| 66 | + el.dequeue(); |
| 67 | + }); |
51 | 68 |
|
52 | 69 | });
|
53 | 70 |
|
|
0 commit comments