@leafer/display 1.0.0-beta.8 → 1.0.0-rc.1
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 +14 -10
- package/src/Branch.ts +29 -9
- package/src/Leaf.ts +118 -48
- package/types/index.d.ts +134 -0
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/display",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.1",
|
|
4
4
|
"description": "@leafer/display",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
8
9
|
"files": [
|
|
9
|
-
"src"
|
|
10
|
+
"src",
|
|
11
|
+
"types",
|
|
12
|
+
"dist"
|
|
10
13
|
],
|
|
11
14
|
"repository": {
|
|
12
15
|
"type": "git",
|
|
@@ -19,15 +22,16 @@
|
|
|
19
22
|
"leaferjs"
|
|
20
23
|
],
|
|
21
24
|
"dependencies": {
|
|
22
|
-
"@leafer/math": "1.0.0-
|
|
23
|
-
"@leafer/data": "1.0.0-
|
|
24
|
-
"@leafer/layout": "1.0.0-
|
|
25
|
-
"@leafer/display-module": "1.0.0-
|
|
26
|
-
"@leafer/event": "1.0.0-
|
|
27
|
-
"@leafer/decorator": "1.0.0-
|
|
28
|
-
"@leafer/helper": "1.0.0-
|
|
25
|
+
"@leafer/math": "1.0.0-rc.1",
|
|
26
|
+
"@leafer/data": "1.0.0-rc.1",
|
|
27
|
+
"@leafer/layout": "1.0.0-rc.1",
|
|
28
|
+
"@leafer/display-module": "1.0.0-rc.1",
|
|
29
|
+
"@leafer/event": "1.0.0-rc.1",
|
|
30
|
+
"@leafer/decorator": "1.0.0-rc.1",
|
|
31
|
+
"@leafer/helper": "1.0.0-rc.1",
|
|
32
|
+
"@leafer/platform": "1.0.0-rc.1"
|
|
29
33
|
},
|
|
30
34
|
"devDependencies": {
|
|
31
|
-
"@leafer/interface": "1.0.0-
|
|
35
|
+
"@leafer/interface": "1.0.0-rc.1"
|
|
32
36
|
}
|
|
33
37
|
}
|
package/src/Branch.ts
CHANGED
|
@@ -57,12 +57,15 @@ export class Branch extends Leaf {
|
|
|
57
57
|
// own
|
|
58
58
|
|
|
59
59
|
public __updateSortChildren(): void {
|
|
60
|
+
let affectSort: boolean
|
|
60
61
|
const { children } = this
|
|
61
62
|
if (children.length > 1) {
|
|
62
63
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
63
64
|
children[i].__tempNumber = i
|
|
65
|
+
if (children[i].__.zIndex) affectSort = true
|
|
64
66
|
}
|
|
65
67
|
children.sort(sort)
|
|
68
|
+
this.__layout.affectChildrenSort = affectSort
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
|
|
@@ -78,11 +81,17 @@ export class Branch extends Leaf {
|
|
|
78
81
|
|
|
79
82
|
if (this.leafer) {
|
|
80
83
|
child.__bindLeafer(this.leafer)
|
|
81
|
-
if (this.leafer.
|
|
84
|
+
if (this.leafer.created) this.__emitChildEvent(ChildEvent.ADD, child)
|
|
82
85
|
}
|
|
86
|
+
|
|
87
|
+
this.__layout.affectChildrenSort && this.__layout.childrenSortChange()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public addMany(...children: ILeaf[]): void {
|
|
91
|
+
children.forEach(child => this.add(child))
|
|
83
92
|
}
|
|
84
93
|
|
|
85
|
-
public remove(child?: Leaf): void {
|
|
94
|
+
public remove(child?: Leaf, destroy?: boolean): void {
|
|
86
95
|
if (child) {
|
|
87
96
|
const index = this.children.indexOf(child)
|
|
88
97
|
if (index > -1) {
|
|
@@ -90,31 +99,41 @@ export class Branch extends Leaf {
|
|
|
90
99
|
if (child.isBranch) this.__.__childBranchNumber = (this.__.__childBranchNumber || 1) - 1
|
|
91
100
|
this.__preRemove()
|
|
92
101
|
this.__realRemoveChild(child)
|
|
102
|
+
if (destroy) child.destroy()
|
|
93
103
|
}
|
|
94
104
|
} else if (child === undefined) {
|
|
95
|
-
super.remove()
|
|
105
|
+
super.remove(null, destroy)
|
|
96
106
|
}
|
|
97
107
|
}
|
|
98
108
|
|
|
99
|
-
public removeAll(): void {
|
|
109
|
+
public removeAll(destroy?: boolean): void {
|
|
100
110
|
const { children } = this
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
if (children.length) {
|
|
112
|
+
this.children = []
|
|
113
|
+
this.__preRemove()
|
|
114
|
+
this.__.__childBranchNumber = 0
|
|
115
|
+
children.forEach(child => {
|
|
116
|
+
this.__realRemoveChild(child)
|
|
117
|
+
if (destroy) child.destroy()
|
|
118
|
+
})
|
|
119
|
+
}
|
|
105
120
|
}
|
|
106
121
|
|
|
107
122
|
protected __preRemove(): void {
|
|
108
123
|
if (this.__hasMask) this.__updateMask()
|
|
109
124
|
if (this.__hasEraser) this.__updateEraser()
|
|
110
125
|
this.__layout.boxChange()
|
|
126
|
+
this.__layout.affectChildrenSort && this.__layout.childrenSortChange()
|
|
111
127
|
}
|
|
112
128
|
|
|
113
129
|
protected __realRemoveChild(child: ILeaf): void {
|
|
114
130
|
child.parent = null
|
|
115
131
|
if (this.leafer) {
|
|
116
132
|
child.__bindLeafer(null)
|
|
117
|
-
if (this.leafer.
|
|
133
|
+
if (this.leafer.created) {
|
|
134
|
+
this.__emitChildEvent(ChildEvent.REMOVE, child)
|
|
135
|
+
if (this.leafer.hitCanvasManager) this.leafer.hitCanvasManager.clear()
|
|
136
|
+
}
|
|
118
137
|
}
|
|
119
138
|
}
|
|
120
139
|
|
|
@@ -124,4 +143,5 @@ export class Branch extends Leaf {
|
|
|
124
143
|
if (this.hasEvent(type) && !this.isLeafer) this.emitEvent(event)
|
|
125
144
|
this.leafer.emitEvent(event)
|
|
126
145
|
}
|
|
146
|
+
|
|
127
147
|
}
|
package/src/Leaf.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILeafer, ILeaf, ILeafInputData, ILeafData, ILeaferCanvas, IRenderOptions, IMatrixWithBoundsData, __Number, __Boolean, __Value, ILeafLayout, InnerId, IHitCanvas, IRadiusPointData, IEventListenerMap, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IObject, IFunction, __String, IPointData, IMatrixDecompositionAttr, ILayoutBoundsType, ILayoutLocationType, IBoundsData,
|
|
1
|
+
import { ILeafer, ILeaf, ILeafInputData, ILeafData, ILeaferCanvas, IRenderOptions, IMatrixWithBoundsData, __Number, __Boolean, __Value, ILeafLayout, InnerId, IHitCanvas, IRadiusPointData, IEventListenerMap, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IObject, IFunction, __String, IPointData, IMatrixDecompositionAttr, ILayoutBoundsType, ILayoutLocationType, IBoundsData, IBranch, IMatrixWithLayoutData } from '@leafer/interface'
|
|
2
2
|
import { IncrementId, MatrixHelper, PointHelper } from '@leafer/math'
|
|
3
3
|
import { LeafData } from '@leafer/data'
|
|
4
4
|
import { LeafLayout } from '@leafer/layout'
|
|
@@ -8,6 +8,9 @@ import { LeafHelper, WaitHelper } from '@leafer/helper'
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
const { LEAF, create } = IncrementId
|
|
11
|
+
const { toInnerPoint, toOuterPoint } = MatrixHelper
|
|
12
|
+
const { tempToOuterOf, copy } = PointHelper
|
|
13
|
+
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal } = LeafHelper
|
|
11
14
|
|
|
12
15
|
@useModule(LeafDataProxy)
|
|
13
16
|
@useModule(LeafMatrix)
|
|
@@ -38,15 +41,17 @@ export class Leaf implements ILeaf {
|
|
|
38
41
|
public __: ILeafData
|
|
39
42
|
public __layout: ILeafLayout
|
|
40
43
|
|
|
44
|
+
public __world: IMatrixWithLayoutData
|
|
41
45
|
public __local: IMatrixWithBoundsData
|
|
42
|
-
|
|
46
|
+
|
|
43
47
|
public __worldOpacity: number
|
|
44
48
|
|
|
45
49
|
// now transform
|
|
46
|
-
public get worldTransform():
|
|
47
|
-
public get localTransform():
|
|
50
|
+
public get worldTransform(): IMatrixWithLayoutData { return this.__layout.getTransform('world') as IMatrixWithLayoutData }
|
|
51
|
+
public get localTransform(): IMatrixWithBoundsData { return this.__layout.getTransform('local') as IMatrixWithBoundsData }
|
|
48
52
|
|
|
49
53
|
// now bounds
|
|
54
|
+
public get boxBounds(): IBoundsData { return this.getBounds('box', 'inner') }
|
|
50
55
|
public get worldBoxBounds(): IBoundsData { return this.getBounds('box') }
|
|
51
56
|
public get worldStrokeBounds(): IBoundsData { return this.getBounds('stroke') }
|
|
52
57
|
public get worldRenderBounds(): IBoundsData { return this.getBounds('render') }
|
|
@@ -57,6 +62,10 @@ export class Leaf implements ILeaf {
|
|
|
57
62
|
public __level: number // layer level 0 -> branch -> branch -> deep
|
|
58
63
|
public __tempNumber: number // temp sort
|
|
59
64
|
|
|
65
|
+
public get resizeable(): boolean { return true }
|
|
66
|
+
|
|
67
|
+
public get __hasMirror(): boolean { return this.__world.scaleX < 0 || this.__world.scaleY < 0 }
|
|
68
|
+
|
|
60
69
|
public __hasMask?: boolean
|
|
61
70
|
public __hasEraser?: boolean
|
|
62
71
|
public __hitCanvas?: IHitCanvas
|
|
@@ -74,19 +83,29 @@ export class Leaf implements ILeaf {
|
|
|
74
83
|
// branch
|
|
75
84
|
public children?: ILeaf[]
|
|
76
85
|
|
|
86
|
+
|
|
87
|
+
public destroyed: boolean
|
|
88
|
+
|
|
89
|
+
|
|
77
90
|
constructor(data?: ILeafInputData) {
|
|
78
91
|
|
|
79
92
|
this.innerId = create(LEAF)
|
|
80
93
|
|
|
94
|
+
this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 }
|
|
81
95
|
this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 }
|
|
82
|
-
this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 }
|
|
83
96
|
|
|
84
97
|
this.__worldOpacity = 1
|
|
85
98
|
|
|
86
99
|
this.__ = new this.__DataProcessor(this)
|
|
87
100
|
this.__layout = new this.__LayoutProcessor(this)
|
|
88
101
|
|
|
89
|
-
if (data)
|
|
102
|
+
if (data) {
|
|
103
|
+
if (data.children) {
|
|
104
|
+
this.set(data)
|
|
105
|
+
} else {
|
|
106
|
+
Object.assign(this, data)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
90
109
|
}
|
|
91
110
|
|
|
92
111
|
|
|
@@ -98,14 +117,21 @@ export class Leaf implements ILeaf {
|
|
|
98
117
|
this.leafer ? item() : (this.__leaferWait ? this.__leaferWait.push(item) : this.__leaferWait = [item])
|
|
99
118
|
}
|
|
100
119
|
|
|
120
|
+
public nextRender(item: IFunction): void {
|
|
121
|
+
this.leafer ? this.leafer.nextRender(item) : this.waitLeafer(() => this.leafer.nextRender(item))
|
|
122
|
+
}
|
|
101
123
|
|
|
102
124
|
public __bindLeafer(leafer: ILeafer | null): void {
|
|
103
|
-
if (this.isLeafer)
|
|
125
|
+
if (this.isLeafer) {
|
|
126
|
+
if (leafer !== null) leafer = this as unknown as ILeafer
|
|
127
|
+
}
|
|
104
128
|
|
|
105
129
|
this.leafer = leafer
|
|
106
|
-
this.__level = this.parent ? this.parent.__level + 1 : 1
|
|
107
130
|
|
|
108
|
-
if (
|
|
131
|
+
if (leafer) {
|
|
132
|
+
this.__level = this.parent ? this.parent.__level + 1 : 1
|
|
133
|
+
if (this.__leaferWait) WaitHelper.run(this.__leaferWait)
|
|
134
|
+
}
|
|
109
135
|
|
|
110
136
|
if (this.isBranch) {
|
|
111
137
|
const { children } = this
|
|
@@ -115,10 +141,17 @@ export class Leaf implements ILeaf {
|
|
|
115
141
|
}
|
|
116
142
|
}
|
|
117
143
|
|
|
144
|
+
// data
|
|
145
|
+
|
|
118
146
|
public set(_data: IObject): void { }
|
|
119
147
|
|
|
120
|
-
public
|
|
148
|
+
public toJSON(): IObject {
|
|
149
|
+
return this.__.__getInputData()
|
|
150
|
+
}
|
|
121
151
|
|
|
152
|
+
public toString(): string {
|
|
153
|
+
return JSON.stringify(this.toJSON())
|
|
154
|
+
}
|
|
122
155
|
|
|
123
156
|
// LeafDataProxy rewrite
|
|
124
157
|
|
|
@@ -129,8 +162,10 @@ export class Leaf implements ILeaf {
|
|
|
129
162
|
// ---
|
|
130
163
|
|
|
131
164
|
public forceUpdate(attrName?: string): void {
|
|
132
|
-
if (
|
|
133
|
-
|
|
165
|
+
if (attrName === undefined) attrName = 'scaleX'
|
|
166
|
+
else if (attrName === 'surface') attrName = 'blendMode'
|
|
167
|
+
const value = this.__.__getInput(attrName)
|
|
168
|
+
this.__[attrName] = value === undefined ? null : undefined;
|
|
134
169
|
(this as any)[attrName] = value
|
|
135
170
|
}
|
|
136
171
|
|
|
@@ -163,6 +198,9 @@ export class Leaf implements ILeaf {
|
|
|
163
198
|
public __updateRenderBounds(): void { }
|
|
164
199
|
|
|
165
200
|
|
|
201
|
+
public __updateNaturalSize(): void { }
|
|
202
|
+
|
|
203
|
+
|
|
166
204
|
public __updateStrokeSpread(): number { return 0 }
|
|
167
205
|
|
|
168
206
|
public __updateRenderSpread(): number { return 0 }
|
|
@@ -188,7 +226,10 @@ export class Leaf implements ILeaf {
|
|
|
188
226
|
// convert
|
|
189
227
|
|
|
190
228
|
public getWorld(attrName: IMatrixDecompositionAttr): number {
|
|
191
|
-
|
|
229
|
+
this.__layout.checkUpdate()
|
|
230
|
+
if (attrName === 'x') return this.__world.e
|
|
231
|
+
if (attrName === 'y') return this.__world.f
|
|
232
|
+
return this.__world[attrName]
|
|
192
233
|
}
|
|
193
234
|
|
|
194
235
|
public getBounds(type: ILayoutBoundsType, locationType: ILayoutLocationType = 'world'): IBoundsData {
|
|
@@ -196,46 +237,86 @@ export class Leaf implements ILeaf {
|
|
|
196
237
|
}
|
|
197
238
|
|
|
198
239
|
|
|
199
|
-
public worldToLocal(world: IPointData, to?: IPointData,
|
|
240
|
+
public worldToLocal(world: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void {
|
|
200
241
|
if (this.parent) {
|
|
201
|
-
|
|
242
|
+
this.parent.worldToInner(world, to, distance, relative)
|
|
202
243
|
} else {
|
|
203
|
-
if (to)
|
|
244
|
+
if (to) copy(to, world)
|
|
204
245
|
}
|
|
205
246
|
}
|
|
206
247
|
|
|
207
|
-
public localToWorld(local: IPointData, to?: IPointData,
|
|
248
|
+
public localToWorld(local: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void {
|
|
208
249
|
if (this.parent) {
|
|
209
|
-
|
|
250
|
+
this.parent.innerToWorld(local, to, distance, relative)
|
|
210
251
|
} else {
|
|
211
|
-
if (to)
|
|
252
|
+
if (to) copy(to, local)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
public worldToInner(world: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void {
|
|
257
|
+
if (relative) {
|
|
258
|
+
relative.innerToWorld(world, to, distance)
|
|
259
|
+
world = to ? to : world
|
|
212
260
|
}
|
|
261
|
+
toInnerPoint(this.worldTransform, world, to, distance)
|
|
213
262
|
}
|
|
214
263
|
|
|
215
|
-
public
|
|
216
|
-
|
|
264
|
+
public innerToWorld(inner: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void {
|
|
265
|
+
toOuterPoint(this.worldTransform, inner, to, distance)
|
|
266
|
+
if (relative) relative.worldToInner(to ? to : inner, null, distance)
|
|
217
267
|
}
|
|
218
268
|
|
|
219
|
-
|
|
220
|
-
|
|
269
|
+
// simple
|
|
270
|
+
|
|
271
|
+
public getInnerPoint(world: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData {
|
|
272
|
+
const point = change ? world : {} as IPointData
|
|
273
|
+
this.worldToInner(world, point, distance, relative)
|
|
274
|
+
return point
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
public getInnerPointByLocal(local: IPointData, _relative?: ILeaf, distance?: boolean, change?: boolean): IPointData {
|
|
278
|
+
return this.getInnerPoint(local, this.parent, distance, change)
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
public getLocalPoint(world: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData {
|
|
282
|
+
const point = change ? world : {} as IPointData
|
|
283
|
+
this.worldToLocal(world, point, distance, relative)
|
|
284
|
+
return point
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
public getLocalPointByInner(inner: IPointData, _relative?: ILeaf, distance?: boolean, change?: boolean): IPointData {
|
|
288
|
+
return this.getWorldPoint(inner, this.parent, distance, change)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
public getWorldPoint(inner: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData {
|
|
292
|
+
const point = change ? inner : {} as IPointData
|
|
293
|
+
this.innerToWorld(inner, point, distance, relative)
|
|
294
|
+
return point
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
public getWorldPointByLocal(local: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData {
|
|
298
|
+
const point = change ? local : {} as IPointData
|
|
299
|
+
this.localToWorld(local, point, distance, relative)
|
|
300
|
+
return point
|
|
221
301
|
}
|
|
222
302
|
|
|
223
303
|
|
|
224
304
|
// transform
|
|
225
305
|
|
|
226
306
|
public move(x: number, y?: number): void {
|
|
227
|
-
|
|
307
|
+
moveLocal(this, x, y)
|
|
228
308
|
}
|
|
229
309
|
|
|
230
310
|
public scaleOf(origin: IPointData, x: number, y?: number): void {
|
|
231
|
-
this.
|
|
232
|
-
if (y === undefined) y = x
|
|
233
|
-
LeafHelper.zoomOfLocal(this, PointHelper.tempToOuterOf(origin, this.__local), x, y)
|
|
311
|
+
zoomOfLocal(this, tempToOuterOf(origin, this.localTransform), x, y)
|
|
234
312
|
}
|
|
235
313
|
|
|
236
314
|
public rotateOf(origin: IPointData, angle: number): void {
|
|
237
|
-
this.
|
|
238
|
-
|
|
315
|
+
rotateOfLocal(this, tempToOuterOf(origin, this.localTransform), angle)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
public skewOf(origin: IPointData, x: number, y: number): void {
|
|
319
|
+
skewOfLocal(this, tempToOuterOf(origin, this.localTransform), x, y)
|
|
239
320
|
}
|
|
240
321
|
|
|
241
322
|
|
|
@@ -287,8 +368,8 @@ export class Leaf implements ILeaf {
|
|
|
287
368
|
|
|
288
369
|
public add(_child: ILeaf, _index?: number): void { }
|
|
289
370
|
|
|
290
|
-
public remove(_child?: ILeaf): void {
|
|
291
|
-
if (this.parent) this.parent.remove(this)
|
|
371
|
+
public remove(_child?: ILeaf, destroy?: boolean): void {
|
|
372
|
+
if (this.parent) this.parent.remove(this, destroy)
|
|
292
373
|
}
|
|
293
374
|
|
|
294
375
|
// ---
|
|
@@ -314,28 +395,17 @@ export class Leaf implements ILeaf {
|
|
|
314
395
|
|
|
315
396
|
// ---
|
|
316
397
|
|
|
317
|
-
public destroy(): void {
|
|
318
|
-
if (this.__) {
|
|
319
|
-
if (this.__hitCanvas) {
|
|
320
|
-
this.__hitCanvas.destroy()
|
|
321
|
-
this.__hitCanvas = null
|
|
322
|
-
}
|
|
323
398
|
|
|
324
|
-
|
|
325
|
-
|
|
399
|
+
public destroy(): void {
|
|
400
|
+
if (!this.destroyed) {
|
|
401
|
+
if (this.parent) this.remove()
|
|
402
|
+
if (this.children) (this as unknown as IBranch).removeAll(true)
|
|
326
403
|
|
|
327
404
|
this.__.destroy()
|
|
328
405
|
this.__layout.destroy()
|
|
329
|
-
this.__ = null
|
|
330
|
-
this.__layout = null
|
|
331
406
|
|
|
332
|
-
this.__captureMap = null
|
|
333
|
-
this.
|
|
334
|
-
|
|
335
|
-
if (this.children) {
|
|
336
|
-
this.children.forEach(child => { child.destroy() })
|
|
337
|
-
this.children.length = 0
|
|
338
|
-
}
|
|
407
|
+
this.__captureMap = this.__bubbleMap = this.__parentWait = this.__leaferWait = null
|
|
408
|
+
this.destroyed = true
|
|
339
409
|
}
|
|
340
410
|
}
|
|
341
411
|
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { ILeaf, InnerId, ILeafer, ILeafData, ILeafLayout, IMatrixWithLayoutData, IMatrixWithBoundsData, IBoundsData, IHitCanvas, IEventListenerMap, IFunction, ILeafInputData, IObject, __Value, ILeaferCanvas, IMatrixDecompositionAttr, ILayoutBoundsType, ILayoutLocationType, IPointData, IRadiusPointData, IRenderOptions, IEventListener, IEventListenerOptions, IEventListenerId, IEvent } from '@leafer/interface';
|
|
2
|
+
import { LeafData } from '@leafer/data';
|
|
3
|
+
import { LeafLayout } from '@leafer/layout';
|
|
4
|
+
|
|
5
|
+
declare class Leaf implements ILeaf {
|
|
6
|
+
get tag(): string;
|
|
7
|
+
set tag(_value: string);
|
|
8
|
+
get __tag(): string;
|
|
9
|
+
readonly innerId: InnerId;
|
|
10
|
+
get innerName(): string;
|
|
11
|
+
get __DataProcessor(): typeof LeafData;
|
|
12
|
+
get __LayoutProcessor(): typeof LeafLayout;
|
|
13
|
+
leafer?: ILeafer;
|
|
14
|
+
parent?: ILeaf;
|
|
15
|
+
isLeafer: boolean;
|
|
16
|
+
isBranch: boolean;
|
|
17
|
+
isBranchLeaf: boolean;
|
|
18
|
+
__: ILeafData;
|
|
19
|
+
__layout: ILeafLayout;
|
|
20
|
+
__world: IMatrixWithLayoutData;
|
|
21
|
+
__local: IMatrixWithBoundsData;
|
|
22
|
+
__worldOpacity: number;
|
|
23
|
+
get worldTransform(): IMatrixWithLayoutData;
|
|
24
|
+
get localTransform(): IMatrixWithBoundsData;
|
|
25
|
+
get boxBounds(): IBoundsData;
|
|
26
|
+
get worldBoxBounds(): IBoundsData;
|
|
27
|
+
get worldStrokeBounds(): IBoundsData;
|
|
28
|
+
get worldRenderBounds(): IBoundsData;
|
|
29
|
+
get worldOpacity(): number;
|
|
30
|
+
__level: number;
|
|
31
|
+
__tempNumber: number;
|
|
32
|
+
get resizeable(): boolean;
|
|
33
|
+
get __hasMirror(): boolean;
|
|
34
|
+
__hasMask?: boolean;
|
|
35
|
+
__hasEraser?: boolean;
|
|
36
|
+
__hitCanvas?: IHitCanvas;
|
|
37
|
+
get __onlyHitMask(): boolean;
|
|
38
|
+
get __ignoreHitWorld(): boolean;
|
|
39
|
+
__captureMap?: IEventListenerMap;
|
|
40
|
+
__bubbleMap?: IEventListenerMap;
|
|
41
|
+
__parentWait?: IFunction[];
|
|
42
|
+
__leaferWait?: IFunction[];
|
|
43
|
+
children?: ILeaf[];
|
|
44
|
+
destroyed: boolean;
|
|
45
|
+
constructor(data?: ILeafInputData);
|
|
46
|
+
waitParent(item: IFunction): void;
|
|
47
|
+
waitLeafer(item: IFunction): void;
|
|
48
|
+
nextRender(item: IFunction): void;
|
|
49
|
+
__bindLeafer(leafer: ILeafer | null): void;
|
|
50
|
+
set(_data: IObject): void;
|
|
51
|
+
toJSON(): IObject;
|
|
52
|
+
toString(): string;
|
|
53
|
+
__setAttr(_attrName: string, _newValue: __Value): void;
|
|
54
|
+
__getAttr(_attrName: string): __Value;
|
|
55
|
+
forceUpdate(attrName?: string): void;
|
|
56
|
+
__updateWorldMatrix(): void;
|
|
57
|
+
__updateLocalMatrix(): void;
|
|
58
|
+
__updateWorldBounds(): void;
|
|
59
|
+
__updateLocalBoxBounds(): void;
|
|
60
|
+
__updateLocalStrokeBounds(): void;
|
|
61
|
+
__updateLocalRenderBounds(): void;
|
|
62
|
+
__updateBoxBounds(): void;
|
|
63
|
+
__updateStrokeBounds(): void;
|
|
64
|
+
__updateRenderBounds(): void;
|
|
65
|
+
__updateNaturalSize(): void;
|
|
66
|
+
__updateStrokeSpread(): number;
|
|
67
|
+
__updateRenderSpread(): number;
|
|
68
|
+
__onUpdateSize(): void;
|
|
69
|
+
__updateEraser(_value?: boolean): void;
|
|
70
|
+
__updateMask(_value?: boolean): void;
|
|
71
|
+
__renderMask(_canvas: ILeaferCanvas, _content: ILeaferCanvas, _mask: ILeaferCanvas): void;
|
|
72
|
+
__removeMask(_child?: ILeaf): void;
|
|
73
|
+
getWorld(attrName: IMatrixDecompositionAttr): number;
|
|
74
|
+
getBounds(type: ILayoutBoundsType, locationType?: ILayoutLocationType): IBoundsData;
|
|
75
|
+
worldToLocal(world: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
|
|
76
|
+
localToWorld(local: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
|
|
77
|
+
worldToInner(world: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
|
|
78
|
+
innerToWorld(inner: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
|
|
79
|
+
getInnerPoint(world: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
|
|
80
|
+
getInnerPointByLocal(local: IPointData, _relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
|
|
81
|
+
getLocalPoint(world: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
|
|
82
|
+
getLocalPointByInner(inner: IPointData, _relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
|
|
83
|
+
getWorldPoint(inner: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
|
|
84
|
+
getWorldPointByLocal(local: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
|
|
85
|
+
move(x: number, y?: number): void;
|
|
86
|
+
scaleOf(origin: IPointData, x: number, y?: number): void;
|
|
87
|
+
rotateOf(origin: IPointData, angle: number): void;
|
|
88
|
+
skewOf(origin: IPointData, x: number, y: number): void;
|
|
89
|
+
__hitWorld(_point: IRadiusPointData): boolean;
|
|
90
|
+
__hit(_local: IRadiusPointData): boolean;
|
|
91
|
+
__drawHitPath(_canvas: ILeaferCanvas): void;
|
|
92
|
+
__updateHitCanvas(): void;
|
|
93
|
+
__render(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
|
|
94
|
+
__drawFast(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
|
|
95
|
+
__draw(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
|
|
96
|
+
__renderShape(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
|
|
97
|
+
__updateWorldOpacity(): void;
|
|
98
|
+
__updateChange(): void;
|
|
99
|
+
__drawPath(_canvas: ILeaferCanvas): void;
|
|
100
|
+
__drawRenderPath(_canvas: ILeaferCanvas): void;
|
|
101
|
+
__updatePath(): void;
|
|
102
|
+
__updateRenderPath(): void;
|
|
103
|
+
__updateSortChildren(): void;
|
|
104
|
+
add(_child: ILeaf, _index?: number): void;
|
|
105
|
+
remove(_child?: ILeaf, destroy?: boolean): void;
|
|
106
|
+
on(_type: string | string[], _listener: IEventListener, _options?: IEventListenerOptions | boolean): void;
|
|
107
|
+
off(_type: string | string[], _listener: IEventListener, _options?: IEventListenerOptions | boolean): void;
|
|
108
|
+
on_(_type: string | string[], _listener: IEventListener, _bind?: IObject, _options?: IEventListenerOptions | boolean): IEventListenerId;
|
|
109
|
+
off_(_id: IEventListenerId | IEventListenerId[]): void;
|
|
110
|
+
once(_type: string | string[], _listener: IEventListener, _capture?: boolean): void;
|
|
111
|
+
emit(_type: string, _event?: IEvent | IObject, _capture?: boolean): void;
|
|
112
|
+
emitEvent(_event?: IEvent, _capture?: boolean): void;
|
|
113
|
+
hasEvent(_type: string, _capture?: boolean): boolean;
|
|
114
|
+
destroy(): void;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
declare class Branch extends Leaf {
|
|
118
|
+
constructor();
|
|
119
|
+
__updateStrokeSpread(): number;
|
|
120
|
+
__updateRenderSpread(): number;
|
|
121
|
+
__updateBoxBounds(): void;
|
|
122
|
+
__updateStrokeBounds(): void;
|
|
123
|
+
__updateRenderBounds(): void;
|
|
124
|
+
__updateSortChildren(): void;
|
|
125
|
+
add(child: ILeaf, index?: number): void;
|
|
126
|
+
addMany(...children: ILeaf[]): void;
|
|
127
|
+
remove(child?: Leaf, destroy?: boolean): void;
|
|
128
|
+
removeAll(destroy?: boolean): void;
|
|
129
|
+
protected __preRemove(): void;
|
|
130
|
+
protected __realRemoveChild(child: ILeaf): void;
|
|
131
|
+
protected __emitChildEvent(type: string, child: ILeaf): void;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { Branch, Leaf };
|