mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-04 03:45:58 -05:00
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:
parent
317fcf5432
commit
63640cad03
1 changed files with 4 additions and 2 deletions
|
@ -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)) {
|
||||
|
|
Loading…
Reference in a new issue