diff --git a/packages/core/src/stack.mjs b/packages/core/src/stack.mjs index 277d8453194..2ee01e472a9 100644 --- a/packages/core/src/stack.mjs +++ b/packages/core/src/stack.mjs @@ -57,18 +57,21 @@ Stack.prototype.home = function () { for (const part of this.getPartList()) { part.__boundary() - const { tl, br } = utils.getTransformedBounds(part, part.attributes.getAsArray('transform')) + const { topLeft, bottomRight } = utils.getTransformedBounds( + part, + part.attributes.getAsArray('transform') + ) - if (!tl) { + if (!topLeft) { continue } // get the top left, the minimum x and y values of any corner - this.topLeft.x = Math.min(this.topLeft.x, tl.x) - this.topLeft.y = Math.min(this.topLeft.y, tl.y) + this.topLeft.x = Math.min(this.topLeft.x, topLeft.x) + this.topLeft.y = Math.min(this.topLeft.y, topLeft.y) // get the bottom right, the maximum x and y values of any corner - this.bottomRight.x = Math.max(this.bottomRight.x, br.x) - this.bottomRight.y = Math.max(this.bottomRight.y, br.y) + this.bottomRight.x = Math.max(this.bottomRight.x, bottomRight.x) + this.bottomRight.y = Math.max(this.bottomRight.y, bottomRight.y) } // Fix infinity if it's not overwritten diff --git a/packages/core/src/utils.mjs b/packages/core/src/utils.mjs index 5304f8070f2..170106df7a6 100644 --- a/packages/core/src/utils.mjs +++ b/packages/core/src/utils.mjs @@ -904,7 +904,7 @@ export function applyTransformToPoint(transform, point) { * Get the bounds of a given object after transforms have been applied * @param {Object} boundsObj any object with `topLeft` and `bottomRight` properties * @param {Boolean|String[]} transforms the transforms to apply to the bounds, structured as they would be for being applied as an svg attribute - * @return {Object} `tl` and `br` for the transformed bounds + * @return {Object} `topLeft` and `bottomRight` for the transformed bounds */ export function getTransformedBounds(boundsObj, transforms = false) { if (!boundsObj.topLeft) return {}