|
11 | 11 | * jquery.effects.core.js
|
12 | 12 | */
|
13 | 13 | (function( $, undefined ) {
|
| 14 | + |
| 15 | +var rvertical = /up|down|vertical/; |
| 16 | +var rpositivemotion = /up|left|vertical|horizontal/; |
14 | 17 |
|
15 | 18 | $.effects.effect.blind = function( o ) {
|
16 | 19 |
|
17 | 20 | return this.queue( function() {
|
18 | 21 |
|
19 | 22 | // Create element
|
20 | 23 | var el = $( this ),
|
21 |
| - props = [ 'position', 'top', 'bottom', 'left', 'right' ], |
22 |
| - mode = $.effects.setMode( el, o.mode || 'hide' ), |
23 |
| - direction = o.direction || 'vertical', |
24 |
| - ref = ( direction == 'vertical' ) ? 'height' : 'width', |
| 24 | + props = [ "position", "top", "bottom", "left", "right" ], |
| 25 | + mode = $.effects.setMode( el, o.mode || "hide" ), |
| 26 | + direction = o.direction || "up", |
| 27 | + vertical = rvertical.test( direction ), |
| 28 | + ref = vertical ? "height" : "width", |
| 29 | + ref2 = vertical ? "top" : "left", |
| 30 | + motion = rpositivemotion.test( direction ), |
25 | 31 | animation = {},
|
26 | 32 | wrapper, distance;
|
27 | 33 |
|
28 | 34 | $.effects.save( el, props );
|
29 | 35 | el.show();
|
30 | 36 | wrapper = $.effects.createWrapper( el ).css({
|
31 |
| - overflow: 'hidden' |
| 37 | + overflow: "hidden" |
32 | 38 | });
|
33 | 39 |
|
34 |
| - animation[ ref ] = ( mode == 'show' ? wrapper[ ref ]() : 0 ); |
| 40 | + distance = wrapper[ ref ](); |
| 41 | + |
| 42 | + animation[ ref ] = ( mode === "show" ? distance : 0 ); |
| 43 | + if ( !motion ) { |
| 44 | + el |
| 45 | + .css( vertical ? "bottom" : "right", 0 ) |
| 46 | + .css( vertical ? "top" : "left", "" ) |
| 47 | + .css({ position: "absolute" }); |
| 48 | + animation[ ref2 ] = ( mode === "show" ) ? 0 : distance; |
| 49 | + } |
35 | 50 |
|
36 | 51 | // start at 0 if we are showing
|
37 |
| - ( mode == 'show' && wrapper.css( ref, 0 ) ); |
| 52 | + if ( mode == "show" ) { |
| 53 | + wrapper.css( ref, 0 ); |
| 54 | + if ( ! motion ) { |
| 55 | + wrapper.css( ref2, distance ); |
| 56 | + } |
| 57 | + } |
38 | 58 |
|
39 | 59 | // Animate
|
40 |
| - wrapper.animate( animation, o.duration, o.easing, function() { |
41 |
| - ( mode == 'hide' && el.hide() ); |
42 |
| - $.effects.restore( el, props ); |
43 |
| - $.effects.removeWrapper( el ); |
44 |
| - $.isFunction( o.complete ) && o.complete.apply( el[ 0 ], arguments ); |
45 |
| - el.dequeue(); |
| 60 | + wrapper.animate( animation, { |
| 61 | + duration: o.duration, |
| 62 | + easing: o.easing, |
| 63 | + queue: false, |
| 64 | + complete: function() { |
| 65 | + if ( mode == "hide" ) { |
| 66 | + el.hide(); |
| 67 | + } |
| 68 | + $.effects.restore( el, props ); |
| 69 | + $.effects.removeWrapper( el ); |
| 70 | + if ( $.isFunction( o.complete ) ) { |
| 71 | + o.complete.apply( el[ 0 ], arguments ); |
| 72 | + } |
| 73 | + el.dequeue(); |
| 74 | + } |
46 | 75 | });
|
47 | 76 |
|
48 | 77 | });
|
|
0 commit comments