@leafer/display-module 1.0.0-rc.5 → 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-module",
3
- "version": "1.0.0-rc.5",
3
+ "version": "1.0.0-rc.6",
4
4
  "description": "@leafer/display-module",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,10 +22,10 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/event": "1.0.0-rc.5",
26
- "@leafer/math": "1.0.0-rc.5"
25
+ "@leafer/event": "1.0.0-rc.6",
26
+ "@leafer/math": "1.0.0-rc.6"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.0.0-rc.5"
29
+ "@leafer/interface": "1.0.0-rc.6"
30
30
  }
31
31
  }
@@ -49,8 +49,8 @@ export const BranchRender: IBranchRenderModule = {
49
49
  if (this.__hasMask && children.length > 1) {
50
50
 
51
51
  let mask: boolean
52
- let maskCanvas = canvas.getSameCanvas()
53
- let contentCanvas = canvas.getSameCanvas()
52
+ const maskCanvas = canvas.getSameCanvas()
53
+ const contentCanvas = canvas.getSameCanvas()
54
54
 
55
55
  for (let i = 0, len = children.length; i < len; i++) {
56
56
  child = children[i]
@@ -58,8 +58,6 @@ export const BranchRender: IBranchRenderModule = {
58
58
  if (child.isMask) {
59
59
  if (mask) {
60
60
  this.__renderMask(canvas, contentCanvas, maskCanvas)
61
- maskCanvas.clear()
62
- contentCanvas.clear()
63
61
  } else {
64
62
  mask = true
65
63
  }
@@ -68,12 +66,10 @@ export const BranchRender: IBranchRenderModule = {
68
66
  continue
69
67
  }
70
68
 
71
- child.__render(contentCanvas, options)
69
+ child.__render(mask ? contentCanvas : canvas, options)
72
70
  }
73
71
 
74
- this.__renderMask(canvas, contentCanvas, maskCanvas)
75
- maskCanvas.recycle()
76
- contentCanvas.recycle()
72
+ this.__renderMask(canvas, contentCanvas, maskCanvas, true)
77
73
 
78
74
  } else {
79
75
 
@@ -1,14 +1,16 @@
1
- import { ILeafDataProxyModule } from '@leafer/interface'
1
+ import { ILeafDataProxyModule, __Value } from '@leafer/interface'
2
2
  import { PropertyEvent } from '@leafer/event'
3
3
 
4
4
 
5
5
  export const LeafDataProxy: ILeafDataProxyModule = {
6
6
 
7
- __setAttr(name: string, newValue: unknown): void {
7
+ __setAttr(name: string, newValue: __Value): void {
8
8
  if (this.leafer && this.leafer.created) {
9
9
  const oldValue = this.__.__getInput(name)
10
10
  if (typeof newValue === 'object' || oldValue !== newValue) {
11
11
  this.__[name] = newValue
12
+ if (this.proxyData) this.setProxyAttr(name, newValue)
13
+
12
14
  const { CHANGE } = PropertyEvent
13
15
  const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue)
14
16
  if (this.hasEvent(CHANGE) && !this.isLeafer) this.emitEvent(event)
@@ -16,11 +18,21 @@ export const LeafDataProxy: ILeafDataProxyModule = {
16
18
  }
17
19
  } else {
18
20
  this.__[name] = newValue
21
+ if (this.proxyData) this.setProxyAttr(name, newValue)
19
22
  }
20
23
  },
21
24
 
22
- __getAttr(name: string): unknown {
25
+ __getAttr(name: string): __Value {
26
+ if (this.proxyData) return this.getProxyAttr(name)
23
27
  return this.__.__get(name)
28
+ },
29
+
30
+ setProxyAttr(name: string, newValue: __Value): void {
31
+ if (this.proxyData[name] !== newValue) this.proxyData[name] = newValue
32
+ },
33
+
34
+ getProxyAttr(name: string): __Value {
35
+ return this.proxyData[name]
24
36
  }
25
37
 
26
38
  }
package/src/LeafHit.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ILeafHitModule, IRadiusPointData, ILeaferCanvas } from '@leafer/interface'
2
- import { PointHelper } from '@leafer/math'
2
+ import { PointHelper, BoundsHelper } from '@leafer/math'
3
3
 
4
4
 
5
5
  const { toInnerRadiusPointOf, copy, setRadius } = PointHelper
@@ -19,6 +19,11 @@ export const LeafHit: ILeafHitModule = {
19
19
  }
20
20
 
21
21
  toInnerRadiusPointOf(point, this.__world, inner)
22
+
23
+ if (this.__.hitBox) {
24
+ if (BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner)) return true
25
+ }
26
+
22
27
  return this.__hit(inner)
23
28
  },
24
29
 
package/src/LeafMask.ts CHANGED
@@ -11,12 +11,22 @@ export const LeafMask: ILeafMaskModule = {
11
11
  this.__hasMask = value ? true : this.children.some(item => item.__.isMask)
12
12
  },
13
13
 
14
- __renderMask(canvas: ILeaferCanvas, content: ILeaferCanvas, mask: ILeaferCanvas): void {
14
+ __renderMask(canvas: ILeaferCanvas, content: ILeaferCanvas, mask: ILeaferCanvas, recycle?: boolean): void {
15
+ content.opacity = 1
15
16
  content.resetTransform()
16
17
  content.useMask(mask)
17
- canvas.resetTransform()
18
+
18
19
  canvas.opacity = this.__worldOpacity
20
+ canvas.resetTransform()
19
21
  canvas.copyWorld(content)
22
+
23
+ if (recycle) {
24
+ content.recycle()
25
+ mask.recycle()
26
+ } else {
27
+ content.clear()
28
+ mask.clear()
29
+ }
20
30
  },
21
31
 
22
32
  __removeMask(child?: ILeaf): void {