diff options
author | Woody Gilk <shadowhand@deviantart.com> | 2013-03-14 13:21:24 -0500 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2013-04-17 11:38:29 -0400 |
commit | 943537cb785fb90adf9f0b515cbb084a1a2e3c04 (patch) | |
tree | ea44fd237f268cc7d7866d58183bd9dcb4a9ebcd /tests | |
parent | deec8eb05381cb0d5d257ded2d03ecf8d93f8a82 (diff) | |
download | jquery-ui-943537cb785fb90adf9f0b515cbb084a1a2e3c04.tar.gz jquery-ui-943537cb785fb90adf9f0b515cbb084a1a2e3c04.zip |
Draggable: Fix double offset bug when scrolling. Fixes #6817 - Draggable: auto scroll goes double distance when dragging
(cherry picked from commit 82f588e82b887fdcb2406da2c5dfedc2f13ebdc9)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/draggable/draggable_options.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index a71bf57cb..83fbc1712 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -1103,6 +1103,40 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() { TestHelpers.draggable.restoreScroll( document ); }); +test( "#6817: auto scroll goes double distance when dragging", function() { + expect( 2 ); + + var offsetBefore, + distance = 10, + viewportHeight = $( window ).height(), + element = $( "#draggable1" ).draggable({ + scroll: true, + stop: function( e, ui ) { + equal( ui.offset.top, newY, "offset of item matches pointer position after scroll" ); + equal( ui.offset.top - offsetBefore.top, distance, "offset of item only moves expected distance after scroll" ); + } + }), + scrollSensitivity = element.draggable( "option", "scrollSensitivity" ), + oldY = viewportHeight - scrollSensitivity, + newY = oldY + distance; + + element.offset({ + top: oldY, + left: 1 + }); + + offsetBefore = element.offset(); + + element.simulate( "drag", { + handle: "corner", + dx: 1, + y: newY, + moves: 1 + }); + + TestHelpers.draggable.restoreScroll( document ); +}); + test( "snap, snapMode, and snapTolerance", function() { expect( 9 ); |