diff options
author | Zbigniew Motyka <zbigniew.motyka@gmail.com> | 2012-10-29 09:55:54 +0100 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2013-03-16 11:51:51 -0400 |
commit | bd126a9c1cfcbc9d0fd370af25cfa0eab294fc4e (patch) | |
tree | e666172d54d690d971fd2c846c6287659d9a19ac /tests/unit/draggable/draggable_options.js | |
parent | ebd5f13027b30be1cdd9e8782e81ce468dcdff5e (diff) | |
download | jquery-ui-bd126a9c1cfcbc9d0fd370af25cfa0eab294fc4e.tar.gz jquery-ui-bd126a9c1cfcbc9d0fd370af25cfa0eab294fc4e.zip |
Draggable: modified snapping algorithm to use edges and corners. Fixed #8165 - Draggable: Snapping doesn't take top/left into account properly
Diffstat (limited to 'tests/unit/draggable/draggable_options.js')
-rw-r--r-- | tests/unit/draggable/draggable_options.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 83fbc1712..2cb7ec22b 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -1257,6 +1257,43 @@ test( "snap, snapMode, and snapTolerance", function() { deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap on the inner snapTolerance area when snapMode is outer" ); }); +test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function() { + expect( 1 ); + + var snapTolerance = 20, + y = 1, + element = $( "#draggable1" ) + .css({ + width: "50px", + height: "200px" + }).offset({ + top: y, + left: 1 + }), + element2 = $( "#draggable2" ) + .css({ + width: "50px", + height: "50px" + }).offset({ + top: y + snapTolerance + 1, + left: 200 + }), + newX = element2.offset().left - element.outerWidth() - snapTolerance + 1; + + $( "#draggable1, #draggable2" ).draggable({ + snap: true, + snapTolerance: snapTolerance + }); + + element.simulate( "drag", { + handle: "corner", + x: newX, + moves: 1 + }); + + notDeepEqual( element.offset(), { top: y, left: newX }, "snaps even if only a side (not a corner) is inside the snapTolerance" ); +}); + test( "stack", function() { expect( 2 ); |