@leafer-ui/app 1.0.0-beta.2 → 1.0.0-beta.5
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 +7 -6
- package/src/App.ts +13 -4
- package/src/Leafer.ts +23 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/app",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
4
4
|
"description": "@leafer-ui/app",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leafer/core": "1.0.0-beta.
|
|
23
|
-
"@leafer-ui/display": "1.0.0-beta.
|
|
24
|
-
"@leafer-ui/
|
|
22
|
+
"@leafer/core": "1.0.0-beta.5",
|
|
23
|
+
"@leafer-ui/display": "1.0.0-beta.5",
|
|
24
|
+
"@leafer-ui/type": "1.0.0-beta.5",
|
|
25
|
+
"@leafer-ui/data": "1.0.0-beta.5"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
|
-
"@leafer/interface": "1.0.0-beta.
|
|
28
|
-
"@leafer-ui/interface": "1.0.0-beta.
|
|
28
|
+
"@leafer/interface": "1.0.0-beta.5",
|
|
29
|
+
"@leafer-ui/interface": "1.0.0-beta.5"
|
|
29
30
|
}
|
|
30
31
|
}
|
package/src/App.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ILeaferConfig, IResizeEvent, ILeaferCanvas, IRenderOptions, IApp, __Value } from '@leafer/interface'
|
|
2
|
-
import { DataHelper, Debug, LayoutEvent, PropertyEvent, RenderEvent, canvasSizeAttrs, registerUI } from '@leafer/core'
|
|
1
|
+
import { ILeaferConfig, IResizeEvent, ILeaferCanvas, IRenderOptions, IApp, __Value, IFunction } from '@leafer/interface'
|
|
2
|
+
import { DataHelper, Debug, LayoutEvent, Platform, PropertyEvent, RenderEvent, canvasSizeAttrs, registerUI } from '@leafer/core'
|
|
3
3
|
|
|
4
4
|
import { Leafer } from './Leafer'
|
|
5
5
|
|
|
@@ -70,6 +70,12 @@ export class App extends Leafer implements IApp {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
public waitViewLoaded(fun: IFunction): void {
|
|
74
|
+
const wait = () => { if (this.children.every(item => item.viewLoaded)) Platform.requestRender(fun) }
|
|
75
|
+
this.children.forEach(leafer => { leafer.waitViewLoaded(wait) })
|
|
76
|
+
if (!this.running) this.start()
|
|
77
|
+
}
|
|
78
|
+
|
|
73
79
|
protected __onChildRenderEnd(e: RenderEvent): void {
|
|
74
80
|
this.renderer.addBlock(e.renderBounds)
|
|
75
81
|
if (this.viewReady) this.renderer.update()
|
|
@@ -90,10 +96,13 @@ export class App extends Leafer implements IApp {
|
|
|
90
96
|
|
|
91
97
|
protected __getChildConfig(userConfig?: ILeaferConfig): ILeaferConfig {
|
|
92
98
|
let config = { ...this.config }
|
|
99
|
+
config.hittable = config.realCanvas = undefined
|
|
93
100
|
if (userConfig) DataHelper.assign(config, userConfig)
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
|
|
102
|
+
// reset
|
|
96
103
|
if (this.autoLayout) DataHelper.copyAttrs(config, this, canvasSizeAttrs)
|
|
104
|
+
config.view = this.realCanvas ? undefined : this.view
|
|
105
|
+
config.fill = undefined
|
|
97
106
|
return config
|
|
98
107
|
}
|
|
99
108
|
|
package/src/Leafer.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IApp, ILeafer, ILeaferCanvas, IRenderer, ILayouter, ISelector, IWatcher, IInteraction, ILeaferConfig, ICanvasManager, IHitCanvasManager, IImageManager, IAutoBounds, IScreenSizeData, IResizeEvent, ILeaf, IEventListenerId, ITransformEventData, ITimer, __Value, IObject, IControl } from '@leafer/interface'
|
|
2
|
-
import { AutoBounds, LayoutEvent, ResizeEvent, LeaferEvent, CanvasManager, HitCanvasManager, ImageManager, DataHelper, Creator, Run, Debug, RenderEvent, registerUI, boundsType, canvasSizeAttrs, dataProcessor } from '@leafer/core'
|
|
2
|
+
import { AutoBounds, LayoutEvent, ResizeEvent, LeaferEvent, CanvasManager, HitCanvasManager, ImageManager, DataHelper, Creator, Run, Debug, RenderEvent, registerUI, boundsType, canvasSizeAttrs, dataProcessor, Platform } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { ILeaferInputData, ILeaferData } from '@leafer-ui/interface'
|
|
4
|
+
import { ILeaferInputData, ILeaferData, IFunction } from '@leafer-ui/interface'
|
|
5
5
|
import { LeaferTypeCreator } from '@leafer-ui/type'
|
|
6
6
|
import { LeaferData } from '@leafer-ui/data'
|
|
7
7
|
import { Group } from '@leafer-ui/display'
|
|
@@ -29,6 +29,7 @@ export class Leafer extends Group implements ILeafer {
|
|
|
29
29
|
public running: boolean
|
|
30
30
|
public ready: boolean
|
|
31
31
|
public viewReady: boolean
|
|
32
|
+
public get viewLoaded(): boolean { return this.viewReady && !this.watcher.changed && this.imageManager.tasker.isComplete }
|
|
32
33
|
|
|
33
34
|
public view: unknown
|
|
34
35
|
|
|
@@ -74,7 +75,7 @@ export class Leafer extends Group implements ILeafer {
|
|
|
74
75
|
constructor(userConfig?: ILeaferConfig, data?: ILeaferInputData) {
|
|
75
76
|
super(data)
|
|
76
77
|
this.userConfig = userConfig
|
|
77
|
-
if (userConfig
|
|
78
|
+
if (userConfig && (userConfig.view || userConfig.width)) this.init(userConfig)
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
public init(userConfig?: ILeaferConfig, parentApp?: IApp): void {
|
|
@@ -147,6 +148,10 @@ export class Leafer extends Group implements ILeafer {
|
|
|
147
148
|
Object.keys(data).forEach(key => (this as any)[key] = data[key])
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
public forceLayout(): void {
|
|
152
|
+
this.__layout.checkUpdate(true)
|
|
153
|
+
}
|
|
154
|
+
|
|
150
155
|
public forceFullRender(): void {
|
|
151
156
|
this.renderer.addBlock(this.canvas.bounds)
|
|
152
157
|
if (this.viewReady) this.renderer.update()
|
|
@@ -187,6 +192,19 @@ export class Leafer extends Group implements ILeafer {
|
|
|
187
192
|
this.moveLayer = moveLayer || zoomLayer
|
|
188
193
|
}
|
|
189
194
|
|
|
195
|
+
public waitViewLoaded(fun: IFunction): void {
|
|
196
|
+
let id: IEventListenerId
|
|
197
|
+
const check = () => {
|
|
198
|
+
if (this.viewLoaded) {
|
|
199
|
+
if (id) this.off_(id)
|
|
200
|
+
Platform.requestRender(fun)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (!this.running) this.start()
|
|
204
|
+
check()
|
|
205
|
+
if (!this.viewLoaded) id = this.on_('render.after', check)
|
|
206
|
+
}
|
|
207
|
+
|
|
190
208
|
protected __checkAutoLayout(config: ILeaferConfig): void {
|
|
191
209
|
if (!config.width || !config.height) {
|
|
192
210
|
this.autoLayout = new AutoBounds(config)
|
|
@@ -201,7 +219,7 @@ export class Leafer extends Group implements ILeafer {
|
|
|
201
219
|
} else if (attrName === 'fill') {
|
|
202
220
|
this.__changeFill(newValue as string)
|
|
203
221
|
} else if (attrName === 'hittable') {
|
|
204
|
-
this.canvas.
|
|
222
|
+
this.canvas.hittable = newValue as boolean
|
|
205
223
|
}
|
|
206
224
|
}
|
|
207
225
|
super.__setAttr(attrName, newValue)
|
|
@@ -222,7 +240,7 @@ export class Leafer extends Group implements ILeafer {
|
|
|
222
240
|
protected __changeFill(newValue: string): void {
|
|
223
241
|
this.config.fill = newValue as string
|
|
224
242
|
if (this.canvas.allowBackgroundColor) {
|
|
225
|
-
this.canvas.
|
|
243
|
+
this.canvas.backgroundColor = newValue as string
|
|
226
244
|
} else {
|
|
227
245
|
this.forceFullRender()
|
|
228
246
|
}
|