1
0
Fork 0

fix(core): Left-over use of tl and br

This commit is contained in:
joostdecock 2023-10-21 17:45:35 +02:00
parent bce6224167
commit e7292ee2e4
2 changed files with 10 additions and 7 deletions

View file

@ -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

View file

@ -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 {}