Fix issue with removeOnMove() calls sometimes removing items too early.

Closes #181.
This commit is contained in:
Jürg Lehni 2013-03-05 15:22:44 -08:00
parent c0392b837c
commit 80600d2a2b

View file

@ -322,10 +322,9 @@ var Tool = this.Tool = PaperScopeItem.extend(/** @lends Tool# */{
return true; return true;
}, },
_onHandleEvent: function(type, point, event) { fire: function(type, event) {
// Update global reference to this scope. // Override Callback#fire() so we can handle items marked in removeOn*()
paper = this._scope; // calls first,.
// Handle removeOn* calls first
var sets = Tool._removeSets; var sets = Tool._removeSets;
if (sets) { if (sets) {
// Always clear the drag set on mouseup // Always clear the drag set on mouseup
@ -339,7 +338,7 @@ var Tool = this.Tool = PaperScopeItem.extend(/** @lends Tool# */{
// other sets. // other sets.
for (var key in sets) { for (var key in sets) {
var other = sets[key]; var other = sets[key];
if (other && other != set && other[item._id]) if (other && other != set)
delete other[item._id]; delete other[item._id];
} }
item.remove(); item.remove();
@ -347,6 +346,12 @@ var Tool = this.Tool = PaperScopeItem.extend(/** @lends Tool# */{
sets[type] = null; sets[type] = null;
} }
} }
return this.base(type, event);
},
_onHandleEvent: function(type, point, event) {
// Update global reference to this scope.
paper = this._scope;
// Now handle event callbacks // Now handle event callbacks
var called = false; var called = false;
switch (type) { switch (type) {