@leafer-ui/display 1.0.10 → 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 +8 -8
- package/src/Group.ts +4 -4
- package/src/Leafer.ts +31 -25
- package/src/Text.ts +1 -1
- package/src/UI.ts +10 -5
- package/types/index.d.ts +7 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/display",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "@leafer-ui/display",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.
|
|
26
|
-
"@leafer-ui/data": "1.
|
|
27
|
-
"@leafer-ui/display-module": "1.
|
|
28
|
-
"@leafer-ui/decorator": "1.
|
|
29
|
-
"@leafer-ui/external": "1.
|
|
25
|
+
"@leafer/core": "1.1.1",
|
|
26
|
+
"@leafer-ui/data": "1.1.1",
|
|
27
|
+
"@leafer-ui/display-module": "1.1.1",
|
|
28
|
+
"@leafer-ui/decorator": "1.1.1",
|
|
29
|
+
"@leafer-ui/external": "1.1.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@leafer/interface": "1.
|
|
33
|
-
"@leafer-ui/interface": "1.
|
|
32
|
+
"@leafer/interface": "1.1.1",
|
|
33
|
+
"@leafer-ui/interface": "1.1.1"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/Group.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IJSONOptions, IPickOptions, IPickResult, IPointData } from '@leafer/interface'
|
|
2
2
|
import { Branch, useModule, dataProcessor, registerUI } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { IGroup, IGroupData, IGroupInputData, IUI, IUIInputData, IUIJSONData, IFindCondition, IFindUIMethod } from '@leafer-ui/interface'
|
|
4
|
+
import { IGroup, IGroupData, IGroupInputData, IUI, IUIInputData, IUIJSONData, ITransition, IFindCondition, IFindUIMethod } from '@leafer-ui/interface'
|
|
5
5
|
import { GroupData } from '@leafer-ui/data'
|
|
6
6
|
|
|
7
7
|
import { UI } from './UI'
|
|
@@ -36,19 +36,19 @@ export class Group extends UI implements IGroup { // tip: rewrited Box
|
|
|
36
36
|
|
|
37
37
|
// data
|
|
38
38
|
|
|
39
|
-
public set(data: IUIInputData,
|
|
39
|
+
public set(data: IUIInputData, transition?: ITransition | 'temp'): void {
|
|
40
40
|
if (data.children) {
|
|
41
41
|
const { children } = data
|
|
42
42
|
|
|
43
43
|
delete data.children
|
|
44
44
|
this.children ? this.clear() : this.__setBranch()
|
|
45
45
|
|
|
46
|
-
super.set(data,
|
|
46
|
+
super.set(data, transition)
|
|
47
47
|
|
|
48
48
|
children.forEach(child => this.add(child))
|
|
49
49
|
data.children = children
|
|
50
50
|
|
|
51
|
-
} else super.set(data,
|
|
51
|
+
} else super.set(data, transition)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
public toJSON(options?: IJSONOptions): IUIJSONData {
|
package/src/Leafer.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ILeaferCanvas, IRenderer, ILayouter, ISelector, IWatcher, IInteraction, ILeaferConfig, ICanvasManager, IHitCanvasManager, IAutoBounds, IScreenSizeData, IResizeEvent, IEventListenerId, ITimer, IValue, IObject, IControl, IPointData, ILeaferType, ICursorType, IBoundsData, INumber, IZoomType, IFourNumber, IBounds, IClientPointData } from '@leafer/interface'
|
|
2
2
|
import { AutoBounds, LayoutEvent, ResizeEvent, LeaferEvent, CanvasManager, ImageManager, DataHelper, Creator, Run, Debug, RenderEvent, registerUI, boundsType, canvasSizeAttrs, dataProcessor, WaitHelper, WatchEvent, Bounds, LeafList, needPlugin } from '@leafer/core'
|
|
3
3
|
|
|
4
|
-
import { ILeaferInputData, ILeaferData, IFunction, IUIInputData, ILeafer, IApp, IEditorBase } from '@leafer-ui/interface'
|
|
4
|
+
import { ILeaferInputData, ILeaferData, IFunction, IUIInputData, ITransition, ILeafer, IApp, IEditorBase } from '@leafer-ui/interface'
|
|
5
5
|
import { LeaferData } from '@leafer-ui/data'
|
|
6
6
|
|
|
7
7
|
import { Group } from './Group'
|
|
@@ -28,6 +28,7 @@ export class Leafer extends Group implements ILeafer {
|
|
|
28
28
|
|
|
29
29
|
public get isLeafer(): boolean { return true }
|
|
30
30
|
|
|
31
|
+
public parentApp?: IApp
|
|
31
32
|
declare public parent?: IApp
|
|
32
33
|
|
|
33
34
|
public running: boolean
|
|
@@ -60,20 +61,10 @@ export class Leafer extends Group implements ILeafer {
|
|
|
60
61
|
|
|
61
62
|
public userConfig: ILeaferConfig
|
|
62
63
|
public config: ILeaferConfig = {
|
|
63
|
-
type: 'design',
|
|
64
64
|
start: true,
|
|
65
65
|
hittable: true,
|
|
66
66
|
smooth: true,
|
|
67
|
-
lazySpeard: 100
|
|
68
|
-
zoom: {
|
|
69
|
-
min: 0.01,
|
|
70
|
-
max: 256
|
|
71
|
-
},
|
|
72
|
-
move: {
|
|
73
|
-
holdSpaceKey: true,
|
|
74
|
-
holdMiddleKey: true,
|
|
75
|
-
autoDistance: 2
|
|
76
|
-
}
|
|
67
|
+
lazySpeard: 100
|
|
77
68
|
}
|
|
78
69
|
|
|
79
70
|
public autoLayout?: IAutoBounds
|
|
@@ -104,13 +95,23 @@ export class Leafer extends Group implements ILeafer {
|
|
|
104
95
|
public init(userConfig?: ILeaferConfig, parentApp?: IApp): void {
|
|
105
96
|
if (this.canvas) return
|
|
106
97
|
|
|
107
|
-
this.__setLeafer(this)
|
|
108
|
-
if (userConfig) DataHelper.assign(this.config, userConfig)
|
|
109
|
-
|
|
110
98
|
let start: boolean
|
|
111
99
|
const { config } = this
|
|
112
100
|
|
|
113
|
-
this.
|
|
101
|
+
this.__setLeafer(this)
|
|
102
|
+
|
|
103
|
+
if (parentApp) {
|
|
104
|
+
this.parentApp = parentApp
|
|
105
|
+
this.__bindApp(parentApp)
|
|
106
|
+
start = parentApp.running
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (userConfig) {
|
|
110
|
+
this.parent = parentApp
|
|
111
|
+
this.initType(userConfig.type) // LeaferType
|
|
112
|
+
this.parent = undefined
|
|
113
|
+
DataHelper.assign(config, userConfig)
|
|
114
|
+
}
|
|
114
115
|
|
|
115
116
|
// render / layout
|
|
116
117
|
const canvas = this.canvas = Creator.canvas(config)
|
|
@@ -125,10 +126,7 @@ export class Leafer extends Group implements ILeafer {
|
|
|
125
126
|
this.view = canvas.view
|
|
126
127
|
|
|
127
128
|
// interaction / manager
|
|
128
|
-
if (parentApp) {
|
|
129
|
-
this.__bindApp(parentApp)
|
|
130
|
-
start = parentApp.running
|
|
131
|
-
} else {
|
|
129
|
+
if (!parentApp) {
|
|
132
130
|
this.selector = Creator.selector(this)
|
|
133
131
|
this.interaction = Creator.interaction(this, canvas, this.selector, config)
|
|
134
132
|
|
|
@@ -159,8 +157,8 @@ export class Leafer extends Group implements ILeafer {
|
|
|
159
157
|
|
|
160
158
|
public initType(_type: ILeaferType): void { } // rewrite in @leafer-ui/type
|
|
161
159
|
|
|
162
|
-
public set(data: IUIInputData): void {
|
|
163
|
-
this.waitInit(() => { super.set(data) })
|
|
160
|
+
public set(data: IUIInputData, transition?: ITransition | 'temp'): void {
|
|
161
|
+
this.waitInit(() => { super.set(data, transition) })
|
|
164
162
|
}
|
|
165
163
|
|
|
166
164
|
public start(): void {
|
|
@@ -199,7 +197,11 @@ export class Leafer extends Group implements ILeafer {
|
|
|
199
197
|
|
|
200
198
|
override forceRender(bounds?: IBoundsData): void {
|
|
201
199
|
this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds)
|
|
202
|
-
if (this.viewReady) this.renderer.
|
|
200
|
+
if (this.viewReady) this.renderer.render()
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
public requestRender(change = false): void {
|
|
204
|
+
if (this.renderer) this.renderer.update(change)
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
public updateCursor(cursor?: ICursorType): void {
|
|
@@ -309,7 +311,10 @@ export class Leafer extends Group implements ILeafer {
|
|
|
309
311
|
|
|
310
312
|
const { imageReady } = this
|
|
311
313
|
if (imageReady && !this.viewCompleted) this.__checkViewCompleted()
|
|
312
|
-
if (!imageReady)
|
|
314
|
+
if (!imageReady) {
|
|
315
|
+
this.viewCompleted = false
|
|
316
|
+
this.requestRender()
|
|
317
|
+
}
|
|
313
318
|
}
|
|
314
319
|
}
|
|
315
320
|
|
|
@@ -360,6 +365,7 @@ export class Leafer extends Group implements ILeafer {
|
|
|
360
365
|
if (list[i] === item) { list.splice(i, 1); break }
|
|
361
366
|
}
|
|
362
367
|
} else list.push(item)
|
|
368
|
+
this.requestRender()
|
|
363
369
|
}
|
|
364
370
|
|
|
365
371
|
// need view plugin
|
|
@@ -436,7 +442,7 @@ export class Leafer extends Group implements ILeafer {
|
|
|
436
442
|
|
|
437
443
|
this.canvas.destroy()
|
|
438
444
|
|
|
439
|
-
this.config.view = this.view = null
|
|
445
|
+
this.config.view = this.view = this.parentApp = null
|
|
440
446
|
if (this.userConfig) this.userConfig.view = null
|
|
441
447
|
|
|
442
448
|
super.destroy()
|
package/src/Text.ts
CHANGED
package/src/UI.ts
CHANGED
|
@@ -306,6 +306,9 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
|
|
|
306
306
|
|
|
307
307
|
public motionPath?: boolean
|
|
308
308
|
|
|
309
|
+
public motionPrecision?: INumber
|
|
310
|
+
|
|
311
|
+
|
|
309
312
|
public motion?: INumber | IUnitData
|
|
310
313
|
|
|
311
314
|
public motionRotation?: INumber | IBoolean
|
|
@@ -377,11 +380,13 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
|
|
|
377
380
|
public reset(_data?: IUIInputData): void { }
|
|
378
381
|
|
|
379
382
|
|
|
380
|
-
public set(data: IUIInputData,
|
|
381
|
-
if (
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
383
|
+
public set(data: IUIInputData, transition?: ITransition | 'temp'): void {
|
|
384
|
+
if (transition) {
|
|
385
|
+
if (transition === 'temp') {
|
|
386
|
+
this.lockNormalStyle = true
|
|
387
|
+
Object.assign(this, data)
|
|
388
|
+
this.lockNormalStyle = false
|
|
389
|
+
} else this.animate(data, transition)
|
|
385
390
|
} else Object.assign(this, data)
|
|
386
391
|
}
|
|
387
392
|
|
package/types/index.d.ts
CHANGED
|
@@ -91,6 +91,7 @@ declare class UI extends Leaf implements IUI {
|
|
|
91
91
|
transition?: ITransition;
|
|
92
92
|
transitionOut?: ITransition;
|
|
93
93
|
motionPath?: boolean;
|
|
94
|
+
motionPrecision?: INumber;
|
|
94
95
|
motion?: INumber | IUnitData;
|
|
95
96
|
motionRotation?: INumber | IBoolean;
|
|
96
97
|
states?: IStates;
|
|
@@ -114,7 +115,7 @@ declare class UI extends Leaf implements IUI {
|
|
|
114
115
|
get editInner(): string;
|
|
115
116
|
constructor(data?: IUIInputData);
|
|
116
117
|
reset(_data?: IUIInputData): void;
|
|
117
|
-
set(data: IUIInputData,
|
|
118
|
+
set(data: IUIInputData, transition?: ITransition | 'temp'): void;
|
|
118
119
|
get(name?: string | string[] | IUIInputData): IUIInputData | IValue;
|
|
119
120
|
createProxyData(): IUIInputData;
|
|
120
121
|
find(_condition: number | string | IFindCondition | IFindUIMethod, _options?: any): IUI[];
|
|
@@ -151,7 +152,7 @@ declare class Group extends UI implements IGroup {
|
|
|
151
152
|
constructor(data?: IGroupInputData);
|
|
152
153
|
reset(data?: IGroupInputData): void;
|
|
153
154
|
__setBranch(): void;
|
|
154
|
-
set(data: IUIInputData,
|
|
155
|
+
set(data: IUIInputData, transition?: ITransition | 'temp'): void;
|
|
155
156
|
toJSON(options?: IJSONOptions): IUIJSONData;
|
|
156
157
|
pick(_hitPoint: IPointData, _options?: IPickOptions): IPickResult;
|
|
157
158
|
addAt(child: IUI | IUI[] | IUIInputData | IUIInputData[], index: number): void;
|
|
@@ -172,6 +173,7 @@ declare class Leafer extends Group implements ILeafer {
|
|
|
172
173
|
get isApp(): boolean;
|
|
173
174
|
get app(): ILeafer;
|
|
174
175
|
get isLeafer(): boolean;
|
|
176
|
+
parentApp?: IApp;
|
|
175
177
|
parent?: IApp;
|
|
176
178
|
running: boolean;
|
|
177
179
|
created: boolean;
|
|
@@ -211,13 +213,14 @@ declare class Leafer extends Group implements ILeafer {
|
|
|
211
213
|
init(userConfig?: ILeaferConfig, parentApp?: IApp): void;
|
|
212
214
|
onInit(): void;
|
|
213
215
|
initType(_type: ILeaferType): void;
|
|
214
|
-
set(data: IUIInputData): void;
|
|
216
|
+
set(data: IUIInputData, transition?: ITransition | 'temp'): void;
|
|
215
217
|
start(): void;
|
|
216
218
|
stop(): void;
|
|
217
219
|
unlockLayout(): void;
|
|
218
220
|
lockLayout(): void;
|
|
219
221
|
resize(size: IScreenSizeData): void;
|
|
220
222
|
forceRender(bounds?: IBoundsData): void;
|
|
223
|
+
requestRender(change?: boolean): void;
|
|
221
224
|
updateCursor(cursor?: ICursorType): void;
|
|
222
225
|
updateLazyBounds(): void;
|
|
223
226
|
protected __doResize(size: IScreenSizeData): void;
|
|
@@ -383,7 +386,7 @@ declare class Text extends UI implements IText {
|
|
|
383
386
|
fill?: IFill;
|
|
384
387
|
strokeAlign?: IStrokeAlign;
|
|
385
388
|
hitFill?: IHitType$1;
|
|
386
|
-
text?: IString;
|
|
389
|
+
text?: IString | INumber;
|
|
387
390
|
fontFamily?: IString;
|
|
388
391
|
fontSize?: INumber;
|
|
389
392
|
fontWeight?: IFontWeight;
|