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

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.5",
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.5",
26
+ "@leafer/data": "1.0.0-rc.5",
27
+ "@leafer/layout": "1.0.0-rc.5",
28
+ "@leafer/display-module": "1.0.0-rc.5",
29
+ "@leafer/event": "1.0.0-rc.5",
30
+ "@leafer/decorator": "1.0.0-rc.5",
31
+ "@leafer/helper": "1.0.0-rc.5",
32
+ "@leafer/platform": "1.0.0-rc.5"
33
33
  },
34
34
  "devDependencies": {
35
- "@leafer/interface": "1.0.0-rc.4"
35
+ "@leafer/interface": "1.0.0-rc.5"
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
@@ -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
  }
@@ -162,7 +176,7 @@ export class Leaf implements ILeaf {
162
176
  // ---
163
177
 
164
178
  public forceUpdate(attrName?: string): void {
165
- if (attrName === undefined) attrName = 'scaleX'
179
+ if (attrName === undefined) attrName = 'width'
166
180
  else if (attrName === 'surface') attrName = 'blendMode'
167
181
  const value = this.__.__getInput(attrName)
168
182
  this.__[attrName] = value === undefined ? null : undefined;
package/types/index.d.ts CHANGED
@@ -43,6 +43,8 @@ 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;