mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 13:52:06 -05:00
Remove recently introduced code blocks for small conditional statements.
This commit is contained in:
parent
40c988b313
commit
6e0e31480a
1 changed files with 10 additions and 20 deletions
|
@ -25,9 +25,8 @@ var ToolHandler = this.ToolHandler = Base.extend({
|
||||||
this._firstMove = true;
|
this._firstMove = true;
|
||||||
this._count = 0;
|
this._count = 0;
|
||||||
this._downCount = 0;
|
this._downCount = 0;
|
||||||
for (var i in handlers) {
|
for (var i in handlers)
|
||||||
this[i] = handlers[i];
|
this[i] = handlers[i];
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,10 +58,8 @@ var ToolHandler = this.ToolHandler = Base.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getFixedDistance: function() {
|
getFixedDistance: function() {
|
||||||
if (this._minDistance == this._maxDistance) {
|
return this._minDistance == this._maxDistance
|
||||||
return this._minDistance;
|
? this._minDistance : null;
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setFixedDistance: function(distance) {
|
setFixedDistance: function(distance) {
|
||||||
|
@ -77,9 +74,8 @@ var ToolHandler = this.ToolHandler = Base.extend({
|
||||||
var minDist = minDistance != null ? minDistance : 0;
|
var minDist = minDistance != null ? minDistance : 0;
|
||||||
var vector = pt.subtract(this._point);
|
var vector = pt.subtract(this._point);
|
||||||
var distance = vector.getLength();
|
var distance = vector.getLength();
|
||||||
if (distance < minDist) {
|
if (distance < minDist)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
// Produce a new point on the way to pt if pt is further away
|
// Produce a new point on the way to pt if pt is further away
|
||||||
// than maxDistance
|
// than maxDistance
|
||||||
var maxDist = maxDistance != null ? maxDistance : 0;
|
var maxDist = maxDistance != null ? maxDistance : 0;
|
||||||
|
@ -91,10 +87,9 @@ var ToolHandler = this.ToolHandler = Base.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (needsChange && pt.equals(this._point)) {
|
if (needsChange && pt.equals(this._point))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this._lastPoint = this._point;
|
this._lastPoint = this._point;
|
||||||
this._point = pt;
|
this._point = pt;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -118,9 +113,8 @@ var ToolHandler = this.ToolHandler = Base.extend({
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'mousedown':
|
case 'mousedown':
|
||||||
this.updateEvent(type, pt, null, null, true, false, false);
|
this.updateEvent(type, pt, null, null, true, false, false);
|
||||||
if (this.onMouseDown) {
|
if (this.onMouseDown)
|
||||||
this.onMouseDown(new ToolEvent(this, type, event));
|
this.onMouseDown(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
|
||||||
|
@ -135,9 +129,8 @@ var ToolHandler = this.ToolHandler = Base.extend({
|
||||||
matchMaxDistance = false;
|
matchMaxDistance = false;
|
||||||
while (this.updateEvent(type, pt, this.minDistance,
|
while (this.updateEvent(type, pt, this.minDistance,
|
||||||
this.maxDistance, false, needsChange, matchMaxDistance)) {
|
this.maxDistance, false, needsChange, matchMaxDistance)) {
|
||||||
if (this.onMouseDrag) {
|
if (this.onMouseDrag)
|
||||||
this.onMouseDrag(new ToolEvent(this, type, event));
|
this.onMouseDrag(new ToolEvent(this, type, event));
|
||||||
}
|
|
||||||
needsChange = true;
|
needsChange = true;
|
||||||
matchMaxDistance = true;
|
matchMaxDistance = true;
|
||||||
}
|
}
|
||||||
|
@ -148,15 +141,13 @@ var ToolHandler = this.ToolHandler = Base.extend({
|
||||||
if ((this._point.x != pt.x || this._point.y != pt.y)
|
if ((this._point.x != pt.x || this._point.y != pt.y)
|
||||||
&& this.updateEvent('mousedrag', pt, this.minDistance,
|
&& this.updateEvent('mousedrag', pt, this.minDistance,
|
||||||
this.maxDistance, false, false, false)) {
|
this.maxDistance, false, false, false)) {
|
||||||
if (this.onMouseDrag) {
|
if (this.onMouseDrag)
|
||||||
this.onMouseDrag(new ToolEvent(this, type, event));
|
this.onMouseDrag(new ToolEvent(this, type, event));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.updateEvent(type, pt, null, this.maxDistance, false,
|
this.updateEvent(type, pt, null, this.maxDistance, false,
|
||||||
false, false);
|
false, false);
|
||||||
if (this.onMouseUp) {
|
if (this.onMouseUp)
|
||||||
this.onMouseUp(new ToolEvent(this, type, event));
|
this.onMouseUp(new ToolEvent(this, type, event));
|
||||||
}
|
|
||||||
// Start with new values for 'mousemove'
|
// Start with new values for 'mousemove'
|
||||||
this.updateEvent(type, pt, null, null, true, false, false);
|
this.updateEvent(type, pt, null, null, true, false, false);
|
||||||
this._firstMove = true;
|
this._firstMove = true;
|
||||||
|
@ -164,9 +155,8 @@ var ToolHandler = this.ToolHandler = Base.extend({
|
||||||
case 'mousemove':
|
case 'mousemove':
|
||||||
while (this.updateEvent(type, pt, this.minDistance,
|
while (this.updateEvent(type, pt, this.minDistance,
|
||||||
this.maxDistance, this._firstMove, true, false)) {
|
this.maxDistance, this._firstMove, true, false)) {
|
||||||
if (this.onMouseMove) {
|
if (this.onMouseMove)
|
||||||
this.onMouseMove(new ToolEvent(this, type, event));
|
this.onMouseMove(new ToolEvent(this, type, event));
|
||||||
}
|
|
||||||
this._firstMove = false;
|
this._firstMove = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue