aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/position
diff options
context:
space:
mode:
authorJean-Francois Remy <jfremy@virtuoz.com>2011-05-03 04:38:17 -0400
committerScott González <scott.gonzalez@gmail.com>2011-05-03 04:38:17 -0400
commit5e44b3ce8851f62a38ce9211c6721e1050e2dabf (patch)
tree8e87f743e6a498e0fc50a8c396a504f409eb7efe /tests/unit/position
parent51df02ee4ea02e91919842a169463612176682d5 (diff)
downloadjquery-ui-5e44b3ce8851f62a38ce9211c6721e1050e2dabf.tar.gz
jquery-ui-5e44b3ce8851f62a38ce9211c6721e1050e2dabf.zip
Position: Handled scrolled windows properly with collision: fit. Fixes #7211 - Position: Collision: fit doesn't work at top of window when scrolled.
Diffstat (limited to 'tests/unit/position')
-rw-r--r--tests/unit/position/position_core.js27
1 files changed, 22 insertions, 5 deletions
diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js
index 5a47fe6bb..dbbda8a3b 100644
--- a/tests/unit/position/position_core.js
+++ b/tests/unit/position/position_core.js
@@ -1,5 +1,10 @@
(function( $ ) {
+function scrollTopSupport() {
+ $( window ).scrollTop( 1 );
+ return $( window ).scrollTop() === 1;
+}
+
module( "position" );
test( "my, at, of", function() {
@@ -161,11 +166,7 @@ test( "of", function() {
left: $( window ).width() - 10
}, "window as jQuery object" );
- var scrollTopSupport = (function() {
- $( window ).scrollTop( 1 );
- return $( window ).scrollTop() === 1;
- }() );
- if ( scrollTopSupport ) {
+ if ( scrollTopSupport() ) {
$( window ).scrollTop( 500 ).scrollLeft( 200 );
$( "#elx" ).position({
my: "right bottom",
@@ -311,6 +312,22 @@ test( "collision: fit, with offset", function() {
}, { top: 0, left: 0 }, "left top, negative offset" );
});
+test( "collision: fit, window scrolled", function() {
+ if ( scrollTopSupport() ) {
+ var win = $( window );
+ win.scrollTop( 300 ).scrollLeft( 200 );
+ collisionTest({
+ collision: "fit",
+ at: "left-100 top-100"
+ }, { top: 300, left: 200 }, "top left" );
+ collisionTest2({
+ collision: "fit",
+ at: "right+100 bottom+100"
+ }, { top: 300 + win.height() - 10, left: 200 + win.width() - 10 }, "right bottom" );
+ win.scrollTop( 0 ).scrollLeft( 0 );
+ }
+});
+
test( "collision: flip, no offset", function() {
collisionTest({
collision: "flip"