aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Balchunas <bleshik@gmail.com>2015-07-01 21:45:54 +0300
committerJörn Zaefferer <joern.zaefferer@gmail.com>2016-04-21 16:11:37 +0200
commita240251b36081ddbc24c13e0c3e129332c1d8d45 (patch)
tree08a1f7df0a73bdb0c7abab89a05d7781c37cd6ba
parent2e770153c5c1e7a4a755e2aa249f69a246fd17f7 (diff)
downloadjquery-ui-a240251b36081ddbc24c13e0c3e129332c1d8d45.tar.gz
jquery-ui-a240251b36081ddbc24c13e0c3e129332c1d8d45.zip
Selectable: Proper handling of inner scrolling
Fixes #13359 Closes gh-1570
-rw-r--r--ui/widgets/selectable.js24
1 files changed, 18 insertions, 6 deletions
diff --git a/ui/widgets/selectable.js b/ui/widgets/selectable.js
index de7c59faf..ed980cc49 100644
--- a/ui/widgets/selectable.js
+++ b/ui/widgets/selectable.js
@@ -57,11 +57,16 @@ return $.widget( "ui.selectable", $.ui.mouse, {
// Cache selectee children based on filter
this.refresh = function() {
+ that.elementPos = $( that.element[ 0 ] ).offset();
that.selectees = $( that.options.filter, that.element[ 0 ] );
that._addClass( that.selectees, "ui-selectee" );
that.selectees.each( function() {
var $this = $( this ),
- pos = $this.offset();
+ selecteeOffset = $this.offset(),
+ pos = {
+ left: selecteeOffset.left - that.elementPos.left,
+ top: selecteeOffset.top - that.elementPos.top
+ };
$.data( this, "selectable-item", {
element: this,
$element: $this,
@@ -94,6 +99,7 @@ return $.widget( "ui.selectable", $.ui.mouse, {
options = this.options;
this.opos = [ event.pageX, event.pageY ];
+ this.elementPos = $( this.element[ 0 ] ).offset();
if ( this.options.disabled ) {
return;
@@ -183,19 +189,25 @@ return $.widget( "ui.selectable", $.ui.mouse, {
this.selectees.each( function() {
var selectee = $.data( this, "selectable-item" ),
- hit = false;
+ hit = false,
+ offset = {};
//prevent helper from being selected if appendTo: selectable
if ( !selectee || selectee.element === that.element[ 0 ] ) {
return;
}
+ offset.left = selectee.left + that.elementPos.left;
+ offset.right = selectee.right + that.elementPos.left;
+ offset.top = selectee.top + that.elementPos.top;
+ offset.bottom = selectee.bottom + that.elementPos.top;
+
if ( options.tolerance === "touch" ) {
- hit = ( !( selectee.left > x2 || selectee.right < x1 || selectee.top > y2 ||
- selectee.bottom < y1 ) );
+ hit = ( !( offset.left > x2 || offset.right < x1 || offset.top > y2 ||
+ offset.bottom < y1 ) );
} else if ( options.tolerance === "fit" ) {
- hit = ( selectee.left > x1 && selectee.right < x2 && selectee.top > y1 &&
- selectee.bottom < y2 );
+ hit = ( offset.left > x1 && offset.right < x2 && offset.top > y1 &&
+ offset.bottom < y2 );
}
if ( hit ) {