@leafer-ui/hit 1.6.7 → 1.8.0

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-ui/hit",
3
- "version": "1.6.7",
3
+ "version": "1.8.0",
4
4
  "description": "@leafer-ui/hit",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,11 +22,11 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.6.7",
26
- "@leafer-ui/draw": "1.6.7"
25
+ "@leafer/core": "1.8.0",
26
+ "@leafer-ui/draw": "1.8.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.6.7",
30
- "@leafer-ui/interface": "1.6.7"
29
+ "@leafer/interface": "1.8.0",
30
+ "@leafer-ui/interface": "1.8.0"
31
31
  }
32
32
  }
package/src/LeafHit.ts CHANGED
@@ -34,10 +34,10 @@ leaf.__hitWorld = function (point: IRadiusPointData): boolean {
34
34
  return this.__hit(inner)
35
35
  }
36
36
 
37
- leaf.__hitFill = function (inner: IRadiusPointData): boolean { return this.__hitCanvas?.hitFill(inner, this.__.windingRule) }
37
+ leaf.__hitFill = function (inner: IRadiusPointData): boolean { const h = this.__hitCanvas; return h && h.hitFill(inner, this.__.windingRule) }
38
38
 
39
- leaf.__hitStroke = function (inner: IRadiusPointData, strokeWidth: number): boolean { return this.__hitCanvas?.hitStroke(inner, strokeWidth) }
39
+ leaf.__hitStroke = function (inner: IRadiusPointData, strokeWidth: number): boolean { const h = this.__hitCanvas; return h && h.hitStroke(inner, strokeWidth) }
40
40
 
41
- leaf.__hitPixel = function (inner: IRadiusPointData): boolean { return this.__hitCanvas?.hitPixel(inner, this.__layout.renderBounds, this.__hitCanvas.hitScale) }
41
+ leaf.__hitPixel = function (inner: IRadiusPointData): boolean { const h = this.__hitCanvas; return h && h.hitPixel(inner, this.__layout.renderBounds, h.hitScale) }
42
42
 
43
- leaf.__drawHitPath = function (canvas: ILeaferCanvas): void { if (canvas) this.__drawRenderPath(canvas) }
43
+ leaf.__drawHitPath = function (canvas: ILeaferCanvas): void { canvas && this.__drawRenderPath(canvas) }
package/src/UIHit.ts CHANGED
@@ -10,7 +10,10 @@ ui.__updateHitCanvas = function (): void {
10
10
 
11
11
  if (this.__box) this.__box.__updateHitCanvas()
12
12
 
13
- const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer // 兼容 boxStyle
13
+ const leafer = this.leafer || (this.parent && this.parent.leafer) // 兼容 boxStyle
14
+ if (!leafer) return
15
+
16
+ const data = this.__, { hitCanvasManager } = leafer
14
17
  const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel'
15
18
  const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel'
16
19
  const isHitPixel = isHitPixelFill || isHitPixelStroke
@@ -28,7 +31,7 @@ ui.__updateHitCanvas = function (): void {
28
31
  h.clear()
29
32
 
30
33
  ImageManager.patternLocked = true
31
- this.__renderShape(h, { matrix: matrix.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y) }, !isHitPixelFill, !isHitPixelStroke) // 矩阵
34
+ this.__renderShape(h, { matrix: matrix.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y), ignoreFill: !isHitPixelFill, ignoreStroke: !isHitPixelStroke }) // 矩阵
32
35
  ImageManager.patternLocked = false
33
36
  h.resetTransform()
34
37
 
@@ -55,7 +58,7 @@ ui.__hit = function (inner: IRadiusPointData): boolean {
55
58
  const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all'
56
59
  if (needHitFillPath && this.__hitFill(inner)) return true
57
60
 
58
- const { hitStroke, __strokeWidth } = data
61
+ const { hitStroke, __maxStrokeWidth: strokeWidth } = data
59
62
  const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all'
60
63
  if (!needHitFillPath && !needHitStrokePath) return false
61
64
 
@@ -65,15 +68,15 @@ ui.__hit = function (inner: IRadiusPointData): boolean {
65
68
  if (needHitStrokePath) {
66
69
  switch (data.strokeAlign) {
67
70
  case 'inside':
68
- hitWidth += __strokeWidth * 2
71
+ hitWidth += strokeWidth * 2
69
72
  if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth)) return true
70
73
  hitWidth = radiusWidth
71
74
  break
72
75
  case 'center':
73
- hitWidth += __strokeWidth
76
+ hitWidth += strokeWidth
74
77
  break
75
78
  case 'outside':
76
- hitWidth += __strokeWidth * 2
79
+ hitWidth += strokeWidth * 2
77
80
  if (!needHitFillPath) {
78
81
  if (!this.__hitFill(inner) && this.__hitStroke(inner, hitWidth)) return true
79
82
  hitWidth = radiusWidth