diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2014-08-16 21:27:16 -0400 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2014-08-16 21:27:16 -0400 |
commit | b5846bece34db31d69e75cb3a3537827c005910e (patch) | |
tree | 59d1d4696ced8b581a26cf457a3ac2c02144c0fc /tests/unit/draggable/draggable_events.js | |
parent | cdcb391f4e33de24df8ff5ce17aeea42f3835dc0 (diff) | |
download | jquery-ui-b5846bece34db31d69e75cb3a3537827c005910e.tar.gz jquery-ui-b5846bece34db31d69e75cb3a3537827c005910e.zip |
Draggable: Recalculate hash offset on start after plugins run
Fixes #6884
Diffstat (limited to 'tests/unit/draggable/draggable_events.js')
-rw-r--r-- | tests/unit/draggable/draggable_events.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/unit/draggable/draggable_events.js b/tests/unit/draggable/draggable_events.js index bbaaaeb15..dd5c315b0 100644 --- a/tests/unit/draggable/draggable_events.js +++ b/tests/unit/draggable/draggable_events.js @@ -118,8 +118,47 @@ test( "stopping the stop callback", function() { }); ok( element.draggable( "instance" ).helper, "the clone should not be deleted if the stop callback is stopped" ); +}); + +// http://bugs.jqueryui.com/ticket/6884 +// Draggable: ui.offset.left differs between the "start" and "drag" hooks +test( "position and offset in hash is consistent between start, drag, and stop", function() { + expect( 4 ); + + var startPos, startOffset, dragPos, dragOffset, stopPos, stopOffset; + + element = $( "<div style='margin: 2px;'></div>" ).appendTo( "#qunit-fixture" ); + + element.draggable({ + start: function( event, ui ) { + startPos = ui.position; + startOffset = ui.offset; + }, + drag: function( event, ui ) { + dragPos = ui.position; + dragOffset = ui.offset; + }, + stop: function( event, ui ) { + stopPos = ui.position; + stopOffset = ui.offset; + } + }); + + element.simulate( "drag", { + dx: 10, + dy: 10, + moves: 1 + }); + startPos.left += 10; + startPos.top += 10; + startOffset.left += 10; + startOffset.top += 10; + deepEqual( startPos, dragPos, "start position equals drag position plus distance" ); + deepEqual( dragPos, stopPos, "drag position equals stop position" ); + deepEqual( startOffset, dragOffset, "start offset equals drag offset plus distance" ); + deepEqual( dragOffset, stopOffset, "drag offset equals stop offset" ); }); })( jQuery ); |