@leafer-ui/hit 1.12.0 → 1.12.2

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.12.0",
3
+ "version": "1.12.2",
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.12.0",
26
- "@leafer-ui/draw": "1.12.0"
25
+ "@leafer/core": "1.12.2",
26
+ "@leafer-ui/draw": "1.12.2"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.12.0",
30
- "@leafer-ui/interface": "1.12.0"
29
+ "@leafer/interface": "1.12.2",
30
+ "@leafer-ui/interface": "1.12.2"
31
31
  }
32
32
  }
package/src/LeafHit.ts CHANGED
@@ -2,7 +2,7 @@ import { IRadiusPointData, ILeaferCanvas, IPointData, IBranch } from '@leafer/in
2
2
  import { Leaf, PointHelper, BoundsHelper, Platform } from '@leafer/core'
3
3
 
4
4
 
5
- const { toInnerRadiusPointOf, copy, setRadius } = PointHelper
5
+ const { toInnerRadiusPointOf, copyRadiusPoint } = PointHelper
6
6
  const { hitRadiusPoint, hitPoint } = BoundsHelper
7
7
  const inner = {} as IRadiusPointData, worldRadiusPoint = {} as IRadiusPointData
8
8
 
@@ -11,8 +11,7 @@ const leaf = Leaf.prototype
11
11
  leaf.hit = function (worldPoint: IPointData, hitRadius: number = 0): boolean {
12
12
  this.updateLayout()
13
13
 
14
- copy(worldRadiusPoint, worldPoint)
15
- setRadius(worldRadiusPoint, hitRadius)
14
+ copyRadiusPoint(worldRadiusPoint, worldPoint, hitRadius)
16
15
 
17
16
  const world = this.__world
18
17
  if (hitRadius ? !hitRadiusPoint(world, worldRadiusPoint) : !hitPoint(world, worldRadiusPoint)) return false
@@ -20,7 +19,7 @@ leaf.hit = function (worldPoint: IPointData, hitRadius: number = 0): boolean {
20
19
  return this.isBranch ? Platform.getSelector(this).hitPoint({ ...worldRadiusPoint }, hitRadius, { target: this as unknown as IBranch }) : this.__hitWorld(worldRadiusPoint)
21
20
  }
22
21
 
23
- leaf.__hitWorld = function (point: IRadiusPointData): boolean {
22
+ leaf.__hitWorld = function (point: IRadiusPointData, forceHitFill?: boolean): boolean {
24
23
  const data = this.__
25
24
  if (!data.hitSelf) return false
26
25
 
@@ -28,8 +27,8 @@ leaf.__hitWorld = function (point: IRadiusPointData): boolean {
28
27
  const isSmall = world.width < 10 && world.height < 10
29
28
 
30
29
  if (data.hitRadius) {
31
- copy(inner, point), point = inner
32
- setRadius(point, data.hitRadius)
30
+ copyRadiusPoint(inner, point, data.hitRadius)
31
+ point = inner
33
32
  }
34
33
 
35
34
  toInnerRadiusPointOf(point, world, inner)
@@ -44,7 +43,7 @@ leaf.__hitWorld = function (point: IRadiusPointData): boolean {
44
43
  if (!layout.boundsChanged) layout.hitCanvasChanged = false
45
44
  }
46
45
 
47
- return this.__hit(inner)
46
+ return this.__hit(inner, forceHitFill)
48
47
  }
49
48
 
50
49
  leaf.__hitFill = function (inner: IRadiusPointData): boolean { const h = this.__hitCanvas; return h && h.hitFill(inner, this.__.windingRule) }
package/src/UIHit.ts CHANGED
@@ -45,7 +45,7 @@ ui.__updateHitCanvas = function (): void {
45
45
 
46
46
  }
47
47
 
48
- ui.__hit = function (inner: IRadiusPointData): boolean {
48
+ ui.__hit = function (inner: IRadiusPointData, forceHitFill?: boolean): boolean {
49
49
 
50
50
  if (this.__box && this.__box.__hit(inner)) return true
51
51
 
@@ -55,7 +55,7 @@ ui.__hit = function (inner: IRadiusPointData): boolean {
55
55
 
56
56
  // hit path
57
57
  const { hitFill } = data
58
- const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all'
58
+ const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all' || forceHitFill
59
59
  if (needHitFillPath && this.__hitFill(inner)) return true
60
60
 
61
61
  const { hitStroke, __maxStrokeWidth: strokeWidth } = data