@leafer/layout 1.0.0-alpha.23 → 1.0.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/LeafLayout.ts +25 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/layout",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.30",
|
|
4
4
|
"description": "@leafer/layout",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/math": "1.0.0-alpha.
|
|
22
|
+
"@leafer/math": "1.0.0-alpha.30"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@leafer/interface": "1.0.0-alpha.
|
|
25
|
+
"@leafer/interface": "1.0.0-alpha.30"
|
|
26
26
|
}
|
|
27
27
|
}
|
package/src/LeafLayout.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ILeaf, ILeafLayout, ILayoutLocationType, ILayoutBoundsType, IBoundsData, IMatrixData, IMatrixDecompositionData } from '@leafer/interface'
|
|
2
2
|
import { BoundsHelper, MatrixHelper } from '@leafer/math'
|
|
3
|
+
import { Platform } from '@leafer/platform'
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
const { toOuterOf } = BoundsHelper
|
|
@@ -26,6 +27,7 @@ export class LeafLayout implements ILeafLayout {
|
|
|
26
27
|
public localRenderBounds: IBoundsData
|
|
27
28
|
|
|
28
29
|
// world temp
|
|
30
|
+
protected _worldContentBounds: IBoundsData
|
|
29
31
|
protected _worldBoxBounds: IBoundsData
|
|
30
32
|
protected _worldStrokeBounds: IBoundsData
|
|
31
33
|
|
|
@@ -70,7 +72,7 @@ export class LeafLayout implements ILeafLayout {
|
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
|
|
73
|
-
public
|
|
75
|
+
public checkUpdate(): void {
|
|
74
76
|
const { leafer } = this.leaf
|
|
75
77
|
if (leafer) {
|
|
76
78
|
if (leafer.ready) {
|
|
@@ -79,30 +81,38 @@ export class LeafLayout implements ILeafLayout {
|
|
|
79
81
|
leafer.start()
|
|
80
82
|
leafer.layouter.layout()
|
|
81
83
|
}
|
|
84
|
+
} else {
|
|
85
|
+
let root = this.leaf
|
|
86
|
+
while (root.parent) { root = root.parent }
|
|
87
|
+
Platform.layout(root)
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
public getTransform(locationType: ILayoutLocationType): IMatrixData {
|
|
86
|
-
this.
|
|
92
|
+
this.checkUpdate()
|
|
87
93
|
return locationType === 'world' ? this.leaf.__world : this.leaf.__local
|
|
88
94
|
}
|
|
89
95
|
|
|
90
96
|
public getMatrixDecompositionData(locationType: ILayoutLocationType): IMatrixDecompositionData {
|
|
91
|
-
this.
|
|
97
|
+
this.checkUpdate()
|
|
92
98
|
return MatrixHelper.decompose(locationType === 'world' ? this.leaf.__world : this.leaf.__local)
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
public getBounds(type: ILayoutBoundsType, locationType: ILayoutLocationType): IBoundsData {
|
|
96
102
|
|
|
97
|
-
this.
|
|
103
|
+
this.checkUpdate()
|
|
98
104
|
|
|
99
105
|
if (locationType === 'world') {
|
|
100
106
|
|
|
101
107
|
switch (type) {
|
|
102
108
|
case 'render':
|
|
103
109
|
return this.leaf.__world
|
|
110
|
+
case 'content':
|
|
111
|
+
if (this.contentBounds) return this.getWorldContentBounds()
|
|
112
|
+
case 'margin':
|
|
104
113
|
case 'box':
|
|
105
114
|
return this.getWorldBoxBounds()
|
|
115
|
+
case 'margin':
|
|
106
116
|
case 'stroke':
|
|
107
117
|
return this.getWorldStrokeBounds()
|
|
108
118
|
}
|
|
@@ -112,6 +122,9 @@ export class LeafLayout implements ILeafLayout {
|
|
|
112
122
|
switch (type) {
|
|
113
123
|
case 'render':
|
|
114
124
|
return this.renderBounds
|
|
125
|
+
case 'content':
|
|
126
|
+
if (this.contentBounds) return this.contentBounds
|
|
127
|
+
case 'margin':
|
|
115
128
|
case 'box':
|
|
116
129
|
return this.boxBounds
|
|
117
130
|
case 'stroke':
|
|
@@ -123,6 +136,8 @@ export class LeafLayout implements ILeafLayout {
|
|
|
123
136
|
switch (type) {
|
|
124
137
|
case 'render':
|
|
125
138
|
return this.localRenderBounds
|
|
139
|
+
case 'margin':
|
|
140
|
+
case 'content':
|
|
126
141
|
case 'box':
|
|
127
142
|
return this.leaf.__local
|
|
128
143
|
case 'stroke':
|
|
@@ -131,9 +146,13 @@ export class LeafLayout implements ILeafLayout {
|
|
|
131
146
|
|
|
132
147
|
}
|
|
133
148
|
|
|
134
|
-
return this.leaf.__world
|
|
135
149
|
}
|
|
136
150
|
|
|
151
|
+
protected getWorldContentBounds(): IBoundsData {
|
|
152
|
+
this._worldContentBounds || (this._worldContentBounds = {} as IBoundsData)
|
|
153
|
+
toOuterOf(this.contentBounds, this.leaf.__world, this._worldContentBounds)
|
|
154
|
+
return this._worldContentBounds
|
|
155
|
+
}
|
|
137
156
|
|
|
138
157
|
protected getWorldBoxBounds(): IBoundsData {
|
|
139
158
|
this._worldBoxBounds || (this._worldBoxBounds = {} as IBoundsData)
|
|
@@ -190,6 +209,7 @@ export class LeafLayout implements ILeafLayout {
|
|
|
190
209
|
this.strokeBoundsChanged = true
|
|
191
210
|
this.strokeBoundsSpreadWidth || (this.strokeBoundsSpreadWidth = 1)
|
|
192
211
|
this.boundsChanged = true
|
|
212
|
+
this.hitCanvasChanged = true
|
|
193
213
|
}
|
|
194
214
|
|
|
195
215
|
public renderBoundsChange(): void {
|