Skip to content

Commit 1242a71

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

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ui/selectable.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ return $.widget("ui.selectable", $.ui.mouse, {
6161
that._addClass( that.selectees, "ui-selectee" );
6262
that.selectees.each(function() {
6363
var $this = $(this),
64-
pos = $this.offset();
64+
pos = $this.position();
6565
$.data(this, "selectable-item", {
6666
element: this,
6767
$element: $this,
@@ -94,6 +94,7 @@ return $.widget("ui.selectable", $.ui.mouse, {
9494
options = this.options;
9595

9696
this.opos = [ event.pageX, event.pageY ];
97+
this.elementPos = $(this.element[0]).offset();
9798

9899
if (this.options.disabled) {
99100
return;
@@ -180,16 +181,22 @@ return $.widget("ui.selectable", $.ui.mouse, {
180181
this.selectees.each(function() {
181182
var selectee = $.data(this, "selectable-item"),
182183
hit = false;
184+
var offset = {
185+
left: selectee.left + that.elementPos.left,
186+
right: selectee.right + that.elementPos.left,
187+
top: selectee.top + that.elementPos.top,
188+
bottom: selectee.bottom + that.elementPos.top
189+
}
183190

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

189196
if (options.tolerance === "touch") {
190-
hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
197+
hit = ( !(offset.left > x2 || offset.right < x1 || offset.top > y2 || offset.bottom < y1) );
191198
} else if (options.tolerance === "fit") {
192-
hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
199+
hit = (offset.left > x1 && offset.right < x2 && offset.top > y1 && offset.bottom < y2);
193200
}
194201

195202
if (hit) {

0 commit comments

Comments
 (0)