Make hit-test tolerance dependent of view#matrix

This commit is contained in:
Jürg Lehni 2013-12-10 22:53:03 +01:00
parent 68bce5b062
commit 9501fd1924
3 changed files with 7 additions and 7 deletions

View file

@ -135,9 +135,6 @@ var HitResult = Base.extend(/** @lends HitResult# */{
guides: false,
// Only hit selected objects
selected: false,
// Used to calculate total concatenated matrices, to determine
// correcet tolerance padding.
_totalMatrix: new Matrix(),
// Mark as merged
_merged: true
}, options);

View file

@ -1609,7 +1609,6 @@ var Item = Base.extend(Callback, /** @lends Item# */{
hitTest: function(point, options) {
point = Point.read(arguments);
options = HitResult.getOptions(Base.read(arguments));
if (this._locked || !this._visible || this._guide && !options.guides)
return null;
@ -1620,8 +1619,12 @@ var Item = Base.extend(Callback, /** @lends Item# */{
parentTotalMatrix = options._totalMatrix,
// Keep the accumulated matrices up to this item in options, so we
// can keep calculating the correct _tolerancePadding values.
totalMatrix = options._totalMatrix = parentTotalMatrix.clone()
.concatenate(matrix),
totalMatrix = options._totalMatrix = parentTotalMatrix
? parentTotalMatrix.clone().concatenate(matrix)
// If this is the first one in the recursion, factor in the
// zoom of the view and the globalMatrix of the item.
: this._project.view._matrix.clone().concatenate(
this.getGlobalMatrix()),
// Calculate the transformed padding as 2D size that describes the
// transformed tolerance circle / ellipse. Make sure it's never 0
// since we're using it for division.

View file

@ -455,7 +455,7 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|| item.getLayer().getSelectedColor();
ctx.strokeStyle = ctx.fillStyle = color
? color.toCanvasStyle(ctx) : '#009dec';
var mx = item._globalMatrix.clone().preConcatenate(matrix);
var mx = matrix.clone().concatenate(item._globalMatrix);
if (item._drawSelected)
item._drawSelected(ctx, mx);
if (item._boundsSelected) {