@leafer/renderer 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 +3 -3
- package/src/Renderer.ts +12 -12
- package/types/index.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/renderer",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "@leafer/renderer",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.1.
|
|
25
|
+
"@leafer/core": "1.1.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@leafer/interface": "1.1.
|
|
28
|
+
"@leafer/interface": "1.1.1"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/Renderer.ts
CHANGED
|
@@ -30,6 +30,7 @@ export class Renderer implements IRenderer {
|
|
|
30
30
|
protected renderOptions: IRenderOptions
|
|
31
31
|
protected totalBounds: IBounds
|
|
32
32
|
|
|
33
|
+
protected requestTime: number
|
|
33
34
|
protected __eventIds: IEventListenerId[]
|
|
34
35
|
|
|
35
36
|
protected get needFill(): boolean { return !!(!this.canvas.allowBackgroundColor && this.config.fill) }
|
|
@@ -39,19 +40,20 @@ export class Renderer implements IRenderer {
|
|
|
39
40
|
this.canvas = canvas
|
|
40
41
|
if (userConfig) this.config = DataHelper.default(userConfig, this.config)
|
|
41
42
|
this.__listenEvents()
|
|
42
|
-
this.__requestRender()
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
public start(): void {
|
|
46
46
|
this.running = true
|
|
47
|
+
this.update(false)
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
public stop(): void {
|
|
50
51
|
this.running = false
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
public update(): void {
|
|
54
|
-
this.changed =
|
|
54
|
+
public update(change = true): void {
|
|
55
|
+
if (!this.changed) this.changed = change
|
|
56
|
+
this.__requestRender()
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
public requestLayout(): void {
|
|
@@ -59,10 +61,7 @@ export class Renderer implements IRenderer {
|
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
public render(callback?: IFunction): void {
|
|
62
|
-
if (!(this.running && this.canvas.view))
|
|
63
|
-
this.changed = true
|
|
64
|
-
return
|
|
65
|
-
}
|
|
64
|
+
if (!(this.running && this.canvas.view)) return this.update()
|
|
66
65
|
|
|
67
66
|
const { target } = this
|
|
68
67
|
this.times = 0
|
|
@@ -218,16 +217,17 @@ export class Renderer implements IRenderer {
|
|
|
218
217
|
}
|
|
219
218
|
|
|
220
219
|
protected __requestRender(): void {
|
|
221
|
-
|
|
220
|
+
if (this.requestTime) return
|
|
221
|
+
|
|
222
|
+
const requestTime = this.requestTime = Date.now()
|
|
222
223
|
Platform.requestRender(() => {
|
|
223
|
-
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() -
|
|
224
|
+
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)))
|
|
225
|
+
this.requestTime = 0
|
|
224
226
|
|
|
225
227
|
if (this.running) {
|
|
226
228
|
if (this.changed && this.canvas.view) this.render()
|
|
227
229
|
this.target.emit(RenderEvent.NEXT)
|
|
228
230
|
}
|
|
229
|
-
|
|
230
|
-
if (this.target) this.__requestRender()
|
|
231
231
|
})
|
|
232
232
|
}
|
|
233
233
|
|
|
@@ -245,7 +245,7 @@ export class Renderer implements IRenderer {
|
|
|
245
245
|
|
|
246
246
|
// 需要象征性派发一下渲染事件
|
|
247
247
|
this.addBlock(new Bounds(0, 0, 1, 1))
|
|
248
|
-
this.
|
|
248
|
+
this.update()
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
protected __onLayoutEnd(event: LayoutEvent): void {
|
package/types/index.d.ts
CHANGED
|
@@ -17,12 +17,13 @@ declare class Renderer implements IRenderer {
|
|
|
17
17
|
protected renderBounds: IBounds;
|
|
18
18
|
protected renderOptions: IRenderOptions;
|
|
19
19
|
protected totalBounds: IBounds;
|
|
20
|
+
protected requestTime: number;
|
|
20
21
|
protected __eventIds: IEventListenerId[];
|
|
21
22
|
protected get needFill(): boolean;
|
|
22
23
|
constructor(target: ILeaf, canvas: ILeaferCanvas, userConfig?: IRendererConfig);
|
|
23
24
|
start(): void;
|
|
24
25
|
stop(): void;
|
|
25
|
-
update(): void;
|
|
26
|
+
update(change?: boolean): void;
|
|
26
27
|
requestLayout(): void;
|
|
27
28
|
render(callback?: IFunction): void;
|
|
28
29
|
renderAgain(): void;
|