Fix issue with hit-testing of translated rasters and other items.

Use the untransformed point in the initial bounds check. Closes #45, #86.
This commit is contained in:
Jürg Lehni 2012-10-20 16:54:39 -04:00
parent 317fcf5432
commit 63640cad03

View file

@ -1049,13 +1049,15 @@ function(name) {
*/ */
hitTest: function(point, options) { hitTest: function(point, options) {
options = HitResult.getOptions(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 // 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 // this item does not have children, since we'd have to travel up the
// chain already to determine the rough bounds. // chain already to determine the rough bounds.
if (!this._children && !this.getRoughBounds() if (!this._children && !this.getRoughBounds()
.expand(options.tolerance)._containsPoint(point)) .expand(options.tolerance)._containsPoint(options.point))
return null; 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) && if ((options.center || options.bounds) &&
// Ignore top level layers: // Ignore top level layers:
!(this instanceof Layer && !this._parent)) { !(this instanceof Layer && !this._parent)) {