mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Handle Tool._removeSets also when there is no corresponding event handler installed.
Closes #204.
This commit is contained in:
parent
f8c36b8276
commit
f59882b757
1 changed files with 9 additions and 15 deletions
|
@ -322,9 +322,8 @@ var Tool = PaperScopeItem.extend(/** @lends Tool# */{
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
fire: function fire(type, event) {
|
_fireEvent: function(type, event) {
|
||||||
// Override Callback#fire() so we can handle items marked in removeOn*()
|
// Handle items marked in removeOn*() calls first,.
|
||||||
// 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
|
||||||
|
@ -346,7 +345,8 @@ var Tool = PaperScopeItem.extend(/** @lends Tool# */{
|
||||||
sets[type] = null;
|
sets[type] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fire.base.call(this, type, event);
|
return this.responds(type)
|
||||||
|
&& this.fire(type, new ToolEvent(this, type, event));
|
||||||
},
|
},
|
||||||
|
|
||||||
_onHandleEvent: function(type, point, event) {
|
_onHandleEvent: function(type, point, event) {
|
||||||
|
@ -357,8 +357,7 @@ var Tool = PaperScopeItem.extend(/** @lends Tool# */{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'mousedown':
|
case 'mousedown':
|
||||||
this._updateEvent(type, point, null, null, true, false, false);
|
this._updateEvent(type, point, null, null, true, false, false);
|
||||||
if (this.responds(type))
|
called = this._fireEvent(type, event);
|
||||||
called = this.fire(type, new ToolEvent(this, type, event));
|
|
||||||
break;
|
break;
|
||||||
case 'mousedrag':
|
case 'mousedrag':
|
||||||
// In order for idleInterval drag events to work, we need to not
|
// In order for idleInterval drag events to work, we need to not
|
||||||
|
@ -373,8 +372,7 @@ var Tool = PaperScopeItem.extend(/** @lends Tool# */{
|
||||||
matchMaxDistance = false;
|
matchMaxDistance = false;
|
||||||
while (this._updateEvent(type, point, this.minDistance,
|
while (this._updateEvent(type, point, this.minDistance,
|
||||||
this.maxDistance, false, needsChange, matchMaxDistance)) {
|
this.maxDistance, false, needsChange, matchMaxDistance)) {
|
||||||
if (this.responds(type))
|
called = this._fireEvent(type, event) || called;
|
||||||
called = this.fire(type, new ToolEvent(this, type, event));
|
|
||||||
needsChange = true;
|
needsChange = true;
|
||||||
matchMaxDistance = true;
|
matchMaxDistance = true;
|
||||||
}
|
}
|
||||||
|
@ -385,14 +383,11 @@ var Tool = PaperScopeItem.extend(/** @lends Tool# */{
|
||||||
if (!point.equals(this._point)
|
if (!point.equals(this._point)
|
||||||
&& this._updateEvent('mousedrag', point, this.minDistance,
|
&& this._updateEvent('mousedrag', point, this.minDistance,
|
||||||
this.maxDistance, false, false, false)) {
|
this.maxDistance, false, false, false)) {
|
||||||
if (this.responds('mousedrag'))
|
called = this._fireEvent('mousedrag', event);
|
||||||
called = this.fire('mousedrag',
|
|
||||||
new ToolEvent(this, type, event));
|
|
||||||
}
|
}
|
||||||
this._updateEvent(type, point, null, this.maxDistance, false,
|
this._updateEvent(type, point, null, this.maxDistance, false,
|
||||||
false, false);
|
false, false);
|
||||||
if (this.responds(type))
|
called = this._fireEvent(type, event) || called;
|
||||||
called = this.fire(type, new ToolEvent(this, type, event));
|
|
||||||
// Start with new values for 'mousemove'
|
// Start with new values for 'mousemove'
|
||||||
this._updateEvent(type, point, null, null, true, false, false);
|
this._updateEvent(type, point, null, null, true, false, false);
|
||||||
this._firstMove = true;
|
this._firstMove = true;
|
||||||
|
@ -400,8 +395,7 @@ var Tool = PaperScopeItem.extend(/** @lends Tool# */{
|
||||||
case 'mousemove':
|
case 'mousemove':
|
||||||
while (this._updateEvent(type, point, this.minDistance,
|
while (this._updateEvent(type, point, this.minDistance,
|
||||||
this.maxDistance, this._firstMove, true, false)) {
|
this.maxDistance, this._firstMove, true, false)) {
|
||||||
if (this.responds(type))
|
called = this._fireEvent(type, event) || called;
|
||||||
called = this.fire(type, new ToolEvent(this, type, event));
|
|
||||||
this._firstMove = false;
|
this._firstMove = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue