@leafer/display 1.0.0-alpha.9 → 1.0.0-beta

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.
Files changed (3) hide show
  1. package/package.json +9 -9
  2. package/src/Branch.ts +90 -41
  3. package/src/Leaf.ts +130 -76
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/display",
3
- "version": "1.0.0-alpha.9",
3
+ "version": "1.0.0-beta",
4
4
  "description": "@leafer/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -19,15 +19,15 @@
19
19
  "leaferjs"
20
20
  ],
21
21
  "dependencies": {
22
- "@leafer/math": "1.0.0-alpha.9",
23
- "@leafer/data": "1.0.0-alpha.9",
24
- "@leafer/layout": "1.0.0-alpha.9",
25
- "@leafer/display-module": "1.0.0-alpha.9",
26
- "@leafer/event": "1.0.0-alpha.9",
27
- "@leafer/decorator": "1.0.0-alpha.9",
28
- "@leafer/helper": "1.0.0-alpha.9"
22
+ "@leafer/math": "1.0.0-beta",
23
+ "@leafer/data": "1.0.0-beta",
24
+ "@leafer/layout": "1.0.0-beta",
25
+ "@leafer/display-module": "1.0.0-beta",
26
+ "@leafer/event": "1.0.0-beta",
27
+ "@leafer/decorator": "1.0.0-beta",
28
+ "@leafer/helper": "1.0.0-beta"
29
29
  },
30
30
  "devDependencies": {
31
- "@leafer/interface": "1.0.0-alpha.9"
31
+ "@leafer/interface": "1.0.0-beta"
32
32
  }
33
33
  }
package/src/Branch.ts CHANGED
@@ -1,52 +1,54 @@
1
1
  import { ILeaf, ILeaferCanvas, IRenderOptions } from '@leafer/interface'
2
2
  import { ChildEvent } from '@leafer/event'
3
3
  import { BoundsHelper } from '@leafer/math'
4
- import { BranchHelper, LeafBoundsHelper } from '@leafer/helper'
4
+ import { BranchHelper, LeafBoundsHelper, WaitHelper } from '@leafer/helper'
5
+ import { useModule } from '@leafer/decorator'
6
+ import { LeafMask } from '@leafer/display-module'
5
7
 
6
8
  import { Leaf } from './Leaf'
7
9
 
8
10
 
9
11
  const { setByListWithHandle } = BoundsHelper
10
12
  const { sort } = BranchHelper
11
- const { relativeBoxBounds: localBoxBounds, relativeEventBounds: localEventBounds, relativeRenderBounds: localRenderBounds } = LeafBoundsHelper
13
+ const { localBoxBounds, localEventBounds, localRenderBounds, maskLocalBoxBounds, maskLocalEventBounds, maskLocalRenderBounds } = LeafBoundsHelper
12
14
 
15
+ @useModule(LeafMask)
13
16
  export class Branch extends Leaf {
14
17
 
15
18
  constructor() {
16
19
  super()
17
- this.__isBranch = true
20
+ this.isBranch = true
18
21
  this.children = []
19
22
  }
20
23
 
21
24
  // overwrite
22
25
 
23
- public __updateEventBoundsSpreadWidth(): number {
26
+ public __updateStrokeSpread(): number {
24
27
  const { children } = this
25
28
  for (let i = 0, len = children.length; i < len; i++) {
26
- if (children[i].__layout.eventBoundsSpreadWidth) return 1
29
+ if (children[i].__layout.strokeSpread) return 1
27
30
  }
28
31
  return 0
29
32
  }
30
33
 
31
- public __updateRenderBoundsSpreadWidth(): number {
34
+ public __updateRenderSpread(): number {
32
35
  const { children } = this
33
36
  for (let i = 0, len = children.length; i < len; i++) {
34
- if (children[i].__layout.renderBoundsSpreadWidth) return 1
37
+ if (children[i].__layout.renderSpread) return 1
35
38
  }
36
39
  return 0
37
40
  }
38
41
 
39
-
40
42
  public __updateBoxBounds(): void {
41
- setByListWithHandle(this.__layout.boxBounds, this.children, localBoxBounds)
43
+ setByListWithHandle(this.__layout.boxBounds, this.children, this.__hasMask ? maskLocalBoxBounds : localBoxBounds)
42
44
  }
43
45
 
44
- public __updateEventBounds(): void {
45
- setByListWithHandle(this.__layout.eventBounds, this.children, localEventBounds)
46
+ public __updateStrokeBounds(): void {
47
+ setByListWithHandle(this.__layout.strokeBounds, this.children, this.__hasMask ? maskLocalEventBounds : localEventBounds)
46
48
  }
47
49
 
48
50
  public __updateRenderBounds(): void {
49
- setByListWithHandle(this.__layout.renderBounds, this.children, localRenderBounds)
51
+ setByListWithHandle(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds)
50
52
  }
51
53
 
52
54
  public __updateChange(): void {
@@ -73,13 +75,52 @@ export class Branch extends Leaf {
73
75
  public __render(canvas: ILeaferCanvas, options: IRenderOptions): void {
74
76
 
75
77
  if (this.__worldOpacity) {
78
+
76
79
  let child: ILeaf
77
- const { bounds, hideBounds } = options, { children } = this
78
- for (let i = 0, len = children.length; i < len; i++) {
79
- child = children[i]
80
- if (bounds && !bounds.hit(child.__world, options.matrix)) continue
81
- if (hideBounds && hideBounds.includes(child.__world)) continue
82
- child.__render(canvas, options)
80
+ const { children } = this
81
+
82
+ if (this.__hasMask && children.length > 1) {
83
+
84
+ let mask: boolean
85
+ let maskCanvas = canvas.getSameCanvas()
86
+ let contentCanvas = canvas.getSameCanvas()
87
+
88
+ for (let i = 0, len = children.length; i < len; i++) {
89
+ child = children[i]
90
+
91
+ if (child.isMask) {
92
+ if (mask) {
93
+ this.__renderMask(canvas, contentCanvas, maskCanvas)
94
+ maskCanvas.clear()
95
+ contentCanvas.clear()
96
+ } else {
97
+ mask = true
98
+ }
99
+
100
+ child.__render(maskCanvas, options)
101
+ continue
102
+ }
103
+
104
+ child.__render(contentCanvas, options)
105
+ }
106
+
107
+ this.__renderMask(canvas, contentCanvas, maskCanvas)
108
+ maskCanvas.recycle()
109
+ contentCanvas.recycle()
110
+
111
+ } else {
112
+
113
+ const { bounds, hideBounds } = options
114
+
115
+ for (let i = 0, len = children.length; i < len; i++) {
116
+ child = children[i]
117
+
118
+ if (bounds && !bounds.hit(child.__world, options.matrix)) continue
119
+ if (hideBounds && hideBounds.includes(child.__world, options.matrix)) continue
120
+
121
+ child.__render(canvas, options)
122
+ }
123
+
83
124
  }
84
125
  }
85
126
 
@@ -87,25 +128,27 @@ export class Branch extends Leaf {
87
128
 
88
129
  public add(child: ILeaf, index?: number): void {
89
130
 
90
- if (child.parent) {
91
- if (child.parent !== this) console.warn('child had other parent, can not add to this, child innerId:' + child.innerId)
92
- return
93
- }
94
-
131
+ if (child.parent) child.parent.remove(child)
95
132
  child.parent = this
96
133
 
97
134
  index === undefined ? this.children.push(child) : this.children.splice(index, 0, child)
98
- if (child.__isBranch) this.__childBranchNumber ? this.__childBranchNumber++ : this.__childBranchNumber = 1
135
+ if (child.isBranch) this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1
136
+ child.__layout.boundsChanged || child.__layout.positionChange() // layouted(removed), need update
137
+
138
+ if (child.__parentWait) WaitHelper.run(child.__parentWait)
99
139
 
100
- if (this.root) {
101
- child.__bindRoot(this.root)
140
+ if (this.leafer) {
141
+ child.__bindLeafer(this.leafer)
102
142
 
103
- const event = new ChildEvent(ChildEvent.ADD, child, this)
104
- if (this.hasEvent(ChildEvent.ADD)) this.emitEvent(event)
105
- this.root.emitEvent(event)
143
+ if (this.leafer.ready) {
144
+ const { ADD } = ChildEvent
145
+ const event = new ChildEvent(ADD, child, this)
146
+ if (child.hasEvent(ADD)) child.emitEvent(event)
147
+ if (this.hasEvent(ADD) && !this.isLeafer) this.emitEvent(event)
148
+ this.leafer.emitEvent(event)
149
+ }
106
150
  }
107
151
 
108
- if (child.__parentWait) child.__runParentWait()
109
152
  }
110
153
 
111
154
  public remove(child?: Leaf): void {
@@ -114,21 +157,27 @@ export class Branch extends Leaf {
114
157
  const index = this.children.indexOf(child)
115
158
  if (index > -1) {
116
159
  this.children.splice(index, 1)
117
-
118
- if (child.__isBranch) this.__childBranchNumber > 1 ? this.__childBranchNumber-- : this.__childBranchNumber = 0
119
-
120
- if (this.root) {
121
- const event = new ChildEvent(ChildEvent.REMOVE, child, this)
122
- if (this.hasEvent(ChildEvent.REMOVE)) this.emitEvent(event)
123
- this.root.emitEvent(event)
124
- child.root = undefined
160
+ if (this.__hasMask) this.__updateMask()
161
+ this.__layout.boxChange()
162
+
163
+ if (child.isBranch) this.__.__childBranchNumber = (this.__.__childBranchNumber || 1) - 1
164
+ child.parent = null
165
+
166
+ if (this.leafer) {
167
+ child.__bindLeafer(null)
168
+
169
+ if (this.leafer.ready) {
170
+ const { REMOVE } = ChildEvent
171
+ const event = new ChildEvent(REMOVE, child, this)
172
+ if (child.hasEvent(REMOVE)) child.emitEvent(event)
173
+ if (this.hasEvent(REMOVE) && !this.isLeafer) this.emitEvent(event)
174
+ this.leafer.emitEvent(event)
175
+ }
125
176
  }
126
177
 
127
- child.parent = undefined
128
- this.__layout.boxBoundsChange()
129
178
  }
130
179
  } else {
131
- if (this.parent) this.parent.remove(this)
180
+ super.remove()
132
181
  }
133
182
 
134
183
  }
package/src/Leaf.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { ILeafer, ILeaf, ILeafInputData, ILeafData, ILeaferCanvas, IRenderOptions, IMatrixWithBoundsData, __Number, __Boolean, ILeafLayout, InnerId, IHitCanvas, IRadiusPointData, IEventListenerMap, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IObject, IFunction, __String } from '@leafer/interface'
2
- import { IncrementId } from '@leafer/math'
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, IMatrixData } from '@leafer/interface'
2
+ import { IncrementId, MatrixHelper, PointHelper } from '@leafer/math'
3
3
  import { LeafData } from '@leafer/data'
4
4
  import { LeafLayout } from '@leafer/layout'
5
5
  import { LeafDataProxy, LeafMatrix, LeafBounds, LeafHit, LeafEventer, LeafRender } from '@leafer/display-module'
6
6
  import { useModule } from '@leafer/decorator'
7
+ import { WaitHelper } from '@leafer/helper'
7
8
 
8
9
 
9
10
  const { LEAF, create } = IncrementId
@@ -16,57 +17,68 @@ const { LEAF, create } = IncrementId
16
17
  @useModule(LeafRender)
17
18
  export class Leaf implements ILeaf {
18
19
 
19
- public get tag(): string { return this.constructor.name }
20
+ public get tag(): string { return this.__tag }
21
+ public get __tag(): string { return 'Leaf' }
22
+
20
23
  public readonly innerId: InnerId // 内部唯一标识
24
+ public get innerName(): string { return this.__.name || this.tag + this.innerId }
25
+
21
26
  public get __DataProcessor() { return LeafData }
22
27
  public get __LayoutProcessor() { return LeafLayout }
23
28
 
24
29
  public leafer?: ILeafer
25
- public root?: ILeaf
26
30
  public parent?: ILeaf
27
31
 
28
- public __isRoot: boolean
29
- public __isBranch: boolean
30
- public __isBranchLeaf: boolean
32
+ public isLeafer: boolean
33
+ public isBranch: boolean
34
+ public isBranchLeaf: boolean
31
35
 
32
36
  public __: ILeafData
33
37
  public __layout: ILeafLayout
34
38
 
35
- public __relative: IMatrixWithBoundsData
39
+ public __local: IMatrixWithBoundsData
36
40
  public __world: IMatrixWithBoundsData
37
-
38
41
  public __worldOpacity: number
39
- public __renderTime: number // μs 1000微秒 = 1毫秒
40
- public __complex: boolean // 外观是否复杂
41
42
 
42
- public __interactionOff: boolean
43
- public __childrenInteractionOff: boolean
43
+ // now transform
44
+ public get worldTransform(): IMatrixData { return this.__layout.getTransform('world') }
45
+ public get localTransform(): IMatrixData { return this.__layout.getTransform('local') }
46
+
47
+ // now bounds
48
+ public get worldBoxBounds(): IBoundsData { return this.getBounds('box') }
49
+ public get worldStrokeBounds(): IBoundsData { return this.getBounds('stroke') }
50
+ public get worldRenderBounds(): IBoundsData { return this.getBounds('render') }
44
51
 
45
- public __level: number // 所在层级 0 -> 高
46
- public __tempNumber: number // 用于排序,记录最后一次在parent中的排序索引,可用于移除之后回退
52
+ // now opacity
53
+ public get worldOpacity(): number { this.__layout.checkUpdate(); return this.__worldOpacity }
47
54
 
55
+ public __level: number // layer level 0 -> branch -> branch -> deep
56
+ public __tempNumber: number // temp sort
57
+
58
+ public __hasMask?: boolean
48
59
  public __hitCanvas?: IHitCanvas
49
60
 
61
+ public get __onlyHitMask(): boolean { return this.__hasMask && !this.__.hitChildren }
62
+ public get __ignoreHitWorld(): boolean { return this.__hasMask && this.__.hitChildren }
63
+
50
64
  // event
51
65
  public __captureMap?: IEventListenerMap
52
66
  public __bubbleMap?: IEventListenerMap
53
67
 
54
68
  public __parentWait?: IFunction[]
55
-
69
+ public __leaferWait?: IFunction[]
56
70
 
57
71
  // branch
58
72
  public children?: ILeaf[]
59
- public __childBranchNumber?: number
60
73
 
61
74
  constructor(data?: ILeafInputData) {
62
75
 
63
76
  this.innerId = create(LEAF)
64
77
 
65
- this.__relative = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 }
78
+ this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 }
66
79
  this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 }
67
80
 
68
81
  this.__worldOpacity = 1
69
- this.__renderTime = 2
70
82
 
71
83
  this.__ = new this.__DataProcessor(this)
72
84
  this.__layout = new this.__LayoutProcessor(this)
@@ -75,107 +87,144 @@ export class Leaf implements ILeaf {
75
87
  }
76
88
 
77
89
 
78
- public __addParentWait(item: IFunction): void {
90
+ public waitParent(item: IFunction): void {
79
91
  this.__parentWait ? this.__parentWait.push(item) : this.__parentWait = [item]
80
92
  }
81
93
 
82
- public __runParentWait(): void {
83
- const len = this.__parentWait.length
84
- for (let i = 0; i < len; i++) {
85
- this.__parentWait[i]()
86
- }
87
- this.__parentWait = undefined
94
+ public waitLeafer(item: IFunction): void {
95
+ this.__leaferWait ? this.__leaferWait.push(item) : this.__leaferWait = [item]
88
96
  }
89
97
 
90
- public __setAsLeafer(): void {
91
- this.leafer = this as unknown as ILeafer
92
- }
93
-
94
- public __setAsRoot(): void {
95
- this.__bindRoot(this)
96
- this.__isRoot = true
97
- }
98
98
 
99
- public __bindRoot(root: ILeaf): void {
100
- if (this.__isRoot) return
99
+ public __bindLeafer(leafer: ILeafer | null): void {
100
+ if (this.isLeafer) leafer = this as unknown as ILeafer
101
101
 
102
- this.root = root
103
- this.leafer = root.leafer
102
+ this.leafer = leafer
104
103
  this.__level = this.parent ? this.parent.__level + 1 : 1
105
104
 
106
- if (this.__isBranch) {
105
+ if (this.__leaferWait && leafer) WaitHelper.run(this.__leaferWait)
106
+
107
+ if (this.isBranch) {
107
108
  const { children } = this
108
109
  for (let i = 0, len = children.length; i < len; i++) {
109
- children[i].__bindRoot(root)
110
+ children[i].__bindLeafer(leafer)
110
111
  }
111
112
  }
112
113
  }
113
114
 
115
+ public set(_data: IObject): void { }
114
116
 
115
- // LeafDataProxy rewrite
116
-
117
- public __set(_attrName: string, _newValue: unknown): void { }
118
-
119
- public __get(_attrName: string): unknown { return undefined }
117
+ public get(_attrNames?: string[]): IObject { return undefined }
120
118
 
121
- public __updateAttr(_attrName: string): void { }
122
-
123
- // ---
124
119
 
120
+ // LeafDataProxy rewrite
125
121
 
126
- // worldOpacity rewrite, include visible
122
+ public __setAttr(_attrName: string, _newValue: __Value): void { }
127
123
 
128
- public __updateWorldOpacity(): void { }
124
+ public __getAttr(_attrName: string): __Value { return undefined }
129
125
 
130
126
  // ---
131
127
 
128
+ public forceUpdate(attrName?: string): void {
129
+ if (!attrName) attrName = 'x'
130
+ const value = this.__.__get(attrName)
131
+ this.__[attrName] = (value === null) ? 0 : null;
132
+ (this as any)[attrName] = value
133
+ }
132
134
 
133
135
 
134
136
  // LeafMatrix rewrite
135
137
 
136
138
  public __updateWorldMatrix(): void { }
137
139
 
138
- public __updateRelativeMatrix(): void { }
140
+ public __updateLocalMatrix(): void { }
139
141
 
140
142
  // ---
141
143
 
142
-
143
144
  // LeafBounds rewrite
144
145
 
145
146
  public __updateWorldBounds(): void { }
146
147
 
147
148
 
148
- public __updateRelativeBoxBounds(): void { }
149
+ public __updateLocalBoxBounds(): void { }
149
150
 
150
- public __updateRelativeEventBounds(): void { }
151
+ public __updateLocalStrokeBounds(): void { }
151
152
 
152
- public __updateRelativeRenderBounds(): void { }
153
+ public __updateLocalRenderBounds(): void { }
153
154
 
154
155
  // box
155
156
 
156
157
  public __updateBoxBounds(): void { }
157
158
 
158
- public __updateEventBounds(): void { }
159
+ public __updateStrokeBounds(): void { }
159
160
 
160
161
  public __updateRenderBounds(): void { }
161
162
 
162
163
 
163
- public __updateEventBoundsSpreadWidth(): number { return 0 }
164
-
165
- public __updateRenderBoundsSpreadWidth(): number { return 0 }
164
+ public __updateStrokeSpread(): number { return 0 }
166
165
 
166
+ public __updateRenderSpread(): number { return 0 }
167
167
 
168
168
  public __onUpdateSize(): void { }
169
169
 
170
170
  // ---
171
171
 
172
172
 
173
+ // LeafMask rewrite
174
+
175
+ public __updateMask(): void { }
176
+
177
+ public __renderMask(_canvas: ILeaferCanvas, _content: ILeaferCanvas, _mask: ILeaferCanvas): void { }
178
+
179
+ public __removeMask(_child?: ILeaf): void { }
180
+
181
+ // ---
182
+
183
+
184
+ // convert
185
+
186
+ public getWorld(attrName: IMatrixDecompositionAttr): number {
187
+ return this.__layout.decomposeTransform('world')[attrName]
188
+ }
189
+
190
+ public getBounds(type: ILayoutBoundsType, locationType: ILayoutLocationType = 'world'): IBoundsData {
191
+ return this.__layout.getBounds(type, locationType)
192
+ }
193
+
194
+
195
+ public worldToLocal(world: IPointData, to?: IPointData, isMovePoint?: boolean): void {
196
+ if (this.parent) {
197
+ MatrixHelper.toInnerPoint(this.parent.worldTransform, world, to, isMovePoint)
198
+ } else {
199
+ if (to) PointHelper.copy(to, world)
200
+ }
201
+ }
202
+
203
+ public localToWorld(local: IPointData, to?: IPointData, isMovePoint?: boolean): void {
204
+ if (this.parent) {
205
+ MatrixHelper.toOuterPoint(this.parent.worldTransform, local, to, isMovePoint)
206
+ } else {
207
+ if (to) PointHelper.copy(to, local)
208
+ }
209
+ }
210
+
211
+ public worldToInner(world: IPointData, to?: IPointData, isMovePoint?: boolean): void {
212
+ MatrixHelper.toInnerPoint(this.worldTransform, world, to, isMovePoint)
213
+ }
214
+
215
+ public innerToWorld(inner: IPointData, to?: IPointData, isMovePoint?: boolean): void {
216
+ MatrixHelper.toOuterPoint(this.worldTransform, inner, to, isMovePoint)
217
+ }
218
+
219
+
173
220
  // LeafHit rewrite
174
221
 
175
222
  public __hitWorld(_point: IRadiusPointData): boolean { return true }
176
223
 
177
224
  public __hit(_local: IRadiusPointData): boolean { return true }
178
225
 
226
+ public __drawHitPath(_canvas: ILeaferCanvas): void { }
227
+
179
228
  public __updateHitCanvas(): void { }
180
229
 
181
230
  // ---
@@ -189,6 +238,11 @@ export class Leaf implements ILeaf {
189
238
 
190
239
  public __draw(_canvas: ILeaferCanvas, _options: IRenderOptions): void { }
191
240
 
241
+ public __renderShape(_canvas: ILeaferCanvas, _options: IRenderOptions): void { }
242
+
243
+
244
+ public __updateWorldOpacity(): void { }
245
+
192
246
  public __updateChange(): void { }
193
247
 
194
248
  // ---
@@ -211,7 +265,9 @@ export class Leaf implements ILeaf {
211
265
 
212
266
  public add(_child: ILeaf, _index?: number): void { }
213
267
 
214
- public remove(_child?: ILeaf): void { }
268
+ public remove(_child?: ILeaf): void {
269
+ if (this.parent) this.parent.remove(this)
270
+ }
215
271
 
216
272
  // ---
217
273
 
@@ -222,9 +278,9 @@ export class Leaf implements ILeaf {
222
278
 
223
279
  public off(_type: string | string[], _listener: IEventListener, _options?: IEventListenerOptions | boolean): void { }
224
280
 
225
- public on__(_type: string | string[], _listener: IEventListener, _bind?: IObject, _options?: IEventListenerOptions | boolean): IEventListenerId { return undefined }
281
+ public on_(_type: string | string[], _listener: IEventListener, _bind?: IObject, _options?: IEventListenerOptions | boolean): IEventListenerId { return undefined }
226
282
 
227
- public off__(_id: IEventListenerId | IEventListenerId[]): void { }
283
+ public off_(_id: IEventListenerId | IEventListenerId[]): void { }
228
284
 
229
285
  public once(_type: string | string[], _listener: IEventListener, _capture?: boolean): void { }
230
286
 
@@ -238,28 +294,26 @@ export class Leaf implements ILeaf {
238
294
 
239
295
  public destroy(): void {
240
296
  if (this.__) {
241
-
242
- if (this.__isBranch) {
243
- this.children.forEach(child => { child.destroy() })
244
- this.children = undefined
245
- }
246
-
247
297
  if (this.__hitCanvas) {
248
298
  this.__hitCanvas.destroy()
249
- this.__hitCanvas = undefined
299
+ this.__hitCanvas = null
250
300
  }
251
301
 
252
- this.leafer = undefined
253
- this.root = undefined
254
- this.parent = undefined
302
+ this.leafer = null
303
+ this.parent = null
255
304
 
256
305
  this.__.destroy()
257
306
  this.__layout.destroy()
258
- this.__ = undefined
259
- this.__layout = undefined
307
+ this.__ = null
308
+ this.__layout = null
260
309
 
261
- this.__captureMap = undefined
262
- this.__bubbleMap = undefined
310
+ this.__captureMap = null
311
+ this.__bubbleMap = null
312
+
313
+ if (this.children) {
314
+ this.children.forEach(child => { child.destroy() })
315
+ this.children.length = 0
316
+ }
263
317
  }
264
318
  }
265
319