@leafer/display-module 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 +4 -4
- package/src/BranchRender.ts +4 -8
- package/src/LeafBounds.ts +1 -1
- package/src/LeafDataProxy.ts +18 -5
- package/src/LeafHit.ts +6 -1
- package/src/LeafMask.ts +12 -2
- package/src/LeafMatrix.ts +8 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/display-module",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
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.
|
|
26
|
-
"@leafer/math": "1.0.0-rc.
|
|
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.
|
|
29
|
+
"@leafer/interface": "1.0.0-rc.6"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/BranchRender.ts
CHANGED
|
@@ -49,8 +49,8 @@ export const BranchRender: IBranchRenderModule = {
|
|
|
49
49
|
if (this.__hasMask && children.length > 1) {
|
|
50
50
|
|
|
51
51
|
let mask: boolean
|
|
52
|
-
|
|
53
|
-
|
|
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
|
|
package/src/LeafBounds.ts
CHANGED
|
@@ -124,7 +124,7 @@ export const LeafBounds: ILeafBoundsModule = {
|
|
|
124
124
|
data.__naturalHeight = layout.boxBounds.height
|
|
125
125
|
|
|
126
126
|
if (this.around) {
|
|
127
|
-
layout.
|
|
127
|
+
layout.matrixChanged = true
|
|
128
128
|
this.__updateWorldMatrix()
|
|
129
129
|
}
|
|
130
130
|
},
|
package/src/LeafDataProxy.ts
CHANGED
|
@@ -1,25 +1,38 @@
|
|
|
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:
|
|
7
|
+
__setAttr(name: string, newValue: __Value): void {
|
|
8
8
|
if (this.leafer && this.leafer.created) {
|
|
9
|
-
|
|
9
|
+
const oldValue = this.__.__getInput(name)
|
|
10
|
+
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
10
11
|
this.__[name] = newValue
|
|
12
|
+
if (this.proxyData) this.setProxyAttr(name, newValue)
|
|
13
|
+
|
|
11
14
|
const { CHANGE } = PropertyEvent
|
|
12
|
-
const event = new PropertyEvent(CHANGE, this, name,
|
|
15
|
+
const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue)
|
|
13
16
|
if (this.hasEvent(CHANGE) && !this.isLeafer) this.emitEvent(event)
|
|
14
17
|
this.leafer.emitEvent(event)
|
|
15
18
|
}
|
|
16
19
|
} else {
|
|
17
20
|
this.__[name] = newValue
|
|
21
|
+
if (this.proxyData) this.setProxyAttr(name, newValue)
|
|
18
22
|
}
|
|
19
23
|
},
|
|
20
24
|
|
|
21
|
-
__getAttr(name: string):
|
|
25
|
+
__getAttr(name: string): __Value {
|
|
26
|
+
if (this.proxyData) return this.getProxyAttr(name)
|
|
22
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]
|
|
23
36
|
}
|
|
24
37
|
|
|
25
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
|
-
|
|
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 {
|
package/src/LeafMatrix.ts
CHANGED
|
@@ -101,17 +101,19 @@ export const LeafMatrix: ILeafMatrixModule = {
|
|
|
101
101
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
const { x, y, around } = this.__
|
|
105
|
+
|
|
106
|
+
r.e = x
|
|
107
|
+
r.f = y
|
|
108
|
+
|
|
109
|
+
if (around) {
|
|
110
|
+
const { width, height } = this.__
|
|
111
|
+
if (width && height) {
|
|
109
112
|
const origin = (around === 'center') ? defaultCenter : around
|
|
110
113
|
const offsetX = width * origin.x, offsetY = height * origin.y
|
|
111
114
|
r.e -= offsetX * r.a + offsetY * r.c
|
|
112
115
|
r.f -= offsetX * r.b + offsetY * r.d
|
|
113
116
|
}
|
|
114
|
-
layout.positionChanged = false
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
this.__layout.matrixChanged = false
|