]> source.dussan.org Git - jquery-ui.git/commitdiff
Selectable: Account for scrolling on the helper's initial position. Fixed #8915 ...
authorTJ VanToll <tj.vantoll@gmail.com>
Sat, 29 Dec 2012 03:17:50 +0000 (22:17 -0500)
committerScott González <scott.gonzalez@gmail.com>
Tue, 1 Jan 2013 13:22:18 +0000 (08:22 -0500)
tests/unit/selectable/selectable_events.js
ui/jquery.ui.selectable.js

index 984fd1862f976452fcc42585cdc011e0d1204b7c..f933d3890ab5c0d56a75bcdebdb1ae9bf972c9af 100644 (file)
@@ -35,4 +35,32 @@ test( "stop", function() {
        });
 });
 
+test( "mousedown: initial position of helper", function() {
+       expect( 2 );
+
+       var contentToForceScroll, helper,
+               element = $("#selectable1").selectable();
+
+       contentToForceScroll = $("<div>").css({
+               height: "10000px",
+               width: "10000px"
+       });
+
+       contentToForceScroll.appendTo("body");
+       $( window ).scrollTop( 1 ).scrollLeft( 1 );
+       element.simulate( "mousedown", {
+               clientX: 10,
+               clientY: 10
+       });
+
+       helper = $(".ui-selectable-helper");
+       equal( helper.css("top"), "11px", "Scroll top should be accounted for." );
+       equal( helper.css("left"), "11px", "Scroll left should be accounted for." );
+
+       // Cleanup
+       element.simulate("mouseup");
+       contentToForceScroll.remove();
+       $( window ).scrollTop( 0 ).scrollLeft( 0 );
+});
+
 })( jQuery );
index 32152291bfc926ccc2c8851e98a1bf354e7a8e3c..8e6d03c1ff95816cfb4dca8ac89b337057793a8e 100644 (file)
@@ -88,8 +88,8 @@ $.widget("ui.selectable", $.ui.mouse, {
                $(options.appendTo).append(this.helper);
                // position helper (lasso)
                this.helper.css({
-                       "left": event.clientX,
-                       "top": event.clientY,
+                       "left": event.pageX,
+                       "top": event.pageY,
                        "width": 0,
                        "height": 0
                });