@leafer-ui/app 1.0.0-rc.7 → 1.0.0-rc.8
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 -7
- package/src/App.ts +4 -8
- package/src/Leafer.ts +22 -23
- package/types/index.d.ts +7 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/app",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.8",
|
|
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.
|
|
26
|
-
"@leafer-ui/display": "1.0.0-rc.
|
|
27
|
-
"@leafer-ui/type": "1.0.0-rc.
|
|
28
|
-
"@leafer-ui/data": "1.0.0-rc.
|
|
25
|
+
"@leafer/core": "1.0.0-rc.8",
|
|
26
|
+
"@leafer-ui/display": "1.0.0-rc.8",
|
|
27
|
+
"@leafer-ui/type": "1.0.0-rc.8",
|
|
28
|
+
"@leafer-ui/data": "1.0.0-rc.8"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@leafer/interface": "1.0.0-rc.
|
|
32
|
-
"@leafer-ui/interface": "1.0.0-rc.
|
|
31
|
+
"@leafer/interface": "1.0.0-rc.8",
|
|
32
|
+
"@leafer-ui/interface": "1.0.0-rc.8"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/App.ts
CHANGED
|
@@ -17,9 +17,9 @@ export class App extends Leafer implements IApp {
|
|
|
17
17
|
|
|
18
18
|
public realCanvas: boolean
|
|
19
19
|
|
|
20
|
-
public ground
|
|
21
|
-
public tree
|
|
22
|
-
public sky
|
|
20
|
+
public ground: ILeafer
|
|
21
|
+
public tree: ILeafer
|
|
22
|
+
public sky: ILeafer
|
|
23
23
|
|
|
24
24
|
constructor(userConfig?: IAppConfig, data?: IAppInputData) {
|
|
25
25
|
super(userConfig, data)
|
|
@@ -106,10 +106,6 @@ export class App extends Leafer implements IApp {
|
|
|
106
106
|
if (this.children.every(child => child.viewReady)) super.__onViewReady()
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
protected __checkViewCompleted(): boolean {
|
|
110
|
-
return this.children.every(item => item.viewCompleted)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
109
|
protected __onChildRenderEnd(e: RenderEvent): void {
|
|
114
110
|
this.renderer.addBlock(e.renderBounds)
|
|
115
111
|
if (this.viewReady) this.renderer.update()
|
|
@@ -143,7 +139,7 @@ export class App extends Leafer implements IApp {
|
|
|
143
139
|
protected __listenChildEvents(leafer: ILeaferBase): void {
|
|
144
140
|
leafer.once(LayoutEvent.END, () => this.__onReady())
|
|
145
141
|
leafer.once(RenderEvent.START, () => this.__onCreated())
|
|
146
|
-
leafer.once(RenderEvent.END, (
|
|
142
|
+
leafer.once(RenderEvent.END, () => this.__onViewReady())
|
|
147
143
|
if (this.realCanvas) this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this))
|
|
148
144
|
}
|
|
149
145
|
|
package/src/Leafer.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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, registerUI, boundsType, canvasSizeAttrs, dataProcessor, PluginManager, WaitHelper, WatchEvent } from '@leafer/core'
|
|
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
3
|
|
|
4
4
|
import { ILeaferInputData, ILeaferData, IFunction, IUIInputData, ILeafer, IGroup, IApp, IEditorBase } from '@leafer-ui/interface'
|
|
5
5
|
import { LeaferTypeCreator } from '@leafer-ui/type'
|
|
@@ -30,6 +30,7 @@ export class Leafer extends Group implements ILeafer {
|
|
|
30
30
|
public ready: boolean
|
|
31
31
|
public viewReady: boolean
|
|
32
32
|
public viewCompleted: boolean
|
|
33
|
+
public get imageReady(): boolean { return this.viewReady && ImageManager.isComplete }
|
|
33
34
|
public get layoutLocked() { return !this.layouter.running }
|
|
34
35
|
|
|
35
36
|
public view: unknown
|
|
@@ -283,23 +284,24 @@ export class Leafer extends Group implements ILeafer {
|
|
|
283
284
|
WaitHelper.run(this.__viewReadyWait)
|
|
284
285
|
}
|
|
285
286
|
|
|
286
|
-
protected
|
|
287
|
-
if (
|
|
288
|
-
|
|
289
|
-
if (completed) this.__onViewCompleted()
|
|
290
|
-
this.viewCompleted = completed
|
|
291
|
-
WaitHelper.run(this.__nextRenderWait)
|
|
292
|
-
}
|
|
287
|
+
protected __onAnimateFrame(): void {
|
|
288
|
+
if (this.viewReady) {
|
|
289
|
+
if (this.__nextRenderWait.length) WaitHelper.run(this.__nextRenderWait)
|
|
293
290
|
|
|
294
|
-
|
|
295
|
-
|
|
291
|
+
const { imageReady } = this
|
|
292
|
+
if (imageReady && !this.viewCompleted) this.__checkViewCompleted()
|
|
293
|
+
if (!imageReady) this.viewCompleted = false
|
|
294
|
+
}
|
|
296
295
|
}
|
|
297
296
|
|
|
298
|
-
protected
|
|
299
|
-
|
|
300
|
-
this.
|
|
301
|
-
|
|
302
|
-
|
|
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
|
+
})
|
|
303
305
|
}
|
|
304
306
|
|
|
305
307
|
protected __onWatchData(): void {
|
|
@@ -317,20 +319,16 @@ export class Leafer extends Group implements ILeafer {
|
|
|
317
319
|
}
|
|
318
320
|
|
|
319
321
|
public waitViewCompleted(item: IFunction): void {
|
|
322
|
+
this.__viewCompletedWait.push(item)
|
|
320
323
|
if (this.viewCompleted) {
|
|
321
|
-
|
|
324
|
+
this.__checkViewCompleted(false)
|
|
322
325
|
} else {
|
|
323
|
-
this.__viewCompletedWait.push(item)
|
|
324
326
|
if (!this.running) this.start()
|
|
325
327
|
}
|
|
326
328
|
}
|
|
327
329
|
|
|
328
330
|
public nextRender(item: IFunction): void {
|
|
329
|
-
|
|
330
|
-
item()
|
|
331
|
-
} else {
|
|
332
|
-
this.__nextRenderWait.push(item)
|
|
333
|
-
}
|
|
331
|
+
this.__nextRenderWait.push(item)
|
|
334
332
|
}
|
|
335
333
|
|
|
336
334
|
protected __checkUpdateLayout(): void {
|
|
@@ -346,9 +344,10 @@ export class Leafer extends Group implements ILeafer {
|
|
|
346
344
|
this.once(LeaferEvent.START, () => Run.end(runId))
|
|
347
345
|
this.once(LayoutEvent.END, () => this.__onReady())
|
|
348
346
|
this.once(RenderEvent.START, () => this.__onCreated())
|
|
347
|
+
this.once(RenderEvent.END, () => this.__onViewReady())
|
|
349
348
|
this.__eventIds.push(
|
|
350
349
|
this.on_(WatchEvent.DATA, this.__onWatchData, this),
|
|
351
|
-
this.on_(
|
|
350
|
+
this.on_(AnimateEvent.FRAME, this.__onAnimateFrame, this),
|
|
352
351
|
this.on_(LayoutEvent.CHECK_UPDATE, this.__checkUpdateLayout, this)
|
|
353
352
|
)
|
|
354
353
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
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 { RenderEvent } from '@leafer/core';
|
|
3
2
|
import { ILeafer, ILeaferData, IApp, IEditorBase, IGroup, IFunction, ILeaferInputData, IUIInputData, IAppConfig, IAppInputData } from '@leafer-ui/interface';
|
|
4
3
|
import { Group } from '@leafer-ui/display';
|
|
4
|
+
import { RenderEvent } from '@leafer/core';
|
|
5
5
|
|
|
6
6
|
declare class Leafer extends Group implements ILeafer {
|
|
7
7
|
get __tag(): string;
|
|
@@ -15,6 +15,7 @@ declare class Leafer extends Group implements ILeafer {
|
|
|
15
15
|
ready: boolean;
|
|
16
16
|
viewReady: boolean;
|
|
17
17
|
viewCompleted: boolean;
|
|
18
|
+
get imageReady(): boolean;
|
|
18
19
|
get layoutLocked(): boolean;
|
|
19
20
|
view: unknown;
|
|
20
21
|
canvas: ILeaferCanvas;
|
|
@@ -63,9 +64,8 @@ declare class Leafer extends Group implements ILeafer {
|
|
|
63
64
|
protected __onCreated(): void;
|
|
64
65
|
protected __onReady(): void;
|
|
65
66
|
protected __onViewReady(): void;
|
|
66
|
-
protected
|
|
67
|
-
protected __checkViewCompleted():
|
|
68
|
-
protected __onViewCompleted(): void;
|
|
67
|
+
protected __onAnimateFrame(): void;
|
|
68
|
+
protected __checkViewCompleted(emit?: boolean): void;
|
|
69
69
|
protected __onWatchData(): void;
|
|
70
70
|
waitReady(item: IFunction): void;
|
|
71
71
|
waitViewReady(item: IFunction): void;
|
|
@@ -83,9 +83,9 @@ declare class App extends Leafer implements IApp {
|
|
|
83
83
|
get isApp(): boolean;
|
|
84
84
|
children: ILeafer[];
|
|
85
85
|
realCanvas: boolean;
|
|
86
|
-
ground
|
|
87
|
-
tree
|
|
88
|
-
sky
|
|
86
|
+
ground: ILeafer;
|
|
87
|
+
tree: ILeafer;
|
|
88
|
+
sky: ILeafer;
|
|
89
89
|
constructor(userConfig?: IAppConfig, data?: IAppInputData);
|
|
90
90
|
protected __setApp(): void;
|
|
91
91
|
start(): void;
|
|
@@ -98,7 +98,6 @@ declare class App extends Leafer implements IApp {
|
|
|
98
98
|
protected __onCreated(): void;
|
|
99
99
|
protected __onReady(): void;
|
|
100
100
|
protected __onViewReady(): void;
|
|
101
|
-
protected __checkViewCompleted(): boolean;
|
|
102
101
|
protected __onChildRenderEnd(e: RenderEvent): void;
|
|
103
102
|
__render(canvas: ILeaferCanvas, _options: IRenderOptions): void;
|
|
104
103
|
__onResize(event: IResizeEvent): void;
|