mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
draggable: added missing default for zIndex and cursorAt, added missing scroll tests (unfortunately showing big regressions that need to be fixed prior to 1.6)
This commit is contained in:
parent
65289463de
commit
0036aaf4b6
@ -476,85 +476,196 @@ test("callbacks occurance count", function() {
|
||||
|
||||
module("draggable: Scroll offsets");
|
||||
|
||||
test("{ helper: 'original' }, relative, with scroll offset on parent", function() {
|
||||
el = $("#draggable1").draggable({ helper: "original" });
|
||||
$("#main")[0].scrollTop = 100;
|
||||
|
||||
function testScroll(position) {
|
||||
$("#main").css('position', position);
|
||||
drag(el, 50, 50);
|
||||
moved(50, 50);
|
||||
$("#main")[0].scrollTop = 0;
|
||||
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" });
|
||||
|
||||
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")[0].scrollTop = 0;
|
||||
|
||||
$("#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 + '] ');
|
||||
|
||||
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 + '] ');
|
||||
$(document).scrollTop(0);
|
||||
|
||||
$("#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 + '] ');
|
||||
|
||||
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 + '] ');
|
||||
$(document).scrollTop(0);
|
||||
$("#main")[0].scrollTop = 0;
|
||||
|
||||
$("#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 + '] ');
|
||||
|
||||
restoreScroll('root');
|
||||
restoreScroll();
|
||||
|
||||
});
|
||||
|
||||
|
@ -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;'> </div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
@ -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
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user