Skip to content

Commit b1e35ac

Browse files
committed
Selectable: proper handling of inner scrolling
Fixes #13359
1 parent de4984d commit b1e35ac

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

ui/selectable.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,16 @@ return $.widget("ui.selectable", $.ui.mouse, {
5757

5858
// cache selectee children based on filter
5959
this.refresh = function() {
60+
that.elementPos = $(that.element[0]).offset();
6061
that.selectees = $(that.options.filter, that.element[0]);
6162
that._addClass( that.selectees, "ui-selectee" );
6263
that.selectees.each(function() {
6364
var $this = $(this),
64-
pos = $this.offset();
65+
selecteeOffset = $this.offset(),
66+
pos = {
67+
left: selecteeOffset.left - that.elementPos.left,
68+
top: selecteeOffset.top - that.elementPos.top
69+
};
6570
$.data(this, "selectable-item", {
6671
element: this,
6772
$element: $this,
@@ -94,6 +99,7 @@ return $.widget("ui.selectable", $.ui.mouse, {
9499
options = this.options;
95100

96101
this.opos = [ event.pageX, event.pageY ];
102+
this.elementPos = $(this.element[0]).offset();
97103

98104
if (this.options.disabled) {
99105
return;
@@ -179,17 +185,23 @@ return $.widget("ui.selectable", $.ui.mouse, {
179185

180186
this.selectees.each(function() {
181187
var selectee = $.data(this, "selectable-item"),
182-
hit = false;
188+
hit = false,
189+
offset = {};
183190

184191
//prevent helper from being selected if appendTo: selectable
185192
if (!selectee || selectee.element === that.element[0]) {
186193
return;
187194
}
188195

196+
offset.left = selectee.left + that.elementPos.left;
197+
offset.right = selectee.right + that.elementPos.left;
198+
offset.top = selectee.top + that.elementPos.top;
199+
offset.bottom = selectee.bottom + that.elementPos.top;
200+
189201
if (options.tolerance === "touch") {
190-
hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
202+
hit = ( !(offset.left > x2 || offset.right < x1 || offset.top > y2 || offset.bottom < y1) );
191203
} else if (options.tolerance === "fit") {
192-
hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
204+
hit = (offset.left > x1 && offset.right < x2 && offset.top > y1 && offset.bottom < y2);
193205
}
194206

195207
if (hit) {

0 commit comments

Comments
 (0)