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
@ -434,13 +434,18 @@
|
||||
var inst = $(this).data("draggable");
|
||||
inst.sortables = [];
|
||||
$(ui.options.connectToSortable).each(function() {
|
||||
if($.data(this, 'sortable')) inst.sortables.push({
|
||||
instance: $.data(this, 'sortable'),
|
||||
offset: $.data(this, 'sortable').element.offset(),
|
||||
width: $.data(this, 'sortable').element.width(),
|
||||
height: $.data(this, 'sortable').element.height(),
|
||||
shouldRevert: $.data(this, 'sortable').options.revert
|
||||
if($.data(this, 'sortable')) {
|
||||
var sortable = $.data(this, 'sortable');
|
||||
inst.sortables.push({
|
||||
instance: sortable,
|
||||
offset: sortable.element.offset(),
|
||||
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.options.helper = this.instance.options._helper;
|
||||
} else {
|
||||
this.instance.propagate("deactivate", e, inst);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
@ -478,12 +486,14 @@
|
||||
&& 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, {
|
||||
left: this.offset.left, top: this.offset.top,
|
||||
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(!this.instance.isOver) {
|
||||
this.instance.isOver = 1;
|
||||
@ -496,7 +506,7 @@
|
||||
this.instance.options.helper = function() { return ui.helper[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
|
||||
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;
|
||||
this.currentContainer = this;
|
||||
@ -385,7 +385,10 @@
|
||||
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(!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
|
||||
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(!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--){
|
||||
if(contains(this.containers[i].element[0], this.currentItem[0])) {
|
||||
this.containers[i].propagate("update", e, this);
|
||||
this.containers[i].propagate("receive", e, this);
|
||||
this.containers[i].propagate("update", e, this, noPropagation);
|
||||
this.containers[i].propagate("receive", e, this, noPropagation);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//Post events to containers
|
||||
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) {
|
||||
this.containers[i].propagate("out", e, this);
|
||||
this.containers[i].containerCache.over = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user