@leafer-ui/app 1.0.0-alpha.10 → 1.0.0-alpha.21

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-alpha.10",
3
+ "version": "1.0.0-alpha.21",
4
4
  "description": "@leafer-ui/app",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -19,11 +19,11 @@
19
19
  "leaferjs"
20
20
  ],
21
21
  "dependencies": {
22
- "@leafer/core": "1.0.0-alpha.10",
23
- "@leafer-ui/display": "1.0.0-alpha.10"
22
+ "@leafer/core": "1.0.0-alpha.21",
23
+ "@leafer-ui/display": "1.0.0-alpha.21"
24
24
  },
25
25
  "devDependencies": {
26
- "@leafer/interface": "1.0.0-alpha.10",
27
- "@leafer-ui/interface": "1.0.0-alpha.10"
26
+ "@leafer/interface": "1.0.0-alpha.21",
27
+ "@leafer-ui/interface": "1.0.0-alpha.21"
28
28
  }
29
29
  }
package/src/App.ts CHANGED
@@ -1,12 +1,10 @@
1
- import { ILeaferConfig, IResizeEvent, ILeaferCanvas, IRenderOptions } from '@leafer/interface'
1
+ import { ILeaferConfig, IResizeEvent, ILeaferCanvas, IRenderOptions, IApp } from '@leafer/interface'
2
2
  import { DataHelper, LayoutEvent, RenderEvent } from '@leafer/core'
3
3
 
4
- import { IGroup } from '@leafer-ui/interface'
5
-
6
4
  import { Leafer } from './Leafer'
7
5
 
8
6
 
9
- export class App extends Leafer implements IGroup {
7
+ export class App extends Leafer implements IApp {
10
8
 
11
9
  public get isApp(): boolean { return true }
12
10
 
@@ -53,7 +51,7 @@ export class App extends Leafer implements IGroup {
53
51
  }
54
52
 
55
53
  public __render(canvas: ILeaferCanvas, _options: IRenderOptions): void {
56
- this.children.forEach(leafer => { canvas.copy(leafer.canvas) })
54
+ this.children.forEach(leafer => { canvas.copyWorld(leafer.canvas) })
57
55
  }
58
56
 
59
57
  public __onResize(event: IResizeEvent): void {
package/src/Leafer.ts CHANGED
@@ -26,9 +26,10 @@ export class Leafer extends Group implements ILeafer {
26
26
  public pixelRatio: number
27
27
 
28
28
  public config: ILeaferConfig = {
29
- zoom: true,
30
- move: true,
31
- start: true,
29
+ useZoom: true,
30
+ useMove: true,
31
+ autoStart: true,
32
+ hittable: true,
32
33
  pixelRatio: devicePixelRatio
33
34
  }
34
35
 
@@ -63,6 +64,7 @@ export class Leafer extends Group implements ILeafer {
63
64
 
64
65
  const { config } = this
65
66
  this.creator = Creator
67
+ this.hittable = config.hittable
66
68
 
67
69
  // render
68
70
  this.canvas = Creator.canvas(config)
@@ -84,7 +86,7 @@ export class Leafer extends Group implements ILeafer {
84
86
  app.selector?.defaultPath.unshift(this)
85
87
 
86
88
  this.selector = app.selector
87
- this.interaction = app.interaction
89
+ if (config.hittable) this.interaction = app.interaction
88
90
 
89
91
  this.canvasManager = app.canvasManager
90
92
  this.hitCanvasManager = app.hitCanvasManager
@@ -95,13 +97,13 @@ export class Leafer extends Group implements ILeafer {
95
97
  } else {
96
98
 
97
99
  this.selector = Creator.selector(this)
98
- this.interaction = Creator.interaction(this, this.canvas, this.selector, config)
100
+ if (config.hittable) this.interaction = Creator.interaction(this, this.canvas, this.selector, config)
99
101
 
100
102
  this.canvasManager = new CanvasManager(this)
101
103
  this.hitCanvasManager = new HitCanvasManager(this)
102
104
  this.imageManager = new ImageManager(this, config)
103
105
  Run.start('FullCreate')
104
- if (config.start) setTimeout(this.start.bind(this))
106
+ if (config.autoStart) setTimeout(this.start.bind(this))
105
107
 
106
108
  }
107
109
 
@@ -125,15 +127,17 @@ export class Leafer extends Group implements ILeafer {
125
127
  protected __checkAutoLayout(config: ILeaferConfig): void {
126
128
  if (!config.width || !config.height) {
127
129
  this.autoLayout = new AutoBounds(config)
128
- this.canvas.autoLayout(this.autoLayout, this.__onResize.bind(this))
130
+ this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this))
129
131
  }
130
132
  }
131
133
 
132
134
  public start(): void {
133
135
  if (!this.running) {
134
136
  Run.endOfName('FullCreate')
135
- this.__interactiveWindow()
136
- this.interaction?.start()
137
+ if (this.interaction) {
138
+ this.__interactiveWindow()
139
+ this.interaction.start()
140
+ }
137
141
  this.renderer.start()
138
142
  this.layouter.start()
139
143
  this.watcher.start()
@@ -143,7 +147,7 @@ export class Leafer extends Group implements ILeafer {
143
147
 
144
148
  public stop(): void {
145
149
  if (this.running) {
146
- this.interaction?.stop()
150
+ if (this.interaction) this.interaction.stop()
147
151
  this.watcher.stop()
148
152
  this.layouter.stop()
149
153
  this.renderer.stop()
@@ -152,12 +156,12 @@ export class Leafer extends Group implements ILeafer {
152
156
  }
153
157
 
154
158
  protected __interactiveWindow(): void {
155
- const { zoom, move } = this.config
156
- if (move) {
159
+ const { useZoom, useMove } = this.config
160
+ if (useMove) {
157
161
  const { MOVE } = MoveEvent
158
162
  const { ZOOM } = ZoomEvent
159
163
  if (!this.hasEvent(MOVE)) this.__eventIds.push(this.on__(MOVE, (e: MoveEvent) => { LeafHelper.moveOfWorld(this, e.moveX, e.moveY) }))
160
- if (zoom && !this.hasEvent(ZOOM)) this.__eventIds.push(this.on__(ZOOM, (e: ZoomEvent) => { LeafHelper.zoomOfWorld(this, e.scale, e) }))
164
+ if (useZoom && !this.hasEvent(ZOOM)) this.__eventIds.push(this.on__(ZOOM, (e: ZoomEvent) => { LeafHelper.zoomOfWorld(this, e.scale, e) }))
161
165
  }
162
166
  }
163
167