Skip to content

Commit 1f3f7bf

Browse files
gnarfscottgonzalez
authored andcommitted
Effects (blind): direction now accepts up/down/left/right as well as vertical(up) and horizontal(left) - Fixes #4480 - Invert the blind effect.
1 parent cbce358 commit 1f3f7bf

File tree

3 files changed

+62
-19
lines changed

3 files changed

+62
-19
lines changed

tests/visual/effects.all.html

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,26 @@
2626
<ul class="effects">
2727

2828
<li>
29-
<div class="effect" id="blindHorizontally">
30-
<p>Blind horizontally</p>
29+
<div class="effect" id="blindUp">
30+
<p>Blind up</p>
3131
</div>
3232
</li>
3333

3434
<li>
35-
<div class="effect" id="blindVertically">
36-
<p>Blind vertically</p>
35+
<div class="effect" id="blindDown">
36+
<p>Blind down</p>
37+
</div>
38+
</li>
39+
40+
<li>
41+
<div class="effect" id="blindLeft">
42+
<p>Blind left</p>
43+
</div>
44+
</li>
45+
46+
<li>
47+
<div class="effect" id="blindRight">
48+
<p>Blind right</p>
3749
</div>
3850
</li>
3951

tests/visual/effects.all.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ $(function() {
3333
})
3434
})
3535

36-
effect("#blindHorizontally", "blind", { direction: "horizontal" });
37-
effect("#blindVertically", "blind", { direction: "vertical" });
36+
effect("#blindLeft", "blind", { direction: "left" });
37+
effect("#blindUp", "blind", { direction: "up" });
38+
effect("#blindRight", "blind", { direction: "right" });
39+
effect("#blindDown", "blind", { direction: "down" });
3840

3941
effect("#bounce3times", "bounce", { times: 3 });
4042

ui/jquery.effects.blind.js

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,67 @@
1111
* jquery.effects.core.js
1212
*/
1313
(function( $, undefined ) {
14+
15+
var rvertical = /up|down|vertical/;
16+
var rpositivemotion = /up|left|vertical|horizontal/;
1417

1518
$.effects.effect.blind = function( o ) {
1619

1720
return this.queue( function() {
1821

1922
// Create element
2023
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 ),
2531
animation = {},
2632
wrapper, distance;
2733

2834
$.effects.save( el, props );
2935
el.show();
3036
wrapper = $.effects.createWrapper( el ).css({
31-
overflow: 'hidden'
37+
overflow: "hidden"
3238
});
3339

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+
}
3550

3651
// 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+
}
3858

3959
// 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+
}
4675
});
4776

4877
});

0 commit comments

Comments
 (0)