Fix #1032: Correctly handle lastPoint in first mousemove.

Improve first attempt of a fix in e054b760ed
This commit is contained in:
Jürg Lehni 2016-04-13 15:52:59 -07:00
parent e0a0cd58d5
commit 4f65996d34

View file

@ -303,16 +303,16 @@ var Tool = PaperScopeItem.extend(/** @lends Tool# */{
// is reached.
function update(minDistance, maxDistance) {
var pt = point,
// Set toolPoint to the previous point for moves or downPoint for
// clicks, so mouseup has a delta spanning over the full drag.
// Use the current point if this is the first mousedown, so
// there's always a delta.
toolPoint = (move ? tool._point : tool._downPoint) || pt;
// Set toolPoint to the previous point for moves or downPoint
// for clicks, so mouseup has a delta spanning over the full
// drag. Use the current point if this is the first mousedown,
// so there's always a delta.
toolPoint = move ? tool._point : (tool._downPoint || pt);
if (move) {
if (tool._moveCount && pt.equals(toolPoint)) {
return false;
}
if (minDistance != null || maxDistance != null) {
if (toolPoint && (minDistance != null || maxDistance != null)) {
var vector = pt.subtract(toolPoint),
distance = vector.getLength();
if (distance < (minDistance || 0))
@ -327,7 +327,7 @@ var Tool = PaperScopeItem.extend(/** @lends Tool# */{
tool._moveCount++;
}
tool._point = pt;
tool._lastPoint = toolPoint;
tool._lastPoint = toolPoint || pt;
if (mouse.down) {
tool._moveCount = -1;
tool._downPoint = pt;