@leafer-ui/hit 1.0.6 → 1.0.7

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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/find.ts +9 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/hit",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
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.6",
26
- "@leafer-ui/draw": "1.0.6"
25
+ "@leafer/core": "1.0.7",
26
+ "@leafer-ui/draw": "1.0.7"
27
27
  },
28
28
  "devDependencies": {
29
- "@leafer/interface": "1.0.6",
30
- "@leafer-ui/interface": "1.0.6"
29
+ "@leafer/interface": "1.0.7",
30
+ "@leafer-ui/interface": "1.0.7"
31
31
  }
32
32
  }
package/src/find.ts CHANGED
@@ -1,21 +1,25 @@
1
1
 
2
- import { IFindMethod, IPointData, IPickOptions, IPickResult } from '@leafer/interface'
2
+ import { IFindMethod, IPointData, IPickOptions, IPickResult, ISelector } from '@leafer/interface'
3
3
  import { IFindUIMethod, IUI } from '@leafer-ui/interface'
4
- import { UI, Group } from '@leafer-ui/draw'
4
+ import { UI, Group, Creator, Platform } from '@leafer-ui/draw'
5
5
 
6
6
 
7
7
  const ui = UI.prototype, group = Group.prototype
8
8
 
9
+ function getSelector(ui: IUI): ISelector {
10
+ return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()))
11
+ }
12
+
9
13
  ui.find = function (condition: number | string | IFindUIMethod, options?: any): IUI[] {
10
- return this.leafer ? this.leafer.selector.getBy(condition as IFindMethod, this, false, options) as IUI[] : []
14
+ return getSelector(this).getBy(condition as IFindMethod, this, false, options) as IUI[]
11
15
  }
12
16
 
13
17
  ui.findOne = function (condition: number | string | IFindUIMethod, options?: any): IUI | undefined {
14
- return this.leafer ? this.leafer.selector.getBy(condition as IFindMethod, this, true, options) as IUI : null
18
+ return getSelector(this).getBy(condition as IFindMethod, this, true, options) as IUI
15
19
  }
16
20
 
17
21
  group.pick = function (hitPoint: IPointData, options?: IPickOptions): IPickResult {
18
22
  this.__layout.update()
19
23
  if (!options) options = {}
20
- return this.leafer ? this.leafer.selector.getByPoint(hitPoint, options.hitRadius || 0, { ...options, target: this }) : null
24
+ return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, { ...options, target: this })
21
25
  }