@leafer/display 1.0.0-rc.4 → 1.0.0-rc.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/display",
3
- "version": "1.0.0-rc.4",
3
+ "version": "1.0.0-rc.6",
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.4",
26
- "@leafer/data": "1.0.0-rc.4",
27
- "@leafer/layout": "1.0.0-rc.4",
28
- "@leafer/display-module": "1.0.0-rc.4",
29
- "@leafer/event": "1.0.0-rc.4",
30
- "@leafer/decorator": "1.0.0-rc.4",
31
- "@leafer/helper": "1.0.0-rc.4",
32
- "@leafer/platform": "1.0.0-rc.4"
25
+ "@leafer/math": "1.0.0-rc.6",
26
+ "@leafer/data": "1.0.0-rc.6",
27
+ "@leafer/layout": "1.0.0-rc.6",
28
+ "@leafer/display-module": "1.0.0-rc.6",
29
+ "@leafer/event": "1.0.0-rc.6",
30
+ "@leafer/decorator": "1.0.0-rc.6",
31
+ "@leafer/helper": "1.0.0-rc.6",
32
+ "@leafer/platform": "1.0.0-rc.6"
33
33
  },
34
34
  "devDependencies": {
35
- "@leafer/interface": "1.0.0-rc.4"
35
+ "@leafer/interface": "1.0.0-rc.6"
36
36
  }
37
37
  }
package/src/Branch.ts CHANGED
@@ -75,7 +75,7 @@ export class Branch extends Leaf {
75
75
 
76
76
  index === undefined ? this.children.push(child) : this.children.splice(index, 0, child)
77
77
  if (child.isBranch) this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1
78
- child.__layout.boundsChanged || child.__layout.positionChange() // layouted(removed), need update
78
+ child.__layout.boundsChanged || child.__layout.matrixChange() // layouted(removed), need update
79
79
 
80
80
  if (child.__parentWait) WaitHelper.run(child.__parentWait)
81
81
 
package/src/Leaf.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeafer, ILeaf, ILeafInputData, ILeafData, ILeaferCanvas, IRenderOptions, IMatrixWithBoundsData, __Number, __Boolean, __Value, ILeafLayout, InnerId, IHitCanvas, IRadiusPointData, IEventListenerMap, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IObject, IFunction, __String, IPointData, IMatrixDecompositionAttr, ILayoutBoundsType, ILayoutLocationType, IBoundsData, IBranch, IMatrixWithLayoutData } from '@leafer/interface'
1
+ import { ILeafer, ILeaf, ILeafInputData, ILeafData, ILeaferCanvas, IRenderOptions, IMatrixWithBoundsData, __Number, __Boolean, __Value, ILeafLayout, InnerId, IHitCanvas, IRadiusPointData, IEventListenerMap, IEventListener, IEventListenerOptions, IEventListenerId, IEvent, IObject, IFunction, __String, IPointData, IMatrixDecompositionAttr, ILayoutBoundsType, ILayoutLocationType, IBoundsData, IBranch, IMatrixWithLayoutData, IFindMethod, ILeafDataOptions } from '@leafer/interface'
2
2
  import { IncrementId, MatrixHelper, PointHelper } from '@leafer/math'
3
3
  import { LeafData } from '@leafer/data'
4
4
  import { LeafLayout } from '@leafer/layout'
@@ -88,8 +88,12 @@ export class Leaf implements ILeaf {
88
88
 
89
89
 
90
90
  constructor(data?: ILeafInputData) {
91
-
92
91
  this.innerId = create(LEAF)
92
+ this.reset(data)
93
+ }
94
+
95
+
96
+ public reset(data?: ILeafInputData): void {
93
97
 
94
98
  this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 }
95
99
  this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 }
@@ -99,6 +103,8 @@ export class Leaf implements ILeaf {
99
103
  this.__ = new this.__DataProcessor(this)
100
104
  this.__layout = new this.__LayoutProcessor(this)
101
105
 
106
+ if (this.__level) this.resetCustom()
107
+
102
108
  if (data) {
103
109
  if (data.children) {
104
110
  this.set(data)
@@ -108,6 +114,11 @@ export class Leaf implements ILeaf {
108
114
  }
109
115
  }
110
116
 
117
+ public resetCustom(): void {
118
+ this.__hasMask = this.__hasEraser = null
119
+ this.forceUpdate()
120
+ }
121
+
111
122
 
112
123
  public waitParent(item: IFunction): void {
113
124
  this.parent ? item() : (this.__parentWait ? this.__parentWait.push(item) : this.__parentWait = [item])
@@ -126,9 +137,12 @@ export class Leaf implements ILeaf {
126
137
  if (leafer !== null) leafer = this as unknown as ILeafer
127
138
  }
128
139
 
140
+ if (this.leafer && !leafer) this.leafer.leafs--
141
+
129
142
  this.leafer = leafer
130
143
 
131
144
  if (leafer) {
145
+ leafer.leafs++
132
146
  this.__level = this.parent ? this.parent.__level + 1 : 1
133
147
  if (this.__leaferWait) WaitHelper.run(this.__leaferWait)
134
148
  }
@@ -144,6 +158,7 @@ export class Leaf implements ILeaf {
144
158
  // data
145
159
 
146
160
  public set(_data: IObject): void { }
161
+ get(_options?: ILeafDataOptions): ILeafInputData { return undefined }
147
162
 
148
163
  public toJSON(): IObject {
149
164
  return this.__.__getInputData()
@@ -159,10 +174,23 @@ export class Leaf implements ILeaf {
159
174
 
160
175
  public __getAttr(_attrName: string): __Value { return undefined }
161
176
 
177
+ public setProxyAttr(_attrName: string, _newValue: __Value): void { }
178
+
179
+ public getProxyAttr(_attrName: string): __Value { return undefined }
180
+
181
+ // ---
182
+
183
+
184
+ // find
185
+
186
+ public find(_condition: number | string | IFindMethod): ILeaf[] { return undefined }
187
+
188
+ public findOne(_condition: number | string | IFindMethod): ILeaf { return undefined }
189
+
162
190
  // ---
163
191
 
164
192
  public forceUpdate(attrName?: string): void {
165
- if (attrName === undefined) attrName = 'scaleX'
193
+ if (attrName === undefined) attrName = 'width'
166
194
  else if (attrName === 'surface') attrName = 'blendMode'
167
195
  const value = this.__.__getInput(attrName)
168
196
  this.__[attrName] = value === undefined ? null : undefined;
@@ -216,7 +244,7 @@ export class Leaf implements ILeaf {
216
244
 
217
245
  public __updateMask(_value?: boolean): void { }
218
246
 
219
- public __renderMask(_canvas: ILeaferCanvas, _content: ILeaferCanvas, _mask: ILeaferCanvas): void { }
247
+ public __renderMask(_canvas: ILeaferCanvas, _content: ILeaferCanvas, _mask: ILeaferCanvas, _recycle?: boolean): void { }
220
248
 
221
249
  public __removeMask(_child?: ILeaf): void { }
222
250
 
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeaf, InnerId, ILeafer, ILeafData, ILeafLayout, IMatrixWithLayoutData, IMatrixWithBoundsData, IBoundsData, IHitCanvas, IEventListenerMap, IFunction, ILeafInputData, IObject, __Value, ILeaferCanvas, IMatrixDecompositionAttr, ILayoutBoundsType, ILayoutLocationType, IPointData, IRadiusPointData, IRenderOptions, IEventListener, IEventListenerOptions, IEventListenerId, IEvent } from '@leafer/interface';
1
+ import { ILeaf, InnerId, ILeafer, ILeafData, ILeafLayout, IMatrixWithLayoutData, IMatrixWithBoundsData, IBoundsData, IHitCanvas, IEventListenerMap, IFunction, ILeafInputData, IObject, ILeafDataOptions, __Value, IFindMethod, ILeaferCanvas, IMatrixDecompositionAttr, ILayoutBoundsType, ILayoutLocationType, IPointData, IRadiusPointData, IRenderOptions, IEventListener, IEventListenerOptions, IEventListenerId, IEvent } from '@leafer/interface';
2
2
  import { LeafData } from '@leafer/data';
3
3
  import { LeafLayout } from '@leafer/layout';
4
4
 
@@ -43,15 +43,22 @@ declare class Leaf implements ILeaf {
43
43
  children?: ILeaf[];
44
44
  destroyed: boolean;
45
45
  constructor(data?: ILeafInputData);
46
+ reset(data?: ILeafInputData): void;
47
+ resetCustom(): void;
46
48
  waitParent(item: IFunction): void;
47
49
  waitLeafer(item: IFunction): void;
48
50
  nextRender(item: IFunction): void;
49
51
  __bindLeafer(leafer: ILeafer | null): void;
50
52
  set(_data: IObject): void;
53
+ get(_options?: ILeafDataOptions): ILeafInputData;
51
54
  toJSON(): IObject;
52
55
  toString(): string;
53
56
  __setAttr(_attrName: string, _newValue: __Value): void;
54
57
  __getAttr(_attrName: string): __Value;
58
+ setProxyAttr(_attrName: string, _newValue: __Value): void;
59
+ getProxyAttr(_attrName: string): __Value;
60
+ find(_condition: number | string | IFindMethod): ILeaf[];
61
+ findOne(_condition: number | string | IFindMethod): ILeaf;
55
62
  forceUpdate(attrName?: string): void;
56
63
  __updateWorldMatrix(): void;
57
64
  __updateLocalMatrix(): void;
@@ -68,7 +75,7 @@ declare class Leaf implements ILeaf {
68
75
  __onUpdateSize(): void;
69
76
  __updateEraser(_value?: boolean): void;
70
77
  __updateMask(_value?: boolean): void;
71
- __renderMask(_canvas: ILeaferCanvas, _content: ILeaferCanvas, _mask: ILeaferCanvas): void;
78
+ __renderMask(_canvas: ILeaferCanvas, _content: ILeaferCanvas, _mask: ILeaferCanvas, _recycle?: boolean): void;
72
79
  __removeMask(_child?: ILeaf): void;
73
80
  getWorld(attrName: IMatrixDecompositionAttr): number;
74
81
  getBounds(type: ILayoutBoundsType, locationType?: ILayoutLocationType): IBoundsData;