From 083a09604dc49629ec5a3d4fecfc5393a14d96c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 9 Mar 2017 12:42:11 +0100 Subject: [PATCH] Hit-Tests: Fix issue with non-invertible matrices. Closes #1271 --- src/item/Item.js | 4 ++-- test/tests/HitResult.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index ee574862..8253b736 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1901,7 +1901,7 @@ new function() { // Injection scope for hit-test functions shared with project // need to apply the inverted item matrix. tolerancePadding = options._tolerancePadding = new Size( Path._getStrokePadding(tolerance, - matrix.inverted()._shiftless())); + matrix._shiftless().invert())); // Transform point to local coordinates. point = matrix._inverseTransform(point); // If the matrix is non-reversible, point will now be `null`: @@ -1980,7 +1980,7 @@ new function() { // Injection scope for hit-test functions shared with project // If the item has a non-scaling stroke, we need to // apply the inverted viewMatrix to stroke dimensions. this.getStrokeScaling() ? null - : viewMatrix.inverted()._shiftless())) + : viewMatrix._shiftless().invert())) || null; } // Transform the point back to the outer coordinate system. diff --git a/test/tests/HitResult.js b/test/tests/HitResult.js index cda735ac..5ca489f7 100644 --- a/test/tests/HitResult.js +++ b/test/tests/HitResult.js @@ -854,4 +854,18 @@ test('hit-testing scaled items with different settings of view.zoom and item.str testItem(Path, 2, true); }); +test('hit-testing items scaled to 0', function() { + var item = new Shape.Rectangle({ + point: [0, 0], + size: [100, 100], + fillColor: 'red', + selected: true + }); + + item.scale(0); + + testHitResult(project.hitTest(item.position), null, + 'should not throw an exception.'); +}); + // TODO: project.hitTest(point, {type: AnItemType});