@leafer-ui/hit 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 +3 -3
- package/src/UIHit.ts +27 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/hit",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.10",
|
|
4
4
|
"description": "@leafer-ui/hit",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@leafer/interface": "1.0.0-
|
|
23
|
-
"@leafer-ui/interface": "1.0.0-
|
|
22
|
+
"@leafer/interface": "1.0.0-beta.10",
|
|
23
|
+
"@leafer-ui/interface": "1.0.0-beta.10"
|
|
24
24
|
}
|
|
25
25
|
}
|
package/src/UIHit.ts
CHANGED
|
@@ -1,39 +1,51 @@
|
|
|
1
1
|
import { IRadiusPointData } from '@leafer/interface'
|
|
2
2
|
|
|
3
3
|
import { IUIHitModule } from '@leafer-ui/interface'
|
|
4
|
+
import { Platform } from '@leafer/core'
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
export const UIHit: IUIHitModule = {
|
|
7
8
|
|
|
8
9
|
__updateHitCanvas(): void {
|
|
9
10
|
if (!this.__hitCanvas) this.__hitCanvas = this.leafer.hitCanvasManager.getPathType(this)
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
11
|
+
const h = this.__hitCanvas
|
|
12
|
+
this.__drawHitPath(h)
|
|
13
|
+
h.setStrokeOptions(this.__)
|
|
12
14
|
},
|
|
13
15
|
|
|
14
16
|
__hit(inner: IRadiusPointData): boolean {
|
|
15
17
|
const { __hitCanvas: h } = this
|
|
18
|
+
if (Platform.name === 'miniapp') this.__drawHitPath(h) // fix: 小程序需要实时更新
|
|
16
19
|
|
|
17
20
|
const { fill, hitFill, windingRule } = this.__
|
|
18
21
|
const needHitFill = (fill && hitFill === 'path') || hitFill === 'all'
|
|
19
|
-
|
|
22
|
+
const isHitFill = h.hitFill(inner, windingRule)
|
|
23
|
+
if (needHitFill && isHitFill) return true
|
|
20
24
|
|
|
21
25
|
const { stroke, hitStroke, strokeWidth, strokeAlign } = this.__
|
|
22
26
|
const needHitStroke = (stroke && hitStroke === 'path') || hitStroke === 'all'
|
|
23
27
|
const radiusWidth = inner.radiusX * 2
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
case 'outside':
|
|
33
|
-
if (!needHitFill) {
|
|
34
|
-
if (!h.hitFill(inner, windingRule) && h.hitStroke(inner, hitWidth)) return true
|
|
28
|
+
|
|
29
|
+
let hitWidth = radiusWidth
|
|
30
|
+
|
|
31
|
+
if (needHitStroke) {
|
|
32
|
+
switch (strokeAlign) {
|
|
33
|
+
case 'inside':
|
|
34
|
+
hitWidth += strokeWidth * 2
|
|
35
|
+
if (!needHitFill && (isHitFill && h.hitStroke(inner, hitWidth))) return true
|
|
35
36
|
hitWidth = radiusWidth
|
|
36
|
-
|
|
37
|
+
break
|
|
38
|
+
case 'center':
|
|
39
|
+
hitWidth += strokeWidth
|
|
40
|
+
break
|
|
41
|
+
case 'outside':
|
|
42
|
+
hitWidth += strokeWidth * 2
|
|
43
|
+
if (!needHitFill) {
|
|
44
|
+
if (!isHitFill && h.hitStroke(inner, hitWidth)) return true
|
|
45
|
+
hitWidth = radiusWidth
|
|
46
|
+
}
|
|
47
|
+
break
|
|
48
|
+
}
|
|
37
49
|
}
|
|
38
50
|
|
|
39
51
|
return hitWidth ? h.hitStroke(inner, hitWidth) : false
|