@leafer/selector 1.9.8 → 1.9.10
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 +3 -3
- package/src/Picker.ts +20 -4
- package/types/index.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/selector",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.10",
|
|
4
4
|
"description": "@leafer/selector",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.9.
|
|
25
|
+
"@leafer/core": "1.9.10"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@leafer/interface": "1.9.
|
|
28
|
+
"@leafer/interface": "1.9.10"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/Picker.ts
CHANGED
|
@@ -35,7 +35,7 @@ export class Picker implements IPicker {
|
|
|
35
35
|
if (!options.findList) this.hitBranch(target.isBranchLeaf ? { children: [target] } as ILeaf : target) // 包含through元素
|
|
36
36
|
|
|
37
37
|
const { list } = this.findList
|
|
38
|
-
const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable)
|
|
38
|
+
const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable, !!options.findList)
|
|
39
39
|
const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf)
|
|
40
40
|
|
|
41
41
|
this.clear()
|
|
@@ -47,7 +47,7 @@ export class Picker implements IPicker {
|
|
|
47
47
|
return !!this.getByPoint(hitPoint, hitRadius, options).target // 后期需进行优化 !!!
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
public getBestMatchLeaf(list: ILeaf[], bottomList: IPickBottom[], ignoreHittable: boolean): ILeaf {
|
|
50
|
+
public getBestMatchLeaf(list: ILeaf[], bottomList: IPickBottom[], ignoreHittable: boolean, allowNull?: boolean): ILeaf {
|
|
51
51
|
const findList = this.findList = new LeafList()
|
|
52
52
|
|
|
53
53
|
if (list.length) {
|
|
@@ -76,16 +76,32 @@ export class Picker implements IPicker {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
if (allowNull) return null
|
|
79
80
|
return ignoreHittable ? list[0] : list.find(item => LeafHelper.worldHittable(item))
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
public getPath(leaf: ILeaf): LeafList {
|
|
83
|
-
const path = new LeafList()
|
|
84
|
+
const path = new LeafList(), syncList = [], { target } = this
|
|
85
|
+
|
|
84
86
|
while (leaf) {
|
|
87
|
+
if (leaf.syncEventer) syncList.push(leaf.syncEventer)
|
|
85
88
|
path.add(leaf)
|
|
86
89
|
leaf = leaf.parent
|
|
90
|
+
if (leaf === target) break
|
|
87
91
|
}
|
|
88
|
-
|
|
92
|
+
|
|
93
|
+
// 存在同步触发
|
|
94
|
+
if (syncList.length) {
|
|
95
|
+
syncList.forEach(item => {
|
|
96
|
+
while (item) {
|
|
97
|
+
if (item.__.hittable) path.add(item)
|
|
98
|
+
item = item.parent
|
|
99
|
+
if (item === target) break
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (target) path.add(target)
|
|
89
105
|
return path
|
|
90
106
|
}
|
|
91
107
|
|
package/types/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ declare class Picker implements IPicker {
|
|
|
23
23
|
constructor(target: ILeaf, selector: ISelector);
|
|
24
24
|
getByPoint(hitPoint: IPointData, hitRadius: number, options?: IPickOptions): IPickResult;
|
|
25
25
|
hitPoint(hitPoint: IPointData, hitRadius: number, options?: IPickOptions): boolean;
|
|
26
|
-
getBestMatchLeaf(list: ILeaf[], bottomList: IPickBottom[], ignoreHittable: boolean): ILeaf;
|
|
26
|
+
getBestMatchLeaf(list: ILeaf[], bottomList: IPickBottom[], ignoreHittable: boolean, allowNull?: boolean): ILeaf;
|
|
27
27
|
getPath(leaf: ILeaf): LeafList;
|
|
28
28
|
getHitablePath(leaf: ILeaf): LeafList;
|
|
29
29
|
getThroughPath(list: ILeaf[]): LeafList;
|