Skip to content

Commit 6953589

Browse files
tjvantollscottgonzalez
authored andcommitted
Selectable: Account for scrolling on the helper's initial position. Fixed #8915 - Selectable: Lasso offset issue with scrolling.
1 parent 2620be8 commit 6953589

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

tests/unit/selectable/selectable_events.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,32 @@ test( "stop", function() {
3535
});
3636
});
3737

38+
test( "mousedown: initial position of helper", function() {
39+
expect( 2 );
40+
41+
var contentToForceScroll, helper,
42+
element = $("#selectable1").selectable();
43+
44+
contentToForceScroll = $("<div>").css({
45+
height: "10000px",
46+
width: "10000px"
47+
});
48+
49+
contentToForceScroll.appendTo("body");
50+
$( window ).scrollTop( 1 ).scrollLeft( 1 );
51+
element.simulate( "mousedown", {
52+
clientX: 10,
53+
clientY: 10
54+
});
55+
56+
helper = $(".ui-selectable-helper");
57+
equal( helper.css("top"), "11px", "Scroll top should be accounted for." );
58+
equal( helper.css("left"), "11px", "Scroll left should be accounted for." );
59+
60+
// Cleanup
61+
element.simulate("mouseup");
62+
contentToForceScroll.remove();
63+
$( window ).scrollTop( 0 ).scrollLeft( 0 );
64+
});
65+
3866
})( jQuery );

ui/jquery.ui.selectable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ $.widget("ui.selectable", $.ui.mouse, {
8888
$(options.appendTo).append(this.helper);
8989
// position helper (lasso)
9090
this.helper.css({
91-
"left": event.clientX,
92-
"top": event.clientY,
91+
"left": event.pageX,
92+
"top": event.pageY,
9393
"width": 0,
9494
"height": 0
9595
});

0 commit comments

Comments
 (0)