@leafer-ui/app 1.6.1 → 1.6.3
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 +6 -6
- package/src/App.ts +14 -11
- package/types/index.d.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/app",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"description": "@leafer-ui/app",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.6.
|
|
26
|
-
"@leafer-ui/display": "1.6.
|
|
27
|
-
"@leafer-ui/data": "1.6.
|
|
25
|
+
"@leafer/core": "1.6.3",
|
|
26
|
+
"@leafer-ui/display": "1.6.3",
|
|
27
|
+
"@leafer-ui/data": "1.6.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@leafer/interface": "1.6.
|
|
31
|
-
"@leafer-ui/interface": "1.6.
|
|
30
|
+
"@leafer/interface": "1.6.3",
|
|
31
|
+
"@leafer-ui/interface": "1.6.3"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/App.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ILeaferConfig, IResizeEvent, ILeaferCanvas, IRenderOptions, ILeaferBase, IBoundsData } from '@leafer/interface'
|
|
2
2
|
import { Creator, DataHelper, LayoutEvent, RenderEvent, canvasSizeAttrs, registerUI } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { IApp, IAppConfig,
|
|
4
|
+
import { IApp, IAppConfig, IAppForEachFunction, IAppInputData, ILeafer } from '@leafer-ui/interface'
|
|
5
5
|
|
|
6
6
|
import { Leafer } from '@leafer-ui/draw'
|
|
7
7
|
|
|
@@ -32,7 +32,7 @@ export class App extends Leafer implements IApp {
|
|
|
32
32
|
if (ground) this.ground = this.addLeafer(ground)
|
|
33
33
|
if (tree || editor) this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' })
|
|
34
34
|
if (sky || editor) this.sky = this.addLeafer(sky)
|
|
35
|
-
if (editor)
|
|
35
|
+
if (editor) Creator.editor(editor, this)
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -47,6 +47,11 @@ export class App extends Leafer implements IApp {
|
|
|
47
47
|
this.layouter.disable()
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
override __updateLocalBounds(): void {
|
|
51
|
+
this.forEach(leafer => leafer.updateLayout())
|
|
52
|
+
super.__updateLocalBounds()
|
|
53
|
+
}
|
|
54
|
+
|
|
50
55
|
override start(): void {
|
|
51
56
|
super.start()
|
|
52
57
|
this.forEach(leafer => leafer.start())
|
|
@@ -91,7 +96,7 @@ export class App extends Leafer implements IApp {
|
|
|
91
96
|
this.__listenChildEvents(leafer)
|
|
92
97
|
}
|
|
93
98
|
|
|
94
|
-
public forEach(fn:
|
|
99
|
+
public forEach(fn: IAppForEachFunction): void {
|
|
95
100
|
this.children.forEach(fn)
|
|
96
101
|
}
|
|
97
102
|
|
|
@@ -113,11 +118,7 @@ export class App extends Leafer implements IApp {
|
|
|
113
118
|
}
|
|
114
119
|
|
|
115
120
|
override __render(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
116
|
-
if (canvas.context)
|
|
117
|
-
const m = options.matrix
|
|
118
|
-
if (m) canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f) // screenshot
|
|
119
|
-
this.forEach(leafer => canvas.copyWorld(leafer.canvas))
|
|
120
|
-
}
|
|
121
|
+
if (canvas.context) this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options && options.bounds))
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
public __onResize(event: IResizeEvent): void {
|
|
@@ -142,9 +143,11 @@ export class App extends Leafer implements IApp {
|
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
protected __listenChildEvents(leafer: ILeaferBase): void {
|
|
145
|
-
leafer.once(
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
leafer.once([
|
|
147
|
+
[LayoutEvent.END, this.__onReady, this],
|
|
148
|
+
[RenderEvent.START, this.__onCreated, this],
|
|
149
|
+
[RenderEvent.END, this.__onViewReady, this]
|
|
150
|
+
])
|
|
148
151
|
if (this.realCanvas) this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this))
|
|
149
152
|
}
|
|
150
153
|
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IBoundsData, ILeaferConfig, ILeaferCanvas, IRenderOptions, IResizeEvent, ILeaferBase } from '@leafer/interface';
|
|
2
2
|
import { RenderEvent } from '@leafer/core';
|
|
3
|
-
import { IApp, ILeafer, IAppConfig, IAppInputData,
|
|
3
|
+
import { IApp, ILeafer, IAppConfig, IAppInputData, IAppForEachFunction } from '@leafer-ui/interface';
|
|
4
4
|
import { Leafer } from '@leafer-ui/draw';
|
|
5
5
|
|
|
6
6
|
declare class App extends Leafer implements IApp {
|
|
@@ -14,6 +14,7 @@ declare class App extends Leafer implements IApp {
|
|
|
14
14
|
constructor(userConfig?: IAppConfig, data?: IAppInputData);
|
|
15
15
|
init(userConfig?: IAppConfig, parentApp?: IApp): void;
|
|
16
16
|
protected __setApp(): void;
|
|
17
|
+
__updateLocalBounds(): void;
|
|
17
18
|
start(): void;
|
|
18
19
|
stop(): void;
|
|
19
20
|
unlockLayout(): void;
|
|
@@ -21,7 +22,7 @@ declare class App extends Leafer implements IApp {
|
|
|
21
22
|
forceRender(bounds?: IBoundsData, sync?: boolean): void;
|
|
22
23
|
addLeafer(merge?: ILeaferConfig): Leafer;
|
|
23
24
|
add(leafer: ILeafer, index?: number): void;
|
|
24
|
-
forEach(fn:
|
|
25
|
+
forEach(fn: IAppForEachFunction): void;
|
|
25
26
|
protected __onCreated(): void;
|
|
26
27
|
protected __onReady(): void;
|
|
27
28
|
protected __onViewReady(): void;
|