Skip to content

Commit cf48fc7

Browse files
author
Paul Bakaus
committed
sortable: added forcePointerForContainers option (to have another intersection mode for items, but allow only one container to be activated at the same time), added custom object in options, that holds custom (defined) functions that are called instead of original pieces. Only for advanced developers, currently only supported function: refreshContainers.
1 parent a8c39c2 commit cf48fc7

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

ui/ui.sortable.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
9292
var l = item.left, r = l + item.width,
9393
t = item.top, b = t + item.height;
9494

95-
if(this.options.tolerance == "pointer" || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) {
95+
if(this.options.tolerance == "pointer" || this.options.forcePointerForContainers || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) {
9696
return (y1 + this.offset.click.top > t && y1 + this.offset.click.top < b && x1 + this.offset.click.left > l && x1 + this.offset.click.left < r);
9797
} else {
9898

@@ -206,15 +206,19 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
206206
this.items[i].top = p.top;
207207

208208
};
209-
210-
for (var i = this.containers.length - 1; i >= 0; i--){
211-
var p =this.containers[i].element.offset();
212-
this.containers[i].containerCache.left = p.left;
213-
this.containers[i].containerCache.top = p.top;
214-
this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
215-
this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
216-
};
217-
209+
210+
if(this.options.custom && this.options.custom.refreshContainers) {
211+
this.options.custom.refreshContainers.call(this);
212+
} else {
213+
for (var i = this.containers.length - 1; i >= 0; i--){
214+
var p =this.containers[i].element.offset();
215+
this.containers[i].containerCache.left = p.left;
216+
this.containers[i].containerCache.top = p.top;
217+
this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
218+
this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
219+
};
220+
}
221+
218222
},
219223
destroy: function() {
220224
this.element

0 commit comments

Comments
 (0)