Ticket #4977: droppable_pointer_test.patch

File droppable_pointer_test.patch, 1.6 KB (added by kevin.wells, 13 years ago)
  • droppable_tickets.js

     
    55
    66module("droppable: tickets");
    77
     8test("#4977: tolerance, pointer - when pointer outside draggable", function() {
     9        var draggable1 = $("#draggable1");
     10        var droppable1 = $("#droppable1");
     11        var isDropped = false;
     12
     13        droppable1.droppable({
     14                tolerance: 'pointer',
     15                drop: function() { isDropped = true; }
     16        });
     17
     18        // Contain draggable so only its bottom half can be dragged
     19        // over the droppable.
     20        draggable1.draggable({ containment: [
     21                draggable1.offset().left,
     22                draggable1.offset().top,
     23                droppable1.offset().left + droppable1.width(),
     24                droppable1.offset().top - Math.round(draggable1.height() / 2)
     25        ]});
     26
     27        // Pointer starts out over "top of draggable"
     28        draggable1.simulate("mousedown", {
     29                clientX: draggable1.offset().left + draggable1.width() / 2,
     30                clientY: draggable1.offset().top + 1 // draggable1.height() - 1
     31        });
     32
     33        // Pointer ends up below bottom of draggable:
     34        //
     35        //   * Top of draggable is *not* inside droppable.
     36        //   * Bottom of draggable *is* inside droppable.
     37        //   * Pointer *is* inside droppable, and outside droppable.
     38        var pos = {
     39                clientX: droppable1.offset().left + droppable1.width() / 2,
     40                clientY: droppable1.offset().top + draggable1.height()
     41        };
     42        draggable1.simulate("mousemove", pos);
     43        draggable1.simulate("mouseup", pos);
     44
     45        draggable1.draggable("destroy");
     46        droppable1.droppable("destroy");
     47
     48        ok(isDropped, "tolerance, pointer - when pointer outside draggable");
     49});
     50
    851})(jQuery);