@leafer-ui/hit 1.0.0-beta.12 → 1.0.0-beta.15

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,12 +1,14 @@
1
1
  {
2
2
  "name": "@leafer-ui/hit",
3
- "version": "1.0.0-beta.12",
3
+ "version": "1.0.0-beta.15",
4
4
  "description": "@leafer-ui/hit",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
+ "types": "types/index.d.ts",
8
9
  "files": [
9
- "src"
10
+ "types",
11
+ "dist"
10
12
  ],
11
13
  "repository": {
12
14
  "type": "git",
@@ -19,7 +21,7 @@
19
21
  "leaferjs"
20
22
  ],
21
23
  "devDependencies": {
22
- "@leafer/interface": "1.0.0-beta.12",
23
- "@leafer-ui/interface": "1.0.0-beta.12"
24
+ "@leafer/interface": "1.0.0-beta.15",
25
+ "@leafer-ui/interface": "1.0.0-beta.15"
24
26
  }
25
27
  }
@@ -0,0 +1,5 @@
1
+ import { IUIHitModule } from '@leafer-ui/interface';
2
+
3
+ declare const UIHit: IUIHitModule;
4
+
5
+ export { UIHit };
package/src/UIHit.ts DELETED
@@ -1,54 +0,0 @@
1
- import { IRadiusPointData } from '@leafer/interface'
2
-
3
- import { IUIHitModule } from '@leafer-ui/interface'
4
- import { Platform } from '@leafer/core'
5
-
6
-
7
- export const UIHit: IUIHitModule = {
8
-
9
- __updateHitCanvas(): void {
10
- if (!this.__hitCanvas) this.__hitCanvas = this.leafer.hitCanvasManager.getPathType(this)
11
- const h = this.__hitCanvas
12
- this.__drawHitPath(h)
13
- h.setStrokeOptions(this.__)
14
- },
15
-
16
- __hit(inner: IRadiusPointData): boolean {
17
- const { __hitCanvas: h } = this
18
- if (Platform.name === 'miniapp') this.__drawHitPath(h) // fix: 小程序需要实时更新
19
-
20
- const { fill, hitFill, windingRule } = this.__
21
- const needHitFill = (fill && hitFill === 'path') || hitFill === 'all'
22
- const isHitFill = h.hitFill(inner, windingRule)
23
- if (needHitFill && isHitFill) return true
24
-
25
- const { stroke, hitStroke, strokeWidth, strokeAlign } = this.__
26
- const needHitStroke = (stroke && hitStroke === 'path') || hitStroke === 'all'
27
- const radiusWidth = inner.radiusX * 2
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
36
- hitWidth = radiusWidth
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
- }
49
- }
50
-
51
- return hitWidth ? h.hitStroke(inner, hitWidth) : false
52
- }
53
-
54
- }