aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/draggable.js241
-rw-r--r--tests/droppable.html8
-rw-r--r--ui/ui.draggable.js4
3 files changed, 196 insertions, 57 deletions
diff --git a/tests/draggable.js b/tests/draggable.js
index 31a820613..4c62d45a2 100644
--- a/tests/draggable.js
+++ b/tests/draggable.js
@@ -476,85 +476,196 @@ test("callbacks occurance count", function() {
module("draggable: Scroll offsets");
+
+function testScroll(position) {
+ $("#main").css('position', position);
+ drag(el, 50, 50);
+ moved(50, 50, position+' parent');
+
+}
+
+function setScroll(what) {
+ if(what) {
+ $(document).scrollTop(100); $(document).scrollLeft(100);
+ } else {
+ $("#main")[0].scrollTop = 100; $("#main")[0].scrollLeft = 100;
+ }
+}
+
+function restoreScroll(what) {
+ if(what) {
+ $(document).scrollTop(0); $(document).scrollLeft(0);
+ } else {
+ $("#main")[0].scrollTop = 0; $("#main")[0].scrollLeft = 0;
+ }
+}
+
test("{ helper: 'original' }, relative, with scroll offset on parent", function() {
+
el = $("#draggable1").draggable({ helper: "original" });
- $("#main")[0].scrollTop = 100;
- drag(el, 50, 50);
- moved(50, 50);
- $("#main")[0].scrollTop = 0;
+
+ setScroll();
+ testScroll('relative');
+
+ setScroll();
+ testScroll('static');
+
+ setScroll();
+ testScroll('absolute');
+
+ restoreScroll();
+
});
test("{ helper: 'original' }, relative, with scroll offset on root", function() {
+
el = $("#draggable1").draggable({ helper: "original" });
- $(document).scrollTop(100);
- drag(el, 50, 50);
- moved(50, 50);
- $(document).scrollTop(0);
+
+ setScroll('root');
+ testScroll('relative');
+
+ setScroll('root');
+ testScroll('static');
+
+ setScroll('root');
+ testScroll('absolute');
+
+ restoreScroll('root');
+
});
test("{ helper: 'original' }, relative, with scroll offset on root and parent", function() {
+
el = $("#draggable1").draggable({ helper: "original" });
- $(document).scrollTop(100);
- $("#main")[0].scrollTop = 100;
- drag(el, 50, 50);
- moved(50, 50);
- $(document).scrollTop(0);
- $("#main")[0].scrollTop = 0;
+
+ setScroll();
+ setScroll('root');
+ testScroll('relative');
+
+ setScroll();
+ setScroll('root');
+ testScroll('static');
+
+ setScroll();
+ setScroll('root');
+ testScroll('absolute');
+
+ restoreScroll();
+ restoreScroll('root');
+
});
test("{ helper: 'original' }, absolute, with scroll offset on parent", function() {
+
el = $("#draggable1").css({ position: 'absolute', top: 0, left: 0 }).draggable({ helper: "original" });
- $("#main")[0].scrollTop = 100;
- drag(el, 50, 50);
- moved(50, 50);
- $("#main")[0].scrollTop = 0;
+
+ setScroll();
+ testScroll('relative');
+
+ setScroll();
+ testScroll('static');
+
+ setScroll();
+ testScroll('absolute');
+
+ restoreScroll();
+
});
test("{ helper: 'original' }, absolute, with scroll offset on root", function() {
+
el = $("#draggable1").css({ position: 'absolute', top: 0, left: 0 }).draggable({ helper: "original" });
- $(document).scrollTop(100);
- drag(el, 50, 50);
- moved(50, 50);
- $(document).scrollTop(0);
+
+ setScroll('root');
+ testScroll('relative');
+
+ setScroll('root');
+ testScroll('static');
+
+ setScroll('root');
+ testScroll('absolute');
+
+ restoreScroll('root');
+
});
test("{ helper: 'original' }, absolute, with scroll offset on root and parent", function() {
+
el = $("#draggable1").css({ position: 'absolute', top: 0, left: 0 }).draggable({ helper: "original" });
- $(document).scrollTop(100);
- $("#main")[0].scrollTop = 100;
- drag(el, 50, 50);
- moved(50, 50);
- $(document).scrollTop(0);
- $("#main")[0].scrollTop = 0;
+
+ setScroll();
+ setScroll('root');
+ testScroll('relative');
+
+ setScroll();
+ setScroll('root');
+ testScroll('static');
+
+ setScroll();
+ setScroll('root');
+ testScroll('absolute');
+
+ restoreScroll();
+ restoreScroll('root');
+
});
//Fixed not for IE < 7
if(!($.browser.msie && $.browser.version < 7)) {
test("{ helper: 'original' }, fixed, with scroll offset on parent", function() {
+
el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" });
- $("#main")[0].scrollTop = 100;
- drag(el, 50, 50);
- moved(50, 50);
- $("#main")[0].scrollTop = 0;
+
+ setScroll();
+ testScroll('relative');
+
+ setScroll();
+ testScroll('static');
+
+ setScroll();
+ testScroll('absolute');
+
+ restoreScroll();
+
});
test("{ helper: 'original' }, fixed, with scroll offset on root", function() {
+
el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" });
- $(document).scrollTop(100);
- drag(el, 50, 50);
- moved(50, 50);
- $(document).scrollTop(0);
+
+ setScroll('root');
+ testScroll('relative');
+
+ setScroll('root');
+ testScroll('static');
+
+ setScroll('root');
+ testScroll('absolute');
+
+ restoreScroll('root');
+
});
test("{ helper: 'original' }, fixed, with scroll offset on root and parent", function() {
+
el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" });
- $(document).scrollTop(100);
- $("#main")[0].scrollTop = 100;
- drag(el, 50, 50);
- moved(50, 50);
- $(document).scrollTop(0);
- $("#main")[0].scrollTop = 0;
+
+ setScroll();
+ setScroll('root');
+ testScroll('relative');
+
+ setScroll();
+ setScroll('root');
+ testScroll('static');
+
+ setScroll();
+ setScroll('root');
+ testScroll('absolute');
+
+ restoreScroll();
+ restoreScroll('root');
+
});
}
@@ -571,14 +682,13 @@ test("{ helper: 'clone' }, absolute", function() {
} });
drag(el, 1, 1);
-
same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
});
test("{ helper: 'clone' }, absolute with scroll offset on parent", function() {
- $("#main")[0].scrollTop = 100;
+ setScroll();
var helperOffset = null;
var origOffset = $("#draggable1").offset();
@@ -586,34 +696,52 @@ test("{ helper: 'clone' }, absolute with scroll offset on parent", function() {
helperOffset = ui.helper.offset();
} });
+ $("#main").css('position', 'relative');
drag(el, 1, 1);
+ same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+ $("#main").css('position', 'static');
+ drag(el, 1, 1);
same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
- $("#main")[0].scrollTop = 0;
+
+ $("#main").css('position', 'absolute');
+ drag(el, 1, 1);
+ same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+
+ restoreScroll();
});
test("{ helper: 'clone' }, absolute with scroll offset on root", function() {
- $(document).scrollTop(100);
+ setScroll('root');
var helperOffset = null;
var origOffset = $("#draggable1").offset();
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
helperOffset = ui.helper.offset();
} });
-
+
+ $("#main").css('position', 'relative');
drag(el, 1, 1);
+ same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+ $("#main").css('position', 'static');
+ drag(el, 1, 1);
same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
- $(document).scrollTop(0);
+
+ $("#main").css('position', 'absolute');
+ drag(el, 1, 1);
+ same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+
+ restoreScroll('root');
});
test("{ helper: 'clone' }, absolute with scroll offset on root and parent", function() {
- $(document).scrollTop(100);
- $("#main")[0].scrollTop = 100;
+ setScroll('root');
+ setScroll();
var helperOffset = null;
var origOffset = $("#draggable1").offset();
@@ -621,11 +749,20 @@ test("{ helper: 'clone' }, absolute with scroll offset on root and parent", func
helperOffset = ui.helper.offset();
} });
+ $("#main").css('position', 'relative');
drag(el, 1, 1);
+ same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+ $("#main").css('position', 'static');
+ drag(el, 1, 1);
+ same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+
+ $("#main").css('position', 'absolute');
+ drag(el, 1, 1);
same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
- $(document).scrollTop(0);
- $("#main")[0].scrollTop = 0;
+
+ restoreScroll('root');
+ restoreScroll();
});
diff --git a/tests/droppable.html b/tests/droppable.html
index ec4bb758b..d2a4e0beb 100644
--- a/tests/droppable.html
+++ b/tests/droppable.html
@@ -18,9 +18,8 @@
<style type="text/css">
html { border: 0; }
#main {
- position:absolute !important;
- top: -1000px !important;
- left: -1000px !important;
+ top: -1000px;
+ left: -1000px;
}
</style>
</head>
@@ -32,9 +31,10 @@
<ol id="tests"></ol>
-<div id="main">
+<div id="main" style='position: absolute; width: 300px; height: 300px; overflow: auto;'>
<div id="draggable1" style="width: 25px; height: 25px;">Draggable</div>
<div id="droppable1" style="width: 100px; height: 100px;">Droppable</div>
+ <div style='width:1000px;height:1000px;'>&nbsp;</div>
</div>
</body>
diff --git a/ui/ui.draggable.js b/ui/ui.draggable.js
index abf1cddbc..d247ac09a 100644
--- a/ui/ui.draggable.js
+++ b/ui/ui.draggable.js
@@ -369,6 +369,7 @@ $.extend($.ui.draggable, {
containment: false,
cssNamespace: "ui",
cursor: "default",
+ cursorAt: null,
delay: 0,
distance: 1,
grid: false,
@@ -386,7 +387,8 @@ $.extend($.ui.draggable, {
snap: false,
snapMode: "both",
snapTolerance: 20,
- stack: false
+ stack: false,
+ zIndex: null
}
});