diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2014-08-09 23:00:58 -0400 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2014-08-12 19:30:09 -0400 |
commit | e9efbc222149ca7c7a5fef2c0fe28b7b1d9be698 (patch) | |
tree | 081806d40a83fc1db9ea18dfecdecc780ee6744d /tests | |
parent | 67e4b44b295517cb81ced7b6c41fd9898a45d0d9 (diff) | |
download | jquery-ui-e9efbc222149ca7c7a5fef2c0fe28b7b1d9be698.tar.gz jquery-ui-e9efbc222149ca7c7a5fef2c0fe28b7b1d9be698.zip |
Draggable: consider offsets from overflow:hidden parents
Developers can programmatically set scrollTop/Left on
draggable containers that are overflow:hidden. They must
be considered for positioning.
Fixes #10147
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/draggable/draggable_core.js | 66 | ||||
-rw-r--r-- | tests/unit/draggable/draggable_options.js | 2 |
2 files changed, 37 insertions, 31 deletions
diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 8d611514f..93c6e4080 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -185,38 +185,44 @@ 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, +$( [ "hidden", "auto", "scroll" ] ).each(function() { + var overflow = this; + + // http://bugs.jqueryui.com/ticket/9379 - position bug in scrollable div + // http://bugs.jqueryui.com/ticket/10147 - Wrong position in a parent with "overflow: hidden" + test( "position in scrollable parent with overflow: " + overflow, function() { + expect( 2 ); + + $( "#qunit-fixture" ).html( "<div id='outer'><div id='inner'></div><div id='dragged'>a</div></div>" ); + $( "#inner" ).css({ position: "absolute", width: "500px", height: "500px" }); + $( "#outer" ).css({ position: "absolute", width: "300px", height: "300px" }); + $( "#dragged" ).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 = $( "#dragged" ).draggable({ + drag: function() { + startValue += dragDelta; + $( "#outer" ).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" ); + } + }); + + $( "#outer" ).css( "overflow", overflow ); - // 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" ); - } + element.simulate( "drag", { + dy: delta, + dx: delta, + moves: moves }); - - $( "#o_9379" ).css( "overflow", "auto" ); - - element.simulate( "drag", { - dy: delta, - dx: delta, - moves: moves }); }); diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 1a9d78925..a94452d9a 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -361,7 +361,7 @@ test( "containment, account for border", function() { el.css({ height: "5px", width: "5px" - }).draggable({ containment: "parent" }); + }).draggable({ containment: "parent", scroll: false }); el.simulate( "drag", { dx: 100, |