[vercel skip] chore (core) document and test Stack.home
This commit is contained in:
parent
444d82c527
commit
042d4e71a9
2 changed files with 58 additions and 14 deletions
|
@ -52,30 +52,27 @@ Stack.prototype.home = function () {
|
|||
for (const part of this.getPartList()) {
|
||||
part.__boundary()
|
||||
|
||||
const transforms = part.attributes.get('transform')
|
||||
// get all corners of the part's bounds
|
||||
let tl = part.topLeft || this.topLeft
|
||||
let br = part.bottomRight || this.bottomRight
|
||||
let tr = new Point(br.x, tl.y)
|
||||
let bl = new Point(tl.x, br.y)
|
||||
|
||||
// if there are transforms on the part, apply them to the corners so that we have the correct bounds
|
||||
const transforms = part.attributes.getAsArray('transform')
|
||||
if (transforms) {
|
||||
const combinedTransform =
|
||||
typeof transforms === 'string' ? transforms : utils.combineTransforms(transforms)
|
||||
const combinedTransform = utils.combineTransforms(transforms)
|
||||
|
||||
tl = utils.applyTransformToPoint(combinedTransform, part.topLeft.copy())
|
||||
br = utils.applyTransformToPoint(combinedTransform, part.bottomRight.copy())
|
||||
bl = utils.applyTransformToPoint(
|
||||
combinedTransform,
|
||||
new Point(part.topLeft.x, part.bottomRight.y)
|
||||
)
|
||||
tr = utils.applyTransformToPoint(
|
||||
combinedTransform,
|
||||
new Point(part.bottomRight.x, part.topLeft.y)
|
||||
)
|
||||
tl = utils.applyTransformToPoint(combinedTransform, tl.copy())
|
||||
br = utils.applyTransformToPoint(combinedTransform, br.copy())
|
||||
tr = utils.applyTransformToPoint(combinedTransform, tr.copy())
|
||||
bl = utils.applyTransformToPoint(combinedTransform, bl.copy())
|
||||
}
|
||||
|
||||
// get the top left, the minimum x and y values of any corner
|
||||
this.topLeft.x = Math.min(this.topLeft.x, tl.x, br.x, bl.x, tr.x)
|
||||
this.topLeft.y = Math.min(this.topLeft.y, tl.y, br.y, bl.y, tr.y)
|
||||
// get the bottom right, the maximum x and y values of any corner
|
||||
this.bottomRight.x = Math.max(this.bottomRight.x, tl.x, br.x, bl.x, tr.x)
|
||||
this.bottomRight.y = Math.max(this.bottomRight.y, tl.y, br.y, bl.y, tr.y)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue