From 63640cad0301c2cc6b2d5e33fc2b55b1d97141d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 20 Oct 2012 16:54:39 -0400 Subject: [PATCH] Fix issue with hit-testing of translated rasters and other items. Use the untransformed point in the initial bounds check. Closes #45, #86. --- src/item/Item.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index 508caaf1..8ae693bb 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1049,13 +1049,15 @@ function(name) { */ hitTest: function(point, options) { options = HitResult.getOptions(point, options); - point = options.point = this._matrix._inverseTransform(options.point); // Check if the point is withing roughBounds + tolerance, but only if // this item does not have children, since we'd have to travel up the // chain already to determine the rough bounds. if (!this._children && !this.getRoughBounds() - .expand(options.tolerance)._containsPoint(point)) + .expand(options.tolerance)._containsPoint(options.point)) return null; + // Transform point to local coordinates but use untransformed point + // for bounds check above. + point = options.point = this._matrix._inverseTransform(options.point); if ((options.center || options.bounds) && // Ignore top level layers: !(this instanceof Layer && !this._parent)) {