mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Make hit-test tolerance dependent of view#matrix
This commit is contained in:
parent
68bce5b062
commit
9501fd1924
3 changed files with 7 additions and 7 deletions
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue