@leafer-ui/app 1.0.0-rc.9 → 1.0.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/app",
3
- "version": "1.0.0-rc.9",
3
+ "version": "1.0.0",
4
4
  "description": "@leafer-ui/app",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,13 +22,13 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.0.0-rc.9",
26
- "@leafer-ui/display": "1.0.0-rc.9",
27
- "@leafer-ui/type": "1.0.0-rc.9",
28
- "@leafer-ui/data": "1.0.0-rc.9"
25
+ "@leafer/core": "1.0.0",
26
+ "@leafer-ui/display": "1.0.0",
27
+ "@leafer-ui/type": "1.0.0",
28
+ "@leafer-ui/data": "1.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@leafer/interface": "1.0.0-rc.9",
32
- "@leafer-ui/interface": "1.0.0-rc.9"
31
+ "@leafer/interface": "1.0.0",
32
+ "@leafer-ui/interface": "1.0.0"
33
33
  }
34
34
  }
package/src/App.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { ILeaferConfig, IResizeEvent, ILeaferCanvas, IRenderOptions, ILeaferBase } from '@leafer/interface'
1
+ import { ILeaferConfig, IResizeEvent, ILeaferCanvas, IRenderOptions, ILeaferBase, IBoundsData } from '@leafer/interface'
2
2
  import { Creator, DataHelper, Debug, LayoutEvent, PropertyEvent, RenderEvent, canvasSizeAttrs, registerUI } from '@leafer/core'
3
3
 
4
4
  import { IApp, IAppConfig, IAppInputData, IEditorBase, ILeafer } from '@leafer-ui/interface'
5
5
 
6
- import { Leafer } from './Leafer'
6
+ import { Leafer } from '@leafer-ui/draw'
7
7
 
8
8
 
9
9
  @registerUI()
@@ -23,6 +23,10 @@ export class App extends Leafer implements IApp {
23
23
 
24
24
  constructor(userConfig?: IAppConfig, data?: IAppInputData) {
25
25
  super(userConfig, data)
26
+ }
27
+
28
+ override init(userConfig?: IAppConfig, parentApp?: IApp): void {
29
+ super.init(userConfig, parentApp)
26
30
  if (userConfig) {
27
31
  const { ground, tree, sky, editor } = userConfig
28
32
  if (ground) this.ground = this.addLeafer(ground)
@@ -51,42 +55,47 @@ export class App extends Leafer implements IApp {
51
55
  this.__eventIds.push(this.on_(PropertyEvent.CHANGE, this.__onPropertyChange, this))
52
56
  }
53
57
 
54
- public start(): void {
58
+ override start(): void {
55
59
  super.start()
56
60
  this.children.forEach(leafer => leafer.start())
57
61
  }
58
62
 
59
- public stop(): void {
63
+ override stop(): void {
60
64
  this.children.forEach(leafer => leafer.stop())
61
65
  super.stop()
62
66
  }
63
67
 
64
- public unlockLayout(): void {
68
+ override unlockLayout(): void {
65
69
  super.unlockLayout()
66
70
  this.children.forEach(leafer => leafer.unlockLayout())
67
71
  }
68
72
 
69
- public lockLayout(): void {
73
+ override lockLayout(): void {
70
74
  super.lockLayout()
71
75
  this.children.forEach(leafer => leafer.lockLayout())
72
76
  }
73
77
 
78
+ override forceRender(bounds?: IBoundsData): void {
79
+ this.children.forEach(leafer => leafer.forceRender(bounds))
80
+ }
81
+
74
82
  public addLeafer(merge?: ILeaferConfig): Leafer {
75
83
  const leafer = new Leafer(merge)
76
84
  this.add(leafer)
77
85
  return leafer
78
86
  }
79
87
 
80
- public add(leafer: ILeafer): void {
88
+ override add(leafer: ILeafer, index?: number): void {
81
89
  if (!leafer.view) {
82
90
  if (this.realCanvas && !this.canvas.bounds) { // wait miniapp select canvas
83
- setTimeout(() => this.add(leafer), 10)
91
+ setTimeout(() => this.add(leafer, index), 10)
84
92
  return
85
93
  }
86
94
  leafer.init(this.__getChildConfig(leafer.userConfig), this)
87
95
  }
88
96
 
89
- super.add(leafer)
97
+ super.add(leafer, index)
98
+ if (index !== undefined) leafer.canvas.childIndex = index
90
99
  this.__listenChildEvents(leafer)
91
100
  }
92
101
 
@@ -111,7 +120,11 @@ export class App extends Leafer implements IApp {
111
120
  if (this.viewReady) this.renderer.update()
112
121
  }
113
122
 
114
- public __render(canvas: ILeaferCanvas, _options: IRenderOptions): void {
123
+ override __render(canvas: ILeaferCanvas, options: IRenderOptions): void {
124
+ if (options.matrix) {
125
+ const { a, b, c, d, e, f } = options.matrix
126
+ canvas.setTransform(a, b, c, d, e, f) // screenshot
127
+ }
115
128
  this.children.forEach(leafer => canvas.copyWorld(leafer.canvas))
116
129
  }
117
130
 
package/src/index.ts CHANGED
@@ -1,2 +1 @@
1
- export { Leafer } from './Leafer'
2
1
  export { App } from './App'
package/types/index.d.ts CHANGED
@@ -1,82 +1,7 @@
1
- import { ILeaferCanvas, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IPointData, IEventListenerId, ITimer, IControl, IScreenSizeData, IResizeEvent, ILeaf, IValue, IRenderOptions, ILeaferBase } from '@leafer/interface';
2
- import { ILeafer, ILeaferData, IApp, IEditorBase, IGroup, IFunction, ILeaferInputData, IUIInputData, IAppConfig, IAppInputData } from '@leafer-ui/interface';
3
- import { Group } from '@leafer-ui/display';
1
+ import { IBoundsData, ILeaferConfig, ILeaferCanvas, IRenderOptions, IResizeEvent, ILeaferBase } from '@leafer/interface';
4
2
  import { RenderEvent } from '@leafer/core';
5
-
6
- declare class Leafer extends Group implements ILeafer {
7
- get __tag(): string;
8
- __: ILeaferData;
9
- pixelRatio: number;
10
- get isApp(): boolean;
11
- get app(): ILeafer;
12
- parent?: IApp;
13
- running: boolean;
14
- created: boolean;
15
- ready: boolean;
16
- viewReady: boolean;
17
- viewCompleted: boolean;
18
- get imageReady(): boolean;
19
- get layoutLocked(): boolean;
20
- view: unknown;
21
- canvas: ILeaferCanvas;
22
- renderer: IRenderer;
23
- watcher: IWatcher;
24
- layouter: ILayouter;
25
- selector?: ISelector;
26
- interaction?: IInteraction;
27
- canvasManager: ICanvasManager;
28
- hitCanvasManager?: IHitCanvasManager;
29
- editor: IEditorBase;
30
- zoomLayer: IGroup;
31
- userConfig: ILeaferConfig;
32
- config: ILeaferConfig;
33
- autoLayout?: IAutoBounds;
34
- get cursorPoint(): IPointData;
35
- leafs: number;
36
- __eventIds: IEventListenerId[];
37
- protected __startTimer: ITimer;
38
- protected __controllers: IControl[];
39
- protected __readyWait: IFunction[];
40
- protected __viewReadyWait: IFunction[];
41
- protected __viewCompletedWait: IFunction[];
42
- __nextRenderWait: IFunction[];
43
- constructor(userConfig?: ILeaferConfig, data?: ILeaferInputData);
44
- init(userConfig?: ILeaferConfig, parentApp?: IApp): void;
45
- set(data: IUIInputData): void;
46
- start(): void;
47
- stop(): void;
48
- unlockLayout(): void;
49
- lockLayout(): void;
50
- resize(size: IScreenSizeData): void;
51
- forceFullRender(): void;
52
- updateCursor(): void;
53
- protected __doResize(size: IScreenSizeData): void;
54
- protected __onResize(event: IResizeEvent): void;
55
- protected __setApp(): void;
56
- protected __bindApp(app: IApp): void;
57
- __setLeafer(leafer: ILeafer): void;
58
- setZoomLayer(zoomLayer: ILeaf): void;
59
- protected __checkAutoLayout(config: ILeaferConfig): void;
60
- __setAttr(attrName: string, newValue: IValue): void;
61
- __getAttr(attrName: string): IValue;
62
- protected __changeCanvasSize(attrName: string, newValue: number): void;
63
- protected __changeFill(newValue: string): void;
64
- protected __onCreated(): void;
65
- protected __onReady(): void;
66
- protected __onViewReady(): void;
67
- protected __onAnimateFrame(): void;
68
- protected __checkViewCompleted(emit?: boolean): void;
69
- protected __onWatchData(): void;
70
- waitReady(item: IFunction): void;
71
- waitViewReady(item: IFunction): void;
72
- waitViewCompleted(item: IFunction): void;
73
- nextRender(item: IFunction): void;
74
- protected __checkUpdateLayout(): void;
75
- protected emitLeafer(type: string): void;
76
- protected __listenEvents(): void;
77
- protected __removeListenEvents(): void;
78
- destroy(): void;
79
- }
3
+ import { IApp, ILeafer, IAppConfig, IAppInputData } from '@leafer-ui/interface';
4
+ import { Leafer } from '@leafer-ui/draw';
80
5
 
81
6
  declare class App extends Leafer implements IApp {
82
7
  get __tag(): string;
@@ -87,23 +12,25 @@ declare class App extends Leafer implements IApp {
87
12
  tree: ILeafer;
88
13
  sky: ILeafer;
89
14
  constructor(userConfig?: IAppConfig, data?: IAppInputData);
15
+ init(userConfig?: IAppConfig, parentApp?: IApp): void;
90
16
  protected __setApp(): void;
91
17
  start(): void;
92
18
  stop(): void;
93
19
  unlockLayout(): void;
94
20
  lockLayout(): void;
21
+ forceRender(bounds?: IBoundsData): void;
95
22
  addLeafer(merge?: ILeaferConfig): Leafer;
96
- add(leafer: ILeafer): void;
23
+ add(leafer: ILeafer, index?: number): void;
97
24
  protected __onPropertyChange(): void;
98
25
  protected __onCreated(): void;
99
26
  protected __onReady(): void;
100
27
  protected __onViewReady(): void;
101
28
  protected __onChildRenderEnd(e: RenderEvent): void;
102
- __render(canvas: ILeaferCanvas, _options: IRenderOptions): void;
29
+ __render(canvas: ILeaferCanvas, options: IRenderOptions): void;
103
30
  __onResize(event: IResizeEvent): void;
104
31
  protected __checkUpdateLayout(): void;
105
32
  protected __getChildConfig(userConfig?: ILeaferConfig): ILeaferConfig;
106
33
  protected __listenChildEvents(leafer: ILeaferBase): void;
107
34
  }
108
35
 
109
- export { App, Leafer };
36
+ export { App };
package/src/Leafer.ts DELETED
@@ -1,394 +0,0 @@
1
- import { ILeaferCanvas, IRenderer, ILayouter, ISelector, IWatcher, IInteraction, ILeaferConfig, ICanvasManager, IHitCanvasManager, IAutoBounds, IScreenSizeData, IResizeEvent, ILeaf, IEventListenerId, ITimer, IValue, IObject, IControl, IPointData } from '@leafer/interface'
2
- import { AutoBounds, LayoutEvent, ResizeEvent, LeaferEvent, CanvasManager, HitCanvasManager, ImageManager, DataHelper, Creator, Run, Debug, RenderEvent, AnimateEvent, registerUI, boundsType, canvasSizeAttrs, dataProcessor, PluginManager, WaitHelper, WatchEvent } from '@leafer/core'
3
-
4
- import { ILeaferInputData, ILeaferData, IFunction, IUIInputData, ILeafer, IGroup, IApp, IEditorBase } from '@leafer-ui/interface'
5
- import { LeaferTypeCreator } from '@leafer-ui/type'
6
- import { LeaferData } from '@leafer-ui/data'
7
- import { Group } from '@leafer-ui/display'
8
-
9
-
10
- const debug = Debug.get('Leafer')
11
-
12
- @registerUI()
13
- export class Leafer extends Group implements ILeafer {
14
-
15
- public get __tag() { return 'Leafer' }
16
-
17
- @dataProcessor(LeaferData)
18
- declare public __: ILeaferData
19
-
20
- @boundsType()
21
- public pixelRatio: number
22
-
23
- public get isApp(): boolean { return false }
24
- public get app(): ILeafer { return this.parent || this }
25
-
26
- declare public parent?: IApp
27
-
28
- public running: boolean
29
- public created: boolean
30
- public ready: boolean
31
- public viewReady: boolean
32
- public viewCompleted: boolean
33
- public get imageReady(): boolean { return this.viewReady && ImageManager.isComplete }
34
- public get layoutLocked() { return !this.layouter.running }
35
-
36
- public view: unknown
37
-
38
- // manager
39
- public canvas: ILeaferCanvas
40
- public renderer: IRenderer
41
-
42
- public watcher: IWatcher
43
- public layouter: ILayouter
44
-
45
- public selector?: ISelector
46
- public interaction?: IInteraction
47
-
48
- public canvasManager: ICanvasManager
49
- public hitCanvasManager?: IHitCanvasManager
50
-
51
- // plugin
52
- public editor: IEditorBase
53
-
54
- public zoomLayer: IGroup = this
55
-
56
- public userConfig: ILeaferConfig
57
- public config: ILeaferConfig = {
58
- type: 'design',
59
- start: true,
60
- hittable: true,
61
- smooth: true,
62
- zoom: {
63
- min: 0.02,
64
- max: 256
65
- },
66
- move: {
67
- holdSpaceKey: true,
68
- dragOut: true,
69
- autoDistance: 2
70
- }
71
- }
72
-
73
- public autoLayout?: IAutoBounds
74
-
75
- public get cursorPoint(): IPointData { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 } }
76
- public leafs = 0
77
-
78
- public __eventIds: IEventListenerId[] = []
79
- protected __startTimer: ITimer
80
- protected __controllers: IControl[] = []
81
-
82
- protected __readyWait: IFunction[] = []
83
- protected __viewReadyWait: IFunction[] = []
84
- protected __viewCompletedWait: IFunction[] = []
85
- public __nextRenderWait: IFunction[] = []
86
-
87
- constructor(userConfig?: ILeaferConfig, data?: ILeaferInputData) {
88
- super(data)
89
- this.userConfig = userConfig
90
- if (userConfig && (userConfig.view || userConfig.width)) this.init(userConfig)
91
- }
92
-
93
- public init(userConfig?: ILeaferConfig, parentApp?: IApp): void {
94
- if (this.canvas) return
95
-
96
- this.__setLeafer(this)
97
- if (userConfig) DataHelper.assign(this.config, userConfig)
98
-
99
- let start: boolean
100
- const { config } = this
101
- LeaferTypeCreator.run(config.type, this)
102
-
103
- // render / layout
104
- this.canvas = Creator.canvas(config)
105
- this.__controllers.push(
106
- this.renderer = Creator.renderer(this, this.canvas, config),
107
- this.watcher = Creator.watcher(this, config),
108
- this.layouter = Creator.layouter(this, config)
109
- )
110
-
111
- if (this.isApp) this.__setApp()
112
- this.__checkAutoLayout(config)
113
- this.view = this.canvas.view
114
-
115
- // interaction / manager
116
- if (parentApp) {
117
- this.__bindApp(parentApp)
118
- start = parentApp.running
119
- } else {
120
- this.selector = Creator.selector(this)
121
- this.__controllers.unshift(this.interaction = Creator.interaction(this, this.canvas, this.selector, config))
122
-
123
- this.canvasManager = new CanvasManager()
124
- this.hitCanvasManager = new HitCanvasManager()
125
-
126
- start = config.start
127
- }
128
-
129
- this.hittable = config.hittable
130
- this.fill = config.fill
131
- this.canvasManager.add(this.canvas)
132
-
133
- this.__listenEvents()
134
-
135
- if (start) this.__startTimer = setTimeout(this.start.bind(this))
136
-
137
- PluginManager.onLeafer(this)
138
- }
139
-
140
- public set(data: IUIInputData): void {
141
- if (!this.children) {
142
- setTimeout(() => {
143
- super.set(data)
144
- })
145
- } else {
146
- super.set(data)
147
- }
148
- }
149
-
150
- public start(): void {
151
- clearTimeout(this.__startTimer)
152
- if (!this.running && this.canvas) {
153
- this.ready ? this.emitLeafer(LeaferEvent.RESTART) : this.emitLeafer(LeaferEvent.START)
154
- this.__controllers.forEach(item => item.start())
155
- if (!this.isApp) this.renderer.render()
156
- this.running = true
157
- }
158
- }
159
-
160
- public stop(): void {
161
- clearTimeout(this.__startTimer)
162
- if (this.running && this.canvas) {
163
- this.__controllers.forEach(item => item.stop())
164
- this.running = false
165
- this.emitLeafer(LeaferEvent.STOP)
166
- }
167
- }
168
-
169
- public unlockLayout(): void {
170
- this.layouter.start()
171
- this.updateLayout()
172
- }
173
-
174
- public lockLayout(): void {
175
- this.updateLayout()
176
- this.layouter.stop()
177
- }
178
-
179
- public resize(size: IScreenSizeData): void {
180
- const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs)
181
- Object.keys(data).forEach(key => (this as any)[key] = data[key])
182
- }
183
-
184
- public forceFullRender(): void {
185
- this.renderer.addBlock(this.canvas.bounds)
186
- if (this.viewReady) this.renderer.update()
187
- }
188
-
189
- public updateCursor(): void {
190
- if (this.interaction) this.interaction.updateCursor()
191
- }
192
-
193
- protected __doResize(size: IScreenSizeData): void {
194
- if (!this.canvas || this.canvas.isSameSize(size)) return
195
- const old = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs) as IScreenSizeData
196
- this.canvas.resize(size)
197
- this.__onResize(new ResizeEvent(size, old))
198
- }
199
-
200
- protected __onResize(event: IResizeEvent): void {
201
- this.emitEvent(event)
202
- DataHelper.copyAttrs(this.__, event, canvasSizeAttrs)
203
- setTimeout(() => { if (this.canvasManager) this.canvasManager.clearRecycled() }, 0)
204
- }
205
-
206
- protected __setApp(): void { }
207
-
208
- protected __bindApp(app: IApp): void {
209
- this.selector = app.selector
210
- this.interaction = app.interaction
211
-
212
- this.canvasManager = app.canvasManager
213
- this.hitCanvasManager = app.hitCanvasManager
214
- }
215
-
216
- public __setLeafer(leafer: ILeafer): void {
217
- this.leafer = leafer
218
- this.isLeafer = !!leafer
219
- this.__level = 1
220
- }
221
-
222
- public setZoomLayer(zoomLayer: ILeaf): void {
223
- this.zoomLayer = zoomLayer as IGroup
224
- }
225
-
226
- protected __checkAutoLayout(config: ILeaferConfig): void {
227
- if (!config.width || !config.height) {
228
- this.autoLayout = new AutoBounds(config)
229
- this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this))
230
- }
231
- }
232
-
233
- public __setAttr(attrName: string, newValue: IValue): void {
234
- if (this.canvas) {
235
- if (canvasSizeAttrs.includes(attrName)) {
236
- this.__changeCanvasSize(attrName, newValue as number)
237
- } else if (attrName === 'fill') {
238
- this.__changeFill(newValue as string)
239
- } else if (attrName === 'hittable') {
240
- this.canvas.hittable = newValue as boolean
241
- }
242
- }
243
- super.__setAttr(attrName, newValue)
244
- }
245
-
246
- public __getAttr(attrName: string): IValue {
247
- if (this.canvas && canvasSizeAttrs.includes(attrName)) return this.canvas[attrName]
248
- return super.__getAttr(attrName)
249
- }
250
-
251
- protected __changeCanvasSize(attrName: string, newValue: number): void {
252
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs)
253
- data[attrName] = (this.config as IObject)[attrName] = newValue
254
- if (newValue) this.canvas.stopAutoLayout()
255
- this.__doResize(data as IScreenSizeData)
256
- }
257
-
258
- protected __changeFill(newValue: string): void {
259
- this.config.fill = newValue as string
260
- if (this.canvas.allowBackgroundColor) {
261
- this.canvas.backgroundColor = newValue as string
262
- } else {
263
- this.forceFullRender()
264
- }
265
- }
266
-
267
- protected __onCreated(): void {
268
- this.created = true
269
- }
270
-
271
- protected __onReady(): void {
272
- if (this.ready) return
273
- this.ready = true
274
- this.emitLeafer(LeaferEvent.BEFORE_READY)
275
- this.emitLeafer(LeaferEvent.READY)
276
- this.emitLeafer(LeaferEvent.AFTER_READY)
277
- WaitHelper.run(this.__readyWait)
278
- }
279
-
280
- protected __onViewReady(): void {
281
- if (this.viewReady) return
282
- this.viewReady = true
283
- this.emitLeafer(LeaferEvent.VIEW_READY)
284
- WaitHelper.run(this.__viewReadyWait)
285
- }
286
-
287
- protected __onAnimateFrame(): void {
288
- if (this.viewReady) {
289
- if (this.__nextRenderWait.length) WaitHelper.run(this.__nextRenderWait)
290
-
291
- const { imageReady } = this
292
- if (imageReady && !this.viewCompleted) this.__checkViewCompleted()
293
- if (!imageReady) this.viewCompleted = false
294
- }
295
- }
296
-
297
- protected __checkViewCompleted(emit: boolean = true): void {
298
- this.nextRender(() => {
299
- if (this.imageReady) {
300
- if (emit) this.emitLeafer(LeaferEvent.VIEW_COMPLETED)
301
- WaitHelper.run(this.__viewCompletedWait)
302
- this.viewCompleted = true
303
- }
304
- })
305
- }
306
-
307
- protected __onWatchData(): void {
308
- if (this.watcher.childrenChanged && this.interaction) {
309
- this.nextRender(() => this.interaction.updateCursor())
310
- }
311
- }
312
-
313
- public waitReady(item: IFunction): void {
314
- this.ready ? item() : this.__readyWait.push(item)
315
- }
316
-
317
- public waitViewReady(item: IFunction): void {
318
- this.viewReady ? item() : this.__viewReadyWait.push(item)
319
- }
320
-
321
- public waitViewCompleted(item: IFunction): void {
322
- this.__viewCompletedWait.push(item)
323
- if (this.viewCompleted) {
324
- this.__checkViewCompleted(false)
325
- } else {
326
- if (!this.running) this.start()
327
- }
328
- }
329
-
330
- public nextRender(item: IFunction): void {
331
- this.__nextRenderWait.push(item)
332
- }
333
-
334
- protected __checkUpdateLayout(): void {
335
- this.__layout.update()
336
- }
337
-
338
- protected emitLeafer(type: string): void {
339
- this.emitEvent(new LeaferEvent(type, this))
340
- }
341
-
342
- protected __listenEvents(): void {
343
- const runId = Run.start('FirstCreate ' + this.innerName)
344
- this.once(LeaferEvent.START, () => Run.end(runId))
345
- this.once(LayoutEvent.END, () => this.__onReady())
346
- this.once(RenderEvent.START, () => this.__onCreated())
347
- this.once(RenderEvent.END, () => this.__onViewReady())
348
- this.__eventIds.push(
349
- this.on_(WatchEvent.DATA, this.__onWatchData, this),
350
- this.on_(AnimateEvent.FRAME, this.__onAnimateFrame, this),
351
- this.on_(LayoutEvent.CHECK_UPDATE, this.__checkUpdateLayout, this)
352
- )
353
- }
354
-
355
- protected __removeListenEvents(): void {
356
- this.off_(this.__eventIds)
357
- this.__eventIds.length = 0
358
- }
359
-
360
- public destroy(): void {
361
- setTimeout(() => {
362
- if (!this.destroyed) {
363
- try {
364
- this.stop()
365
- this.emitEvent(new LeaferEvent(LeaferEvent.END, this))
366
- this.__removeListenEvents()
367
-
368
- this.__controllers.forEach(item => {
369
- if (!(this.parent && item === this.interaction)) item.destroy()
370
- })
371
- this.__controllers.length = 0
372
-
373
- if (!this.parent) {
374
- this.selector.destroy()
375
- this.canvasManager.destroy()
376
- this.hitCanvasManager.destroy()
377
- }
378
-
379
- this.canvas.destroy()
380
-
381
- this.config.view = this.view = null
382
- if (this.userConfig) this.userConfig.view = null
383
-
384
- super.destroy()
385
-
386
- setTimeout(() => { ImageManager.clearRecycled() }, 100)
387
- } catch (e) {
388
- debug.error(e)
389
- }
390
- }
391
- })
392
-
393
- }
394
- }