@leafer-ui/display 1.1.0 → 1.1.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/display",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "@leafer-ui/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,14 +22,14 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.1.0",
26
- "@leafer-ui/data": "1.1.0",
27
- "@leafer-ui/display-module": "1.1.0",
28
- "@leafer-ui/decorator": "1.1.0",
29
- "@leafer-ui/external": "1.1.0"
25
+ "@leafer/core": "1.1.1",
26
+ "@leafer-ui/data": "1.1.1",
27
+ "@leafer-ui/display-module": "1.1.1",
28
+ "@leafer-ui/decorator": "1.1.1",
29
+ "@leafer-ui/external": "1.1.1"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "1.1.0",
33
- "@leafer-ui/interface": "1.1.0"
32
+ "@leafer/interface": "1.1.1",
33
+ "@leafer-ui/interface": "1.1.1"
34
34
  }
35
35
  }
package/src/Leafer.ts CHANGED
@@ -28,6 +28,7 @@ export class Leafer extends Group implements ILeafer {
28
28
 
29
29
  public get isLeafer(): boolean { return true }
30
30
 
31
+ public parentApp?: IApp
31
32
  declare public parent?: IApp
32
33
 
33
34
  public running: boolean
@@ -60,20 +61,10 @@ export class Leafer extends Group implements ILeafer {
60
61
 
61
62
  public userConfig: ILeaferConfig
62
63
  public config: ILeaferConfig = {
63
- type: 'design',
64
64
  start: true,
65
65
  hittable: true,
66
66
  smooth: true,
67
- lazySpeard: 100,
68
- zoom: {
69
- min: 0.01,
70
- max: 256
71
- },
72
- move: {
73
- holdSpaceKey: true,
74
- holdMiddleKey: true,
75
- autoDistance: 2
76
- }
67
+ lazySpeard: 100
77
68
  }
78
69
 
79
70
  public autoLayout?: IAutoBounds
@@ -104,13 +95,23 @@ export class Leafer extends Group implements ILeafer {
104
95
  public init(userConfig?: ILeaferConfig, parentApp?: IApp): void {
105
96
  if (this.canvas) return
106
97
 
107
- this.__setLeafer(this)
108
- if (userConfig) DataHelper.assign(this.config, userConfig)
109
-
110
98
  let start: boolean
111
99
  const { config } = this
112
100
 
113
- this.initType(config.type) // LeaferType
101
+ this.__setLeafer(this)
102
+
103
+ if (parentApp) {
104
+ this.parentApp = parentApp
105
+ this.__bindApp(parentApp)
106
+ start = parentApp.running
107
+ }
108
+
109
+ if (userConfig) {
110
+ this.parent = parentApp
111
+ this.initType(userConfig.type) // LeaferType
112
+ this.parent = undefined
113
+ DataHelper.assign(config, userConfig)
114
+ }
114
115
 
115
116
  // render / layout
116
117
  const canvas = this.canvas = Creator.canvas(config)
@@ -125,10 +126,7 @@ export class Leafer extends Group implements ILeafer {
125
126
  this.view = canvas.view
126
127
 
127
128
  // interaction / manager
128
- if (parentApp) {
129
- this.__bindApp(parentApp)
130
- start = parentApp.running
131
- } else {
129
+ if (!parentApp) {
132
130
  this.selector = Creator.selector(this)
133
131
  this.interaction = Creator.interaction(this, canvas, this.selector, config)
134
132
 
@@ -199,7 +197,11 @@ export class Leafer extends Group implements ILeafer {
199
197
 
200
198
  override forceRender(bounds?: IBoundsData): void {
201
199
  this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds)
202
- if (this.viewReady) this.renderer.update()
200
+ if (this.viewReady) this.renderer.render()
201
+ }
202
+
203
+ public requestRender(change = false): void {
204
+ if (this.renderer) this.renderer.update(change)
203
205
  }
204
206
 
205
207
  public updateCursor(cursor?: ICursorType): void {
@@ -309,7 +311,10 @@ export class Leafer extends Group implements ILeafer {
309
311
 
310
312
  const { imageReady } = this
311
313
  if (imageReady && !this.viewCompleted) this.__checkViewCompleted()
312
- if (!imageReady) this.viewCompleted = false
314
+ if (!imageReady) {
315
+ this.viewCompleted = false
316
+ this.requestRender()
317
+ }
313
318
  }
314
319
  }
315
320
 
@@ -360,6 +365,7 @@ export class Leafer extends Group implements ILeafer {
360
365
  if (list[i] === item) { list.splice(i, 1); break }
361
366
  }
362
367
  } else list.push(item)
368
+ this.requestRender()
363
369
  }
364
370
 
365
371
  // need view plugin
@@ -436,7 +442,7 @@ export class Leafer extends Group implements ILeafer {
436
442
 
437
443
  this.canvas.destroy()
438
444
 
439
- this.config.view = this.view = null
445
+ this.config.view = this.view = this.parentApp = null
440
446
  if (this.userConfig) this.userConfig.view = null
441
447
 
442
448
  super.destroy()
package/types/index.d.ts CHANGED
@@ -173,6 +173,7 @@ declare class Leafer extends Group implements ILeafer {
173
173
  get isApp(): boolean;
174
174
  get app(): ILeafer;
175
175
  get isLeafer(): boolean;
176
+ parentApp?: IApp;
176
177
  parent?: IApp;
177
178
  running: boolean;
178
179
  created: boolean;
@@ -219,6 +220,7 @@ declare class Leafer extends Group implements ILeafer {
219
220
  lockLayout(): void;
220
221
  resize(size: IScreenSizeData): void;
221
222
  forceRender(bounds?: IBoundsData): void;
223
+ requestRender(change?: boolean): void;
222
224
  updateCursor(cursor?: ICursorType): void;
223
225
  updateLazyBounds(): void;
224
226
  protected __doResize(size: IScreenSizeData): void;