@leafer/display-module 1.0.0-alpha.23 → 1.0.0-alpha.31

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-module",
3
- "version": "1.0.0-alpha.23",
3
+ "version": "1.0.0-alpha.31",
4
4
  "description": "@leafer/display-module",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -19,10 +19,10 @@
19
19
  "leaferjs"
20
20
  ],
21
21
  "dependencies": {
22
- "@leafer/event": "1.0.0-alpha.23",
23
- "@leafer/math": "1.0.0-alpha.23"
22
+ "@leafer/event": "1.0.0-alpha.31",
23
+ "@leafer/math": "1.0.0-alpha.31"
24
24
  },
25
25
  "devDependencies": {
26
- "@leafer/interface": "1.0.0-alpha.23"
26
+ "@leafer/interface": "1.0.0-alpha.31"
27
27
  }
28
28
  }
package/src/LeafBounds.ts CHANGED
@@ -48,15 +48,15 @@ export const LeafBounds: ILeafBoundsModule = {
48
48
 
49
49
  this.__updateStrokeBounds()
50
50
  this.__updateLocalStrokeBounds()
51
- layout.strokeBoundsChanged = false
52
-
53
- if (layout.renderBoundsSpreadWidth) layout.renderBoundsChanged = true
54
51
 
55
52
  } else {
56
53
  layout.strokeBoundsSpreadCancel()
57
54
  }
58
55
 
59
- this.parent?.__layout.strokeBoundsChange()
56
+ layout.strokeBoundsChanged = false
57
+ if (layout.renderBoundsSpreadWidth) layout.renderBoundsChanged = true
58
+
59
+ if (this.parent) this.parent.__layout.strokeBoundsChange()
60
60
  resize || (resize = true)
61
61
  }
62
62
 
@@ -73,13 +73,14 @@ export const LeafBounds: ILeafBoundsModule = {
73
73
 
74
74
  this.__updateRenderBounds()
75
75
  this.__updateLocalRenderBounds()
76
- layout.renderBoundsChanged = false
77
76
 
78
77
  } else {
79
78
  layout.renderBoundsSpreadCancel()
80
79
  }
81
80
 
82
- this.parent?.__layout.renderBoundsChange()
81
+ layout.renderBoundsChanged = false
82
+
83
+ if (this.parent) this.parent.__layout.renderBoundsChange()
83
84
  }
84
85
 
85
86
 
@@ -6,11 +6,11 @@ export const LeafDataProxy: ILeafDataProxyModule = {
6
6
 
7
7
  __setAttr(name: string, newValue: unknown): void {
8
8
  if (this.leafer && this.leafer.ready) {
9
- const oldValue = this.__.__get(name)
10
- if (oldValue !== newValue) {
11
- this.__[name] = newValue
12
- this.leafer.emitEvent(new PropertyEvent(PropertyEvent.CHANGE, this, name, oldValue, newValue))
13
- }
9
+ this.__[name] = newValue
10
+ const { CHANGE } = PropertyEvent
11
+ const event = new PropertyEvent(CHANGE, this, name, this.__.__get(name), newValue)
12
+ if (this.hasEvent(CHANGE) && !this.isLeafer) this.emitEvent(event)
13
+ this.leafer.emitEvent(event)
14
14
  } else {
15
15
  this.__[name] = newValue
16
16
  }
@@ -18,15 +18,6 @@ export const LeafDataProxy: ILeafDataProxyModule = {
18
18
 
19
19
  __getAttr(name: string): unknown {
20
20
  return this.__.__get(name)
21
- },
22
-
23
- __updateAttr(name?: string): void {
24
- if (this.leafer && this.leafer.ready) {
25
- if (!name) name = 'fill'
26
- const value = this.__.__get(name);
27
- (this as any)[name] = value
28
- this.leafer.emitEvent(new PropertyEvent(PropertyEvent.CHANGE, this, name, value, value))
29
- }
30
21
  }
31
22
 
32
23
  }
@@ -1,7 +1,5 @@
1
1
  import { IEventListener, IEventListenerOptions, IEventListenerMap, IEventListenerItem, IEventListenerId, IEvent, IObject, IEventTarget, ILeafEventerModule } from '@leafer/interface'
2
- import { Debug } from '@leafer/debug'
3
2
 
4
- const debug = Debug.get('Life')
5
3
  const empty = {}
6
4
 
7
5
  export const LeafEventer: ILeafEventerModule = {
@@ -71,8 +69,6 @@ export const LeafEventer: ILeafEventerModule = {
71
69
  },
72
70
 
73
71
  emit(type: string, event?: IEvent | IObject, capture?: boolean): void {
74
- if (Debug.enable) debug.log(type)
75
-
76
72
  const map = __getListenerMap(this, capture)
77
73
  const list = map[type]
78
74
  if (list) {
package/src/LeafHit.ts CHANGED
@@ -16,11 +16,6 @@ export const LeafHit: ILeafHitModule = {
16
16
  return this.__hit(inner)
17
17
  },
18
18
 
19
- __updateHitCanvas(): void {
20
- if (!this.__hitCanvas) this.__hitCanvas = this.leafer.hitCanvasManager.getPathType(this)
21
- this.__drawHitPath(this.__hitCanvas)
22
- },
23
-
24
19
  __drawHitPath(canvas: ILeaferCanvas): void {
25
20
  this.__drawRenderPath(canvas)
26
21
  }
@@ -0,0 +1,33 @@
1
+ import { ILeaf, ILeaferCanvas, ILeafMaskModule } from '@leafer/interface'
2
+
3
+
4
+ export const LeafMask: ILeafMaskModule = {
5
+
6
+ __updateMask(value?: boolean): void {
7
+ this.__hasMask = value ? true : this.children.some(item => item.__.isMask)
8
+ },
9
+
10
+ __renderMask(canvas: ILeaferCanvas, content: ILeaferCanvas, mask: ILeaferCanvas): void {
11
+ content.resetTransform()
12
+ content.useMask(mask)
13
+ canvas.resetTransform()
14
+ canvas.copyWorld(content)
15
+ },
16
+
17
+ __removeMask(child?: ILeaf): void {
18
+ if (child) {
19
+ child.isMask = false
20
+ this.remove(child)
21
+ } else {
22
+ const { children } = this
23
+ for (let i = 0, len = children.length; i < len; i++) {
24
+ child = children[i]
25
+ if (child.isMask) {
26
+ this.__removeMask(child)
27
+ len--, i--
28
+ }
29
+ }
30
+ }
31
+ }
32
+
33
+ }
package/src/index.ts CHANGED
@@ -4,4 +4,5 @@ export { LeafMatrix } from './LeafMatrix'
4
4
  export { LeafBounds } from './LeafBounds'
5
5
  export { LeafHit } from './LeafHit'
6
6
  export { LeafRender } from './LeafRender'
7
+ export { LeafMask } from './LeafMask'
7
8