@leafer-ui/hit 1.0.0-rc.21 → 1.0.0-rc.22

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.0.0-rc.21",
3
+ "version": "1.0.0-rc.22",
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.0.0-rc.21",
26
- "@leafer-ui/draw": "1.0.0-rc.21"
25
+ "@leafer/core": "1.0.0-rc.22",
26
+ "@leafer-ui/draw": "1.0.0-rc.22"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.0.0-rc.21",
30
- "@leafer-ui/interface": "1.0.0-rc.21"
29
+ "@leafer/interface": "1.0.0-rc.22",
30
+ "@leafer-ui/interface": "1.0.0-rc.22"
31
31
  }
32
32
  }
package/src/LeafHit.ts CHANGED
@@ -8,6 +8,8 @@ const inner = {} as IRadiusPointData
8
8
  const leaf = Leaf.prototype
9
9
 
10
10
  leaf.__hitWorld = function (point: IRadiusPointData): boolean {
11
+ if (!this.__.hitSelf) return false
12
+
11
13
  if (this.__.hitRadius) {
12
14
  copy(inner, point), point = inner
13
15
  setRadius(point, this.__.hitRadius)
package/src/RectHit.ts CHANGED
@@ -4,13 +4,14 @@ import { Rect, UI } from '@leafer-ui/draw'
4
4
 
5
5
 
6
6
  const ui = new UI()
7
+ const rect = Rect.prototype
7
8
 
8
9
  // hit
9
10
 
10
- Rect.prototype.__updateHitCanvas = function () {
11
+ rect.__updateHitCanvas = function () {
11
12
  if (this.stroke || this.cornerRadius) ui.__updateHitCanvas.call(this)
12
13
  }
13
14
 
14
- Rect.prototype.__hitFill = function (inner: IRadiusPointData): boolean {
15
+ rect.__hitFill = function (inner: IRadiusPointData): boolean {
15
16
  return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner)
16
17
  }
package/src/index.ts CHANGED
@@ -7,15 +7,17 @@ import { IFindUIMethod, IUI } from '@leafer-ui/interface'
7
7
  import { UI, Group } from '@leafer-ui/draw'
8
8
 
9
9
 
10
- UI.prototype.find = function (condition: number | string | IFindUIMethod, options?: any): IUI[] {
10
+ const ui = UI.prototype, group = Group.prototype
11
+
12
+ ui.find = function (condition: number | string | IFindUIMethod, options?: any): IUI[] {
11
13
  return this.leafer ? this.leafer.selector.getBy(condition as IFindMethod, this, false, options) as IUI[] : []
12
14
  }
13
15
 
14
- UI.prototype.findOne = function (condition: number | string | IFindUIMethod, options?: any): IUI {
16
+ ui.findOne = function (condition: number | string | IFindUIMethod, options?: any): IUI {
15
17
  return this.leafer ? this.leafer.selector.getBy(condition as IFindMethod, this, true, options) as IUI : null
16
18
  }
17
19
 
18
- Group.prototype.pick = function (hitPoint: IPointData, options?: IPickOptions): IPickResult {
20
+ group.pick = function (hitPoint: IPointData, options?: IPickOptions): IPickResult {
19
21
  this.__layout.update()
20
22
  if (!options) options = {}
21
23
  return this.leafer ? this.leafer.selector.getByPoint(hitPoint, options.hitRadius || 0, { ...options, target: this }) : null