From e3c298d3f4602d0fffc652ababd45ed846da90d7 Mon Sep 17 00:00:00 2001 From: sasensi Date: Wed, 17 Oct 2018 10:11:35 +0200 Subject: [PATCH] Fix ignoring of clip item matrix in group internal bounds Closes #1427 --- src/item/Group.js | 2 +- test/tests/Group.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/item/Group.js b/src/item/Group.js index fd5083c0..8c66210d 100644 --- a/src/item/Group.js +++ b/src/item/Group.js @@ -172,7 +172,7 @@ var Group = Item.extend(/** @lends Group# */{ var clipItem = this._getClipItem(); return clipItem ? clipItem._getCachedBounds( - matrix && matrix.appended(clipItem._matrix), + matrix && matrix.appended(clipItem._matrix) || clipItem._matrix, Base.set({}, options, { stroke: false })) : _getBounds.base.call(this, matrix, options); }, diff --git a/test/tests/Group.js b/test/tests/Group.js index 17c59d06..5ade1da8 100644 --- a/test/tests/Group.js +++ b/test/tests/Group.js @@ -166,3 +166,16 @@ test('Group#isEmpty(recursively)', function() { equals(false, group.isEmpty()); equals(true, group.isEmpty(true)); }); + +test('group.getInternalBounds() with clip item without matrix applied', function() { + var point = new Point(100, 100); + var translation = new Point(100, 100); + var item = new Path.Circle({ center: point, radius: 50, fillColor: 'orange' }); + var clip = new Path.Rectangle({ from: point.subtract(translation), to: point.add(translation) }); + clip.applyMatrix = false; + clip.translate(translation); + var group = new Group(clip, item); + group.clipped = true; + + equals(group.getInternalBounds(), new Rectangle(point, point.add(translation.multiply(2)))); +});