-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Effects Rewrite #1017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Effects Rewrite #1017
Changes from all commits
fea61ce
a2e69cd
73c00e5
1641329
277b6cc
2603495
03fa2cf
01f7f3c
9029963
d564590
1cae0d3
fb39056
2f25d1f
e02ec9d
cc786a8
dbb6540
85ce536
bf67149
cd3ec9f
e8a0d53
fd051a0
15f0cf7
b68b4b2
32167bd
b404525
8017d84
77783f0
86c375f
4c2ffd9
2d7eb90
64b8ab8
08544b4
f03b938
d1b4132
40e9a82
1cd8fb8
4855481
e9b02fe
2f39707
2a37345
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
(function($) { | ||
|
||
function present( value, array, message ) { | ||
QUnit.push( jQuery.inArray( value, array ) !== -1 , value, array, message ); | ||
QUnit.push( jQuery.inArray( value, array ) !== -1, value, array, message ); | ||
} | ||
|
||
function notPresent( value, array, message ) { | ||
QUnit.push( jQuery.inArray( value, array ) === -1 , value, array, message ); | ||
QUnit.push( jQuery.inArray( value, array ) === -1, value, array, message ); | ||
} | ||
|
||
// minDuration is used for "short" animate tests where we are only concerned about the final | ||
|
@@ -75,20 +75,6 @@ test( "removeClass", function() { | |
equal( "", element[ 0 ].className ); | ||
}); | ||
|
||
|
||
/* TODO: Disabled - Can't figure out why this is failing in IE 6/7 | ||
test( "createWrapper and removeWrapper retain focused elements (#7595)", function() { | ||
expect( 2 ); | ||
var test = $( "div.hidden" ).show(), | ||
input = $( "<input type='text'>" ).appendTo( test ).focus(); | ||
|
||
$.effects.createWrapper( test ); | ||
equal( document.activeElement, input[ 0 ], "Active element is still input after createWrapper" ); | ||
$.effects.removeWrapper( test ); | ||
equal( document.activeElement, input[ 0 ], "Active element is still input after removeWrapper" ); | ||
}); | ||
*/ | ||
|
||
module( "effects.core: animateClass" ); | ||
|
||
asyncTest( "animateClass works with borderStyle", function() { | ||
|
@@ -213,6 +199,44 @@ asyncTest( "animateClass: css and class changes during animation are not lost (# | |
.height( 100 ); | ||
}); | ||
|
||
test( "createPlaceholder: only created for static or relative elements", function() { | ||
expect( 4 ); | ||
|
||
ok( $.effects.createPlaceholder( $( ".relative" ) ).length, "placeholder created for relative element" ); | ||
ok( $.effects.createPlaceholder( $( ".static" ) ).length, "placeholder created for static element" ); | ||
ok( !$.effects.createPlaceholder( $( ".absolute" ) ), "placeholder not created for absolute element" ); | ||
ok( !$.effects.createPlaceholder( $( ".fixed" ) ), "placeholder not created for fixed element" ); | ||
}); | ||
|
||
test( "createPlaceholder: preserves layout affecting properties", function() { | ||
expect( 7 ); | ||
|
||
var position = 5, | ||
element = $( ".relative" ).css({ | ||
top: position, | ||
left: position | ||
}), | ||
before = { | ||
offset: element.offset(), | ||
outerWidth: element.outerWidth( true ), | ||
outerHeight: element.outerHeight( true ), | ||
"float": element.css( "float" ), | ||
position: element.position() | ||
}, | ||
placeholder = $.effects.createPlaceholder( element ); | ||
|
||
// Placeholders are only placed to preserve the effect on layout. Considering | ||
// top and left do not change layout, they are not preserved, which makes some | ||
// of the math simpler in the implementation. | ||
deepEqual( before.offset.top - position, placeholder.offset().top, "offset top preserved" ); | ||
deepEqual( before.offset.left - position, placeholder.offset().left, "offset left preserved" ); | ||
deepEqual( before.position.top - position, placeholder.position().top, "position top preserved" ); | ||
deepEqual( before.position.left - position, placeholder.position().left, "position left preserved" ); | ||
|
||
deepEqual( before[ "float" ], placeholder.css( "float" ), "float preserved" ); | ||
deepEqual( before.outerWidth, placeholder.outerWidth( true ), "width preserved" ); | ||
deepEqual( before.outerHeight, placeholder.outerHeight( true ), "height preserved" ); | ||
}); | ||
|
||
$.each( $.effects.effect, function( effect ) { | ||
module( "effects." + effect ); | ||
|
@@ -223,7 +247,7 @@ $.each( $.effects.effect, function( effect ) { | |
return; | ||
} | ||
asyncTest( "show/hide", function() { | ||
expect( 8 ); | ||
expect( 12 ); | ||
var hidden = $( "div.hidden" ), | ||
count = 0, | ||
test = 0; | ||
|
@@ -242,14 +266,40 @@ $.each( $.effects.effect, function( effect ) { | |
}; | ||
} | ||
|
||
hidden.queue( queueTest() ).show( effect, minDuration, queueTest(function() { | ||
equal( hidden.css("display"), "block", "Hidden is shown after .show(\"" +effect+ "\", time)" ); | ||
})).queue( queueTest() ).hide( effect, minDuration, queueTest(function() { | ||
equal( hidden.css("display"), "none", "Back to hidden after .hide(\"" +effect+ "\", time)" ); | ||
})).queue( queueTest(function() { | ||
deepEqual( hidden.queue(), ["inprogress"], "Only the inprogress sentinel remains"); | ||
start(); | ||
})); | ||
function duringTest( fn ) { | ||
return function( next ) { | ||
setTimeout( fn ); | ||
next(); | ||
}; | ||
} | ||
|
||
hidden | ||
.queue( queueTest() ) | ||
.queue( duringTest(function() { | ||
ok( hidden.is( ":animated" ), | ||
"Hidden is seen as animated during .show(\"" + effect + "\", time)" ); | ||
}) ) | ||
.show( effect, minDuration, queueTest(function() { | ||
equal( hidden.css( "display" ), "block", | ||
"Hidden is shown after .show(\"" + effect + "\", time)" ); | ||
ok( !$( ".ui-effects-placeholder" ).length, | ||
"No placeholder remains after .show(\"" + effect + "\", time)" ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're checking for this not existing after, shouldn't we test for it existing during? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it doesn't exist for all animations. The effects code itself always cleans up the placeholder, but the individual effects definitions determine whether or not they need to create one. |
||
}) ) | ||
.queue( queueTest() ) | ||
.queue( duringTest(function() { | ||
ok( hidden.is( ":animated" ), | ||
"Hidden is seen as animated during .hide(\"" + effect + "\", time)" ); | ||
}) ) | ||
.hide( effect, minDuration, queueTest(function() { | ||
equal( hidden.css( "display" ), "none", | ||
"Back to hidden after .hide(\"" + effect + "\", time)" ); | ||
ok( !$( ".ui-effects-placeholder" ).length, | ||
"No placeholder remains after .hide(\"" + effect + "\", time)" ); | ||
}) ) | ||
.queue( queueTest(function() { | ||
deepEqual( hidden.queue(), [ "inprogress" ], "Only the inprogress sentinel remains" ); | ||
start(); | ||
}) ); | ||
}); | ||
|
||
asyncTest( "relative width & height - properties are preserved", function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Determine if we can enable this now that we don't support IE 6/7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's testing a deprecated function anyway, but I'll see if I can enable it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked into enabling it, and it seemed like it passes, but I'm still removing the test because I'd have to remove it anyway in the future.