fix(core): Left-over use of tl and br
This commit is contained in:
parent
bce6224167
commit
e7292ee2e4
2 changed files with 10 additions and 7 deletions
|
@ -57,18 +57,21 @@ Stack.prototype.home = function () {
|
||||||
for (const part of this.getPartList()) {
|
for (const part of this.getPartList()) {
|
||||||
part.__boundary()
|
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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the top left, the minimum x and y values of any corner
|
// 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.x = Math.min(this.topLeft.x, topLeft.x)
|
||||||
this.topLeft.y = Math.min(this.topLeft.y, tl.y)
|
this.topLeft.y = Math.min(this.topLeft.y, topLeft.y)
|
||||||
// get the bottom right, the maximum x and y values of any corner
|
// 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.x = Math.max(this.bottomRight.x, bottomRight.x)
|
||||||
this.bottomRight.y = Math.max(this.bottomRight.y, br.y)
|
this.bottomRight.y = Math.max(this.bottomRight.y, bottomRight.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix infinity if it's not overwritten
|
// Fix infinity if it's not overwritten
|
||||||
|
|
|
@ -904,7 +904,7 @@ export function applyTransformToPoint(transform, point) {
|
||||||
* Get the bounds of a given object after transforms have been applied
|
* Get the bounds of a given object after transforms have been applied
|
||||||
* @param {Object} boundsObj any object with `topLeft` and `bottomRight` properties
|
* @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
|
* @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) {
|
export function getTransformedBounds(boundsObj, transforms = false) {
|
||||||
if (!boundsObj.topLeft) return {}
|
if (!boundsObj.topLeft) return {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue