aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorZbigniew Motyka <zbigniew.motyka@gmail.com>2012-10-29 09:55:54 +0100
committerScott González <scott.gonzalez@gmail.com>2013-04-17 11:46:10 -0400
commitf74a9080562b9cedcae7030f3e4681b3ee0bfb14 (patch)
tree4adcab778ed1f5c894111b65c68ee6b9d5d37e20 /tests
parent149e6eb0bce7e891d35b862be920d36d3535f62e (diff)
downloadjquery-ui-f74a9080562b9cedcae7030f3e4681b3ee0bfb14.tar.gz
jquery-ui-f74a9080562b9cedcae7030f3e4681b3ee0bfb14.zip
Draggable: modified snapping algorithm to use edges and corners. Fixed #8165 - Draggable: Snapping doesn't take top/left into account properly(cherry picked from commit bd126a9c1cfcbc9d0fd370af25cfa0eab294fc4e)
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/draggable/draggable_options.js37
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 );