@leafer/display 1.0.0-rc.12 → 1.0.0-rc.17
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 +10 -10
- package/src/Branch.ts +3 -7
- package/src/Leaf.ts +13 -7
- package/types/index.d.ts +9 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/display",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.17",
|
|
4
4
|
"description": "@leafer/display",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/math": "1.0.0-rc.
|
|
26
|
-
"@leafer/data": "1.0.0-rc.
|
|
27
|
-
"@leafer/layout": "1.0.0-rc.
|
|
28
|
-
"@leafer/display-module": "1.0.0-rc.
|
|
29
|
-
"@leafer/event": "1.0.0-rc.
|
|
30
|
-
"@leafer/decorator": "1.0.0-rc.
|
|
31
|
-
"@leafer/helper": "1.0.0-rc.
|
|
32
|
-
"@leafer/platform": "1.0.0-rc.
|
|
25
|
+
"@leafer/math": "1.0.0-rc.17",
|
|
26
|
+
"@leafer/data": "1.0.0-rc.17",
|
|
27
|
+
"@leafer/layout": "1.0.0-rc.17",
|
|
28
|
+
"@leafer/display-module": "1.0.0-rc.17",
|
|
29
|
+
"@leafer/event": "1.0.0-rc.17",
|
|
30
|
+
"@leafer/decorator": "1.0.0-rc.17",
|
|
31
|
+
"@leafer/helper": "1.0.0-rc.17",
|
|
32
|
+
"@leafer/platform": "1.0.0-rc.17"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@leafer/interface": "1.0.0-rc.
|
|
35
|
+
"@leafer/interface": "1.0.0-rc.17"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/Branch.ts
CHANGED
|
@@ -16,12 +16,6 @@ const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds
|
|
|
16
16
|
@useModule(BranchRender)
|
|
17
17
|
export class Branch extends Leaf {
|
|
18
18
|
|
|
19
|
-
constructor() {
|
|
20
|
-
super()
|
|
21
|
-
this.isBranch = true
|
|
22
|
-
this.children = []
|
|
23
|
-
}
|
|
24
|
-
|
|
25
19
|
// overwrite
|
|
26
20
|
|
|
27
21
|
public __updateStrokeSpread(): number {
|
|
@@ -69,6 +63,8 @@ export class Branch extends Leaf {
|
|
|
69
63
|
}
|
|
70
64
|
|
|
71
65
|
public add(child: ILeaf, index?: number): void {
|
|
66
|
+
if (child === this) return
|
|
67
|
+
|
|
72
68
|
if (child.parent) child.parent.remove(child)
|
|
73
69
|
child.parent = this
|
|
74
70
|
|
|
@@ -90,7 +86,7 @@ export class Branch extends Leaf {
|
|
|
90
86
|
children.forEach(child => this.add(child))
|
|
91
87
|
}
|
|
92
88
|
|
|
93
|
-
public remove(child?:
|
|
89
|
+
public remove(child?: ILeaf, destroy?: boolean): void {
|
|
94
90
|
if (child) {
|
|
95
91
|
const index = this.children.indexOf(child)
|
|
96
92
|
if (index > -1) {
|
package/src/Leaf.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ILeaferBase, ILeaf, ILeafInputData, ILeafData, ILeaferCanvas, IRenderOptions, IBoundsType, ILocationType, IMatrixWithBoundsData, ILayoutBoundsData, IValue, ILeafLayout, InnerId, IHitCanvas, IRadiusPointData, IEventListenerMap, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IObject, IFunction, IPointData, IBoundsData, IBranch, IFindMethod, ILayoutAttr, IMatrixData, IAttrDecorator, IMatrixWithBoundsScaleData } from '@leafer/interface'
|
|
1
|
+
import { ILeaferBase, ILeaf, ILeafInputData, ILeafData, ILeaferCanvas, IRenderOptions, IBoundsType, ILocationType, IMatrixWithBoundsData, ILayoutBoundsData, IValue, ILeafLayout, InnerId, IHitCanvas, IRadiusPointData, IEventListenerMap, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IObject, IFunction, IPointData, IBoundsData, IBranch, IFindMethod, ILayoutAttr, IMatrixData, IAttrDecorator, IMatrixWithBoundsScaleData, IMatrixWithScaleData } from '@leafer/interface'
|
|
2
2
|
import { BoundsHelper, IncrementId, MatrixHelper, PointHelper } from '@leafer/math'
|
|
3
3
|
import { LeafData } from '@leafer/data'
|
|
4
4
|
import { LeafLayout } from '@leafer/layout'
|
|
5
5
|
import { LeafDataProxy, LeafMatrix, LeafBounds, LeafEventer, LeafRender } from '@leafer/display-module'
|
|
6
6
|
import { boundsType, useModule, defineDataProcessor } from '@leafer/decorator'
|
|
7
7
|
import { LeafHelper, WaitHelper } from '@leafer/helper'
|
|
8
|
+
import { ChildEvent } from '@leafer/event'
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
const { LEAF, create } = IncrementId
|
|
@@ -34,9 +35,9 @@ export class Leaf implements ILeaf {
|
|
|
34
35
|
public leafer?: ILeaferBase
|
|
35
36
|
public parent?: ILeaf
|
|
36
37
|
|
|
37
|
-
public isLeafer: boolean
|
|
38
|
-
public isBranch: boolean
|
|
39
|
-
public isBranchLeaf: boolean
|
|
38
|
+
public get isLeafer(): boolean { return false }
|
|
39
|
+
public get isBranch(): boolean { return false }
|
|
40
|
+
public get isBranchLeaf(): boolean { return false }
|
|
40
41
|
|
|
41
42
|
public __: ILeafData
|
|
42
43
|
public __layout: ILeafLayout
|
|
@@ -53,7 +54,7 @@ export class Leaf implements ILeaf {
|
|
|
53
54
|
public __worldOpacity: number
|
|
54
55
|
|
|
55
56
|
// now transform
|
|
56
|
-
public get worldTransform():
|
|
57
|
+
public get worldTransform(): IMatrixWithScaleData { return this.__layout.getTransform('world') as IMatrixWithScaleData }
|
|
57
58
|
public get localTransform(): IMatrixData { return this.__layout.getTransform('local') }
|
|
58
59
|
|
|
59
60
|
// now bounds
|
|
@@ -79,6 +80,9 @@ export class Leaf implements ILeaf {
|
|
|
79
80
|
public get __onlyHitMask(): boolean { return this.__hasMask && !this.__.hitChildren }
|
|
80
81
|
public get __ignoreHitWorld(): boolean { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren }
|
|
81
82
|
|
|
83
|
+
public get pathInputed(): boolean { return !!this.__.__pathInputed }
|
|
84
|
+
public pathClosed: boolean
|
|
85
|
+
|
|
82
86
|
// event
|
|
83
87
|
public __captureMap?: IEventListenerMap
|
|
84
88
|
public __bubbleMap?: IEventListenerMap
|
|
@@ -159,7 +163,7 @@ export class Leaf implements ILeaf {
|
|
|
159
163
|
// data
|
|
160
164
|
|
|
161
165
|
public set(_data: IObject): void { }
|
|
162
|
-
public get(): ILeafInputData { return undefined }
|
|
166
|
+
public get(_name?: string): ILeafInputData | IValue { return undefined }
|
|
163
167
|
|
|
164
168
|
public toJSON(): IObject {
|
|
165
169
|
return this.__.__getInputData()
|
|
@@ -510,8 +514,10 @@ export class Leaf implements ILeaf {
|
|
|
510
514
|
|
|
511
515
|
public destroy(): void {
|
|
512
516
|
if (!this.destroyed) {
|
|
513
|
-
|
|
517
|
+
const { parent } = this
|
|
518
|
+
if (parent) this.remove()
|
|
514
519
|
if (this.children) (this as unknown as IBranch).removeAll(true)
|
|
520
|
+
if (this.hasEvent(ChildEvent.DESTROY)) this.emitEvent(new ChildEvent(ChildEvent.DESTROY, this, parent))
|
|
515
521
|
|
|
516
522
|
this.__.destroy()
|
|
517
523
|
this.__layout.destroy()
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILeaf, InnerId, ILeaferBase, ILeafData, ILeafLayout, IMatrixWithBoundsScaleData, IMatrixWithBoundsData, IMatrixData, IBoundsData, IHitCanvas, IEventListenerMap, IFunction, ILeafInputData, IObject, IValue, IFindMethod, ILeaferCanvas, IRenderOptions, ILayoutAttr, IBoundsType, ILocationType, ILayoutBoundsData, IPointData, IRadiusPointData, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IAttrDecorator } from '@leafer/interface';
|
|
1
|
+
import { ILeaf, InnerId, ILeaferBase, ILeafData, ILeafLayout, IMatrixWithBoundsScaleData, IMatrixWithBoundsData, IMatrixData, IBoundsData, IMatrixWithScaleData, IHitCanvas, IEventListenerMap, IFunction, ILeafInputData, IObject, IValue, IFindMethod, ILeaferCanvas, IRenderOptions, ILayoutAttr, IBoundsType, ILocationType, ILayoutBoundsData, IPointData, IRadiusPointData, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IAttrDecorator } from '@leafer/interface';
|
|
2
2
|
import { LeafData } from '@leafer/data';
|
|
3
3
|
import { LeafLayout } from '@leafer/layout';
|
|
4
4
|
|
|
@@ -12,9 +12,9 @@ declare class Leaf implements ILeaf {
|
|
|
12
12
|
get __LayoutProcessor(): typeof LeafLayout;
|
|
13
13
|
leafer?: ILeaferBase;
|
|
14
14
|
parent?: ILeaf;
|
|
15
|
-
isLeafer: boolean;
|
|
16
|
-
isBranch: boolean;
|
|
17
|
-
isBranchLeaf: boolean;
|
|
15
|
+
get isLeafer(): boolean;
|
|
16
|
+
get isBranch(): boolean;
|
|
17
|
+
get isBranchLeaf(): boolean;
|
|
18
18
|
__: ILeafData;
|
|
19
19
|
__layout: ILeafLayout;
|
|
20
20
|
__world: IMatrixWithBoundsScaleData;
|
|
@@ -24,7 +24,7 @@ declare class Leaf implements ILeaf {
|
|
|
24
24
|
get __localMatrix(): IMatrixData;
|
|
25
25
|
get __localBoxBounds(): IBoundsData;
|
|
26
26
|
__worldOpacity: number;
|
|
27
|
-
get worldTransform():
|
|
27
|
+
get worldTransform(): IMatrixWithScaleData;
|
|
28
28
|
get localTransform(): IMatrixData;
|
|
29
29
|
get boxBounds(): IBoundsData;
|
|
30
30
|
get renderBounds(): IBoundsData;
|
|
@@ -41,6 +41,8 @@ declare class Leaf implements ILeaf {
|
|
|
41
41
|
__hitCanvas?: IHitCanvas;
|
|
42
42
|
get __onlyHitMask(): boolean;
|
|
43
43
|
get __ignoreHitWorld(): boolean;
|
|
44
|
+
get pathInputed(): boolean;
|
|
45
|
+
pathClosed: boolean;
|
|
44
46
|
__captureMap?: IEventListenerMap;
|
|
45
47
|
__bubbleMap?: IEventListenerMap;
|
|
46
48
|
__parentWait?: IFunction[];
|
|
@@ -56,7 +58,7 @@ declare class Leaf implements ILeaf {
|
|
|
56
58
|
nextRender(item: IFunction, off?: 'off'): void;
|
|
57
59
|
__bindLeafer(leafer: ILeaferBase | null): void;
|
|
58
60
|
set(_data: IObject): void;
|
|
59
|
-
get(): ILeafInputData;
|
|
61
|
+
get(_name?: string): ILeafInputData | IValue;
|
|
60
62
|
toJSON(): IObject;
|
|
61
63
|
toString(): string;
|
|
62
64
|
__setAttr(_attrName: string, _newValue: IValue): void;
|
|
@@ -145,7 +147,6 @@ declare class Leaf implements ILeaf {
|
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
declare class Branch extends Leaf {
|
|
148
|
-
constructor();
|
|
149
150
|
__updateStrokeSpread(): number;
|
|
150
151
|
__updateRenderSpread(): number;
|
|
151
152
|
__updateBoxBounds(): void;
|
|
@@ -154,7 +155,7 @@ declare class Branch extends Leaf {
|
|
|
154
155
|
__updateSortChildren(): void;
|
|
155
156
|
add(child: ILeaf, index?: number): void;
|
|
156
157
|
addMany(...children: ILeaf[]): void;
|
|
157
|
-
remove(child?:
|
|
158
|
+
remove(child?: ILeaf, destroy?: boolean): void;
|
|
158
159
|
removeAll(destroy?: boolean): void;
|
|
159
160
|
clear(): void;
|
|
160
161
|
protected __preRemove(): void;
|