From 6797d2eb116bb8ecb3b01d6d335cff0564852220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 11 Feb 2016 12:51:04 +0100 Subject: [PATCH] Respect clip-items in Group#_getBounds() Closes #956 --- src/item/Group.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/item/Group.js b/src/item/Group.js index 3e05198f..9281bd34 100644 --- a/src/item/Group.js +++ b/src/item/Group.js @@ -167,6 +167,23 @@ var Group = Item.extend(/** @lends Group# */{ child.setClipMask(clipped); }, + _getBounds: function _getBounds(getter, matrix, cacheItem, internal) { + var clipItem = this._getClipItem(), + // We need to fall-back to bounds getter that do not take stroke + // into account + clipBoundsGetter = { + getStrokeBounds: 'getBounds', + getRoughBounds: 'getHandleBounds', + getInternalRoughBounds: 'getInternalBounds' + }; + return clipItem + ? clipItem._getCachedBounds(clipBoundsGetter[getter] || getter, + matrix && matrix.appended(clipItem._matrix), + cacheItem, internal) + : _getBounds.base.call(this, getter, matrix, cacheItem, + internal); + }, + _hitTestChildren: function _hitTestChildren(point, options) { var clipItem = this._getClipItem(); return (!clipItem || clipItem.contains(point))