@leafer/layout
Advanced tools
+3
-3
| { | ||
| "name": "@leafer/layout", | ||
| "version": "1.0.0-alpha.23", | ||
| "version": "1.0.0-alpha.30", | ||
| "description": "@leafer/layout", | ||
@@ -22,7 +22,7 @@ "author": "Chao (Leafer) Wan", | ||
| "dependencies": { | ||
| "@leafer/math": "1.0.0-alpha.23" | ||
| "@leafer/math": "1.0.0-alpha.30" | ||
| }, | ||
| "devDependencies": { | ||
| "@leafer/interface": "1.0.0-alpha.23" | ||
| "@leafer/interface": "1.0.0-alpha.30" | ||
| } | ||
| } |
+25
-5
| import { ILeaf, ILeafLayout, ILayoutLocationType, ILayoutBoundsType, IBoundsData, IMatrixData, IMatrixDecompositionData } from '@leafer/interface' | ||
| import { BoundsHelper, MatrixHelper } from '@leafer/math' | ||
| import { Platform } from '@leafer/platform' | ||
@@ -29,2 +30,3 @@ | ||
| // world temp | ||
| protected _worldContentBounds: IBoundsData | ||
| protected _worldBoxBounds: IBoundsData | ||
@@ -74,3 +76,3 @@ protected _worldStrokeBounds: IBoundsData | ||
| public update(): void { | ||
| public checkUpdate(): void { | ||
| const { leafer } = this.leaf | ||
@@ -84,2 +86,6 @@ if (leafer) { | ||
| } | ||
| } else { | ||
| let root = this.leaf | ||
| while (root.parent) { root = root.parent } | ||
| Platform.layout(root) | ||
| } | ||
@@ -89,3 +95,3 @@ } | ||
| public getTransform(locationType: ILayoutLocationType): IMatrixData { | ||
| this.update() | ||
| this.checkUpdate() | ||
| return locationType === 'world' ? this.leaf.__world : this.leaf.__local | ||
@@ -95,3 +101,3 @@ } | ||
| public getMatrixDecompositionData(locationType: ILayoutLocationType): IMatrixDecompositionData { | ||
| this.update() | ||
| this.checkUpdate() | ||
| return MatrixHelper.decompose(locationType === 'world' ? this.leaf.__world : this.leaf.__local) | ||
@@ -102,3 +108,3 @@ } | ||
| this.update() | ||
| this.checkUpdate() | ||
@@ -110,4 +116,8 @@ if (locationType === 'world') { | ||
| return this.leaf.__world | ||
| case 'content': | ||
| if (this.contentBounds) return this.getWorldContentBounds() | ||
| case 'margin': | ||
| case 'box': | ||
| return this.getWorldBoxBounds() | ||
| case 'margin': | ||
| case 'stroke': | ||
@@ -122,2 +132,5 @@ return this.getWorldStrokeBounds() | ||
| return this.renderBounds | ||
| case 'content': | ||
| if (this.contentBounds) return this.contentBounds | ||
| case 'margin': | ||
| case 'box': | ||
@@ -134,2 +147,4 @@ return this.boxBounds | ||
| return this.localRenderBounds | ||
| case 'margin': | ||
| case 'content': | ||
| case 'box': | ||
@@ -143,5 +158,9 @@ return this.leaf.__local | ||
| return this.leaf.__world | ||
| } | ||
| protected getWorldContentBounds(): IBoundsData { | ||
| this._worldContentBounds || (this._worldContentBounds = {} as IBoundsData) | ||
| toOuterOf(this.contentBounds, this.leaf.__world, this._worldContentBounds) | ||
| return this._worldContentBounds | ||
| } | ||
@@ -203,2 +222,3 @@ protected getWorldBoxBounds(): IBoundsData { | ||
| this.boundsChanged = true | ||
| this.hitCanvasChanged = true | ||
| } | ||
@@ -205,0 +225,0 @@ |
9409
10.43%203
10.93%+ Added
- Removed
Updated