diff --git a/src/item/Item.js b/src/item/Item.js index b14a3ed6..6faa9910 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1404,18 +1404,17 @@ var Item = Base.extend(Callback, /** @lends Item# */{ !(this instanceof Layer && !this._parent)) { // Don't get the transformed bounds, check against transformed // points instead - var bounds = this.getBounds(); - if (options.center && (res = checkBounds('center', 'Center'))) - return res; - if (options.bounds) { + var bounds = this._getBounds('getBounds'); + if (options.center) + res = checkBounds('center', 'Center'); + if (!res && options.bounds) { // TODO: Move these into a private scope var points = [ 'TopLeft', 'TopRight', 'BottomLeft', 'BottomRight', 'LeftCenter', 'TopCenter', 'RightCenter', 'BottomCenter' ]; - for (var i = 0; i < 8; i++) - if (res = checkBounds('bounds', points[i])) - return res; + for (var i = 0; i < 8 && !res; i++) + res = checkBounds('bounds', points[i]); } } @@ -1423,9 +1422,14 @@ var Item = Base.extend(Callback, /** @lends Item# */{ // children are matched but the parent is returned. // Filter for guides or selected items if that's required - return this._children || !(options.guides && !this._guide + if ((res || (res = this._children || !(options.guides && !this._guide || options.selected && !this._selected) - ? this._hitTest(point, options) : null; + ? this._hitTest(point, options) : null)) + && res.point) { + // Transform the point back to the outer coordinate system. + res.point = that._matrix.transform(res.point); + } + return res; }, _hitTest: function(point, options) { diff --git a/src/path/Path.js b/src/path/Path.js index 451d5828..95c325e0 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -1656,8 +1656,6 @@ var Path = PathItem.extend(/** @lends Path# */{ } function checkPoint(seg, pt, name) { - // TODO: We need to transform the point back to the coordinate - // system of the DOM level on which the inquiry was started! if (point.getDistance(pt) < tolerance) return new HitResult(name, that, { segment: seg, point: pt }); }