@leafer/decorator 1.0.0-bate → 1.0.0-beta.10

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/decorator",
3
- "version": "1.0.0-bate",
3
+ "version": "1.0.0-beta.10",
4
4
  "description": "@leafer/decorator",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -19,10 +19,10 @@
19
19
  "leaferjs"
20
20
  ],
21
21
  "dependencies": {
22
- "@leafer/platform": "1.0.0-bate",
23
- "@leafer/debug": "1.0.0-bate"
22
+ "@leafer/platform": "1.0.0-beta.10",
23
+ "@leafer/debug": "1.0.0-beta.10"
24
24
  },
25
25
  "devDependencies": {
26
- "@leafer/interface": "1.0.0-bate"
26
+ "@leafer/interface": "1.0.0-beta.10"
27
27
  }
28
28
  }
package/src/data.ts CHANGED
@@ -134,12 +134,7 @@ export function sortType(defaultValue?: __Value) {
134
134
  set(value: __Value) {
135
135
  this.__setAttr(key, value)
136
136
  this.__layout.surfaceChanged || this.__layout.surfaceChange()
137
-
138
- if (this.parent) {
139
- this.parent.__layout.childrenSortChanged = true
140
- } else {
141
- this.waitParent(() => { this.parent.__layout.childrenSortChanged = true })
142
- }
137
+ this.waitParent(() => { this.parent.__layout.childrenSortChange() })
143
138
  }
144
139
  })
145
140
  }
@@ -151,12 +146,18 @@ export function maskType(defaultValue?: __Value) {
151
146
  set(value: boolean) {
152
147
  this.__setAttr(key, value)
153
148
  this.__layout.boxChanged || this.__layout.boxChange()
149
+ this.waitParent(() => { this.parent.__updateMask(value) })
150
+ }
151
+ })
152
+ }
153
+ }
154
154
 
155
- if (this.parent) {
156
- this.parent.__updateMask(value)
157
- } else {
158
- this.waitParent(() => { this.parent.__updateMask(value) })
159
- }
155
+ export function eraserType(defaultValue?: __Value) {
156
+ return (target: ILeaf, key: string) => {
157
+ defineLeafAttr(target, key, defaultValue, {
158
+ set(value: boolean) {
159
+ this.__setAttr(key, value)
160
+ this.waitParent(() => { this.parent.__updateEraser(value) })
160
161
  }
161
162
  })
162
163
  }
@@ -222,7 +223,19 @@ export function defineDataProcessor(target: ILeaf, key: string, defaultValue?: _
222
223
  enumerable: true
223
224
  }
224
225
 
225
- if (defaultValue === undefined) property.get = function () { return this[computedKey] }
226
+ if (defaultValue === undefined) {
227
+ property.get = function () { return this[computedKey] }
228
+ } else if (key === 'width') {
229
+ property.get = function () {
230
+ const v = this[computedKey]
231
+ return v === undefined ? ((this as ILeafData).__naturalWidth || defaultValue) : v
232
+ }
233
+ } else if (key === 'height') {
234
+ property.get = function () {
235
+ const v = this[computedKey]
236
+ return v === undefined ? ((this as ILeafData).__naturalHeight || defaultValue) : v
237
+ }
238
+ }
226
239
 
227
240
  const descriptor = getDescriptor(data, key)
228
241
 
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { aliasType, defineLeafAttr, dataType, positionType, boundsType, affectStrokeBoundsType, strokeType, affectRenderBoundsType, scaleType, rotationType, surfaceType, opacityType, sortType, maskType, hitType, pathType, dataProcessor, layoutProcessor, setDefaultValue, defineDataProcessor } from './data'
1
+ export { aliasType, defineLeafAttr, dataType, positionType, boundsType, affectStrokeBoundsType, strokeType, affectRenderBoundsType, scaleType, rotationType, surfaceType, opacityType, sortType, maskType, eraserType, hitType, pathType, dataProcessor, layoutProcessor, setDefaultValue, defineDataProcessor } from './data'
2
2
  export { useModule, rewrite, rewriteAble } from './rewrite'
3
3
  export { defineKey, getDescriptor } from './object'
4
4
  export { registerUI, registerUIEvent } from './class'