mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
draggable: another connectToSortable improvement: the activate/deactivate callbacks are now fired when the draggable starts dragging
This commit is contained in:
parent
5b19d8e723
commit
5f24485abe
@ -430,17 +430,22 @@
|
|||||||
|
|
||||||
$.ui.plugin.add("draggable", "connectToSortable", {
|
$.ui.plugin.add("draggable", "connectToSortable", {
|
||||||
start: function(e,ui) {
|
start: function(e,ui) {
|
||||||
|
|
||||||
var inst = $(this).data("draggable");
|
var inst = $(this).data("draggable");
|
||||||
inst.sortables = [];
|
inst.sortables = [];
|
||||||
$(ui.options.connectToSortable).each(function() {
|
$(ui.options.connectToSortable).each(function() {
|
||||||
if($.data(this, 'sortable')) inst.sortables.push({
|
if($.data(this, 'sortable')) {
|
||||||
instance: $.data(this, 'sortable'),
|
var sortable = $.data(this, 'sortable');
|
||||||
offset: $.data(this, 'sortable').element.offset(),
|
inst.sortables.push({
|
||||||
width: $.data(this, 'sortable').element.width(),
|
instance: sortable,
|
||||||
height: $.data(this, 'sortable').element.height(),
|
offset: sortable.element.offset(),
|
||||||
shouldRevert: $.data(this, 'sortable').options.revert
|
width: sortable.element.width(),
|
||||||
});
|
height: sortable.element.height(),
|
||||||
|
shouldRevert: sortable.options.revert
|
||||||
|
});
|
||||||
|
|
||||||
|
sortable.propagate("activate", e, inst);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -461,7 +466,10 @@
|
|||||||
this.instance.element.triggerHandler("sortreceive", [e, $.extend(this.instance.ui(), { sender: inst.element })], this.instance.options["receive"]);
|
this.instance.element.triggerHandler("sortreceive", [e, $.extend(this.instance.ui(), { sender: inst.element })], this.instance.options["receive"]);
|
||||||
|
|
||||||
this.instance.options.helper = this.instance.options._helper;
|
this.instance.options.helper = this.instance.options._helper;
|
||||||
|
} else {
|
||||||
|
this.instance.propagate("deactivate", e, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -473,17 +481,19 @@
|
|||||||
|
|
||||||
var l = o.left, r = l + o.width,
|
var l = o.left, r = l + o.width,
|
||||||
t = o.top, b = t + o.height;
|
t = o.top, b = t + o.height;
|
||||||
|
|
||||||
return (l < (this.positionAbs.left + this.offset.click.left) && (this.positionAbs.left + this.offset.click.left) < r
|
return (l < (this.positionAbs.left + this.offset.click.left) && (this.positionAbs.left + this.offset.click.left) < r
|
||||||
&& t < (this.positionAbs.top + this.offset.click.top) && (this.positionAbs.top + this.offset.click.top) < b);
|
&& t < (this.positionAbs.top + this.offset.click.top) && (this.positionAbs.top + this.offset.click.top) < b);
|
||||||
};
|
};
|
||||||
|
|
||||||
$.each(inst.sortables, function() {
|
$.each(inst.sortables, function(i) {
|
||||||
|
|
||||||
|
|
||||||
if(checkPos.call(inst, {
|
if(checkPos.call(inst, {
|
||||||
left: this.offset.left, top: this.offset.top,
|
left: this.offset.left, top: this.offset.top,
|
||||||
width: this.width, height: this.height
|
width: this.width, height: this.height
|
||||||
})) {
|
})) {
|
||||||
|
|
||||||
//If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
|
//If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
|
||||||
if(!this.instance.isOver) {
|
if(!this.instance.isOver) {
|
||||||
this.instance.isOver = 1;
|
this.instance.isOver = 1;
|
||||||
@ -496,7 +506,7 @@
|
|||||||
this.instance.options.helper = function() { return ui.helper[0]; };
|
this.instance.options.helper = function() { return ui.helper[0]; };
|
||||||
|
|
||||||
e.target = this.instance.currentItem[0];
|
e.target = this.instance.currentItem[0];
|
||||||
this.instance.mouseStart(e, true);
|
this.instance.mouseStart(e, true, true);
|
||||||
|
|
||||||
//Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
|
//Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
|
||||||
this.instance.offset.click.top = inst.offset.click.top;
|
this.instance.offset.click.top = inst.offset.click.top;
|
||||||
|
@ -284,7 +284,7 @@
|
|||||||
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mouseStart: function(e, overrideHandle) {
|
mouseStart: function(e, overrideHandle, noActivation) {
|
||||||
|
|
||||||
var o = this.options;
|
var o = this.options;
|
||||||
this.currentContainer = this;
|
this.currentContainer = this;
|
||||||
@ -385,7 +385,10 @@
|
|||||||
this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size
|
this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size
|
||||||
|
|
||||||
if(this.options.placeholder != 'clone') this.currentItem.css('visibility', 'hidden'); //Set the original element visibility to hidden to still fill out the white space
|
if(this.options.placeholder != 'clone') this.currentItem.css('visibility', 'hidden'); //Set the original element visibility to hidden to still fill out the white space
|
||||||
for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i].propagate("activate", e, this); } //Post 'activate' events to possible containers
|
|
||||||
|
if(!noActivation) {
|
||||||
|
for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i].propagate("activate", e, this); } //Post 'activate' events to possible containers
|
||||||
|
}
|
||||||
|
|
||||||
//Prepare possible droppables
|
//Prepare possible droppables
|
||||||
if($.ui.ddmanager) $.ui.ddmanager.current = this;
|
if($.ui.ddmanager) $.ui.ddmanager.current = this;
|
||||||
@ -529,18 +532,18 @@
|
|||||||
|
|
||||||
if(this.domPosition != this.currentItem.prev()[0]) this.propagate("update", e, null, noPropagation); //Trigger update callback if the DOM position has changed
|
if(this.domPosition != this.currentItem.prev()[0]) this.propagate("update", e, null, noPropagation); //Trigger update callback if the DOM position has changed
|
||||||
if(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
|
if(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
|
||||||
this.propagate("remove", e);
|
this.propagate("remove", e, null, noPropagation);
|
||||||
for (var i = this.containers.length - 1; i >= 0; i--){
|
for (var i = this.containers.length - 1; i >= 0; i--){
|
||||||
if(contains(this.containers[i].element[0], this.currentItem[0])) {
|
if(contains(this.containers[i].element[0], this.currentItem[0])) {
|
||||||
this.containers[i].propagate("update", e, this);
|
this.containers[i].propagate("update", e, this, noPropagation);
|
||||||
this.containers[i].propagate("receive", e, this);
|
this.containers[i].propagate("receive", e, this, noPropagation);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
//Post events to containers
|
//Post events to containers
|
||||||
for (var i = this.containers.length - 1; i >= 0; i--){
|
for (var i = this.containers.length - 1; i >= 0; i--){
|
||||||
this.containers[i].propagate("deactivate", e, this);
|
this.containers[i].propagate("deactivate", e, this, noPropagation);
|
||||||
if(this.containers[i].containerCache.over) {
|
if(this.containers[i].containerCache.over) {
|
||||||
this.containers[i].propagate("out", e, this);
|
this.containers[i].propagate("out", e, this);
|
||||||
this.containers[i].containerCache.over = 0;
|
this.containers[i].containerCache.over = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user