aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2013-10-29 18:35:42 -0400
committerMike Sherov <mike.sherov@gmail.com>2013-12-03 10:08:12 -0500
commit44b2180782df6ef3324789324fcf3f98b85784a0 (patch)
treeb33d1da4ca66804d116f8a00be258f5b4c5df818 /tests
parent77bf202e58a2e6bd505a3013812e4dc217bf7c8a (diff)
downloadjquery-ui-44b2180782df6ef3324789324fcf3f98b85784a0.tar.gz
jquery-ui-44b2180782df6ef3324789324fcf3f98b85784a0.zip
Draggable: normalize lookups for rootNodes when to bust scroll cache. Fixes #9379 - Draggable: position bug in scrollable div
Core: update scrollParent() to support all current supported browsers.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/draggable/draggable.html8
-rw-r--r--tests/unit/draggable/draggable_core.js37
-rw-r--r--tests/unit/draggable/draggable_options.js8
3 files changed, 49 insertions, 4 deletions
diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html
index dd284f280..42467d2d4 100644
--- a/tests/unit/draggable/draggable.html
+++ b/tests/unit/draggable/draggable.html
@@ -19,6 +19,9 @@
top: 0;
}
#main-forceScrollable {
+ position: absolute;
+ left: 0;
+ top: 0;
width: 1100px;
height: 1100px;
}
@@ -33,6 +36,9 @@
overflow-y: hidden;
}
#scrollParent-forceScrollable {
+ position: absolute;
+ left: 0;
+ top: 0;
width: 1300px;
height: 1300px;
}
@@ -78,7 +84,7 @@
<div id="qunit-fixture">
<div id="scrollParent">
<div id="main">
- <div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div>
+ <div id="draggable1" style="background: green; width: 200px; height: 100px; position: relative; top: 0; left: 0;">Relative</div>
<div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span><em>Absolute</em></span></div>
<div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div>
<div id="main-forceScrollable"></div>
diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js
index 1fefb8500..b8ea19930 100644
--- a/tests/unit/draggable/draggable_core.js
+++ b/tests/unit/draggable/draggable_core.js
@@ -136,7 +136,7 @@ test( "#6258: not following mouse when scrolled and using overflow-y: scroll", f
});
});
-test( "#9315: Draggable: jumps down with offset of scrollbar", function() {
+test( "#9315: jumps down with offset of scrollbar", function() {
expect( 2 );
var element = $( "#draggable2" ).draggable({
@@ -186,6 +186,41 @@ test( "#5009: scroll not working with parent's position fixed", function() {
});
});
+test( "#9379: Draggable: position bug in scrollable div", function() {
+ expect( 2 );
+
+ $( "#qunit-fixture" ).html( "<div id='o_9379'><div id='i_9379'></div><div id='d_9379'>a</div></div>" );
+ $( "#i_9379" ).css({ position: "absolute", width: "500px", height: "500px" });
+ $( "#o_9379" ).css({ position: "absolute", width: "300px", height: "300px" });
+ $( "#d_9379" ).css({ width: "10px", height: "10px" });
+
+ var moves = 3,
+ startValue = 0,
+ dragDelta = 20,
+ delta = 100,
+
+ // we scroll after each drag event, so subtract 1 from number of moves for expected
+ expected = delta + ( ( moves - 1 ) * dragDelta ),
+ element = $( "#d_9379" ).draggable({
+ drag: function() {
+ startValue += dragDelta;
+ $( "#o_9379" ).scrollTop( startValue ).scrollLeft( startValue );
+ },
+ stop: function( event, ui ) {
+ equal( ui.position.left, expected, "left position is correct when grandparent is scrolled" );
+ equal( ui.position.top, expected, "top position is correct when grandparent is scrolled" );
+ }
+ });
+
+ $( "#o_9379" ).css( "overflow", "auto" );
+
+ element.simulate( "drag", {
+ dy: delta,
+ dx: delta,
+ moves: moves
+ });
+});
+
test( "#5727: draggable from iframe" , function() {
expect( 1 );
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js
index ea52eb299..11a3c6840 100644
--- a/tests/unit/draggable/draggable_options.js
+++ b/tests/unit/draggable/draggable_options.js
@@ -377,7 +377,7 @@ test( "containment, account for border", function() {
test( "containment, default, switching after initialization", function() {
expect( 6 );
- var element = $( "#draggable1" ).draggable({ containment: false });
+ var element = $( "#draggable1" ).draggable({ containment: false, scroll: false });
TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100, "containment: default" );
@@ -692,7 +692,7 @@ test( "helper, default, switching after initialization", function() {
scroll: false
});
- if ( scrollElements.length === 1 && scrollElements[ 1 ] === "#scrollParent" ) {
+ if ( scrollElements.length === 1 && scrollElements[ 0 ] === "#scrollParent" ) {
TestHelpers.draggable.setScrollable( "#main", false );
TestHelpers.draggable.setScrollable( "#scrollParent", true );
}
@@ -867,6 +867,8 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() {
test( "#6817: auto scroll goes double distance when dragging", function() {
expect( 2 );
+ TestHelpers.draggable.restoreScroll( document );
+
var offsetBefore,
distance = 10,
viewportHeight = $( window ).height(),
@@ -906,6 +908,7 @@ test( "snap, snapMode, and snapTolerance", function() {
snapTolerance = 15,
element = $( "#draggable1" ).draggable({
snap: true,
+ scroll: false,
snapMode: "both",
snapTolerance: snapTolerance
}),
@@ -1028,6 +1031,7 @@ test( "#8459: element can snap to an element that was removed during drag", func
snapTolerance = 15,
element = $( "#draggable1" ).draggable({
snap: true,
+ scroll: false,
snapMode: "both",
snapTolerance: snapTolerance,
start: function() {