diff options
author | gnarf <gnarf@gnarf.net> | 2011-05-03 09:16:30 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-05-03 09:16:30 -0400 |
commit | 1f3f7bf7872db0dcfbaea0276eea93225d2a8f58 (patch) | |
tree | 934e7c8e75a28293e9e9f7daa486612b1d72dc87 /ui/jquery.effects.blind.js | |
parent | cbce3585bcd3edb0202839d9533c43d3a6df1d7f (diff) | |
download | jquery-ui-1f3f7bf7872db0dcfbaea0276eea93225d2a8f58.tar.gz jquery-ui-1f3f7bf7872db0dcfbaea0276eea93225d2a8f58.zip |
Effects (blind): direction now accepts up/down/left/right as well as vertical(up) and horizontal(left) - Fixes #4480 - Invert the blind effect.
Diffstat (limited to 'ui/jquery.effects.blind.js')
-rw-r--r-- | ui/jquery.effects.blind.js | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/ui/jquery.effects.blind.js b/ui/jquery.effects.blind.js index 6b7250789..7a59d8a75 100644 --- a/ui/jquery.effects.blind.js +++ b/ui/jquery.effects.blind.js @@ -11,6 +11,9 @@ * jquery.effects.core.js */ (function( $, undefined ) { + +var rvertical = /up|down|vertical/; +var rpositivemotion = /up|left|vertical|horizontal/; $.effects.effect.blind = function( o ) { @@ -18,31 +21,57 @@ $.effects.effect.blind = function( o ) { // Create element var el = $( this ), - props = [ 'position', 'top', 'bottom', 'left', 'right' ], - mode = $.effects.setMode( el, o.mode || 'hide' ), - direction = o.direction || 'vertical', - ref = ( direction == 'vertical' ) ? 'height' : 'width', + props = [ "position", "top", "bottom", "left", "right" ], + mode = $.effects.setMode( el, o.mode || "hide" ), + direction = o.direction || "up", + vertical = rvertical.test( direction ), + ref = vertical ? "height" : "width", + ref2 = vertical ? "top" : "left", + motion = rpositivemotion.test( direction ), animation = {}, wrapper, distance; $.effects.save( el, props ); el.show(); wrapper = $.effects.createWrapper( el ).css({ - overflow: 'hidden' + overflow: "hidden" }); - animation[ ref ] = ( mode == 'show' ? wrapper[ ref ]() : 0 ); + distance = wrapper[ ref ](); + + animation[ ref ] = ( mode === "show" ? distance : 0 ); + if ( !motion ) { + el + .css( vertical ? "bottom" : "right", 0 ) + .css( vertical ? "top" : "left", "" ) + .css({ position: "absolute" }); + animation[ ref2 ] = ( mode === "show" ) ? 0 : distance; + } // start at 0 if we are showing - ( mode == 'show' && wrapper.css( ref, 0 ) ); + if ( mode == "show" ) { + wrapper.css( ref, 0 ); + if ( ! motion ) { + wrapper.css( ref2, distance ); + } + } // Animate - wrapper.animate( animation, o.duration, o.easing, function() { - ( mode == 'hide' && el.hide() ); - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - $.isFunction( o.complete ) && o.complete.apply( el[ 0 ], arguments ); - el.dequeue(); + wrapper.animate( animation, { + duration: o.duration, + easing: o.easing, + queue: false, + complete: function() { + if ( mode == "hide" ) { + el.hide(); + } + $.effects.restore( el, props ); + $.effects.removeWrapper( el ); + if ( $.isFunction( o.complete ) ) { + o.complete.apply( el[ 0 ], arguments ); + } + el.dequeue(); + } }); }); |