@leafer/selector 1.0.0-beta.12 → 1.0.0-beta.16
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 +7 -6
- package/src/FindPath.ts +3 -5
- package/src/Selector.ts +1 -3
- package/types/index.d.ts +48 -0
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/selector",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.16",
|
|
4
4
|
"description": "@leafer/selector",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
8
9
|
"files": [
|
|
9
|
-
"src"
|
|
10
|
+
"src",
|
|
11
|
+
"types",
|
|
12
|
+
"dist"
|
|
10
13
|
],
|
|
11
14
|
"repository": {
|
|
12
15
|
"type": "git",
|
|
@@ -19,11 +22,9 @@
|
|
|
19
22
|
"leaferjs"
|
|
20
23
|
],
|
|
21
24
|
"dependencies": {
|
|
22
|
-
"@leafer/
|
|
23
|
-
"@leafer/math": "1.0.0-beta.12",
|
|
24
|
-
"@leafer/list": "1.0.0-beta.12"
|
|
25
|
+
"@leafer/core": "1.0.0-beta.16"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
|
-
"@leafer/interface": "1.0.0-beta.
|
|
28
|
+
"@leafer/interface": "1.0.0-beta.16"
|
|
28
29
|
}
|
|
29
30
|
}
|
package/src/FindPath.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ILeaf, ILeafList, IPointData, IRadiusPointData, ISelectPathResult, ISelectPathOptions, ISelector } from '@leafer/interface'
|
|
2
|
-
import { BoundsHelper } from '@leafer/
|
|
3
|
-
import { LeafList } from '@leafer/list'
|
|
4
|
-
import { LeafHelper } from '@leafer/helper'
|
|
2
|
+
import { BoundsHelper, LeafList, LeafHelper } from '@leafer/core'
|
|
5
3
|
|
|
6
4
|
|
|
7
5
|
const { hitRadiusPoint } = BoundsHelper
|
|
@@ -111,8 +109,8 @@ export class FindPath {
|
|
|
111
109
|
const { point } = this, len = children.length
|
|
112
110
|
for (let i = len - 1; i > -1; i--) {
|
|
113
111
|
child = children[i]
|
|
114
|
-
if (hitMask && !child.isMask) continue
|
|
115
|
-
hit = hitRadiusPoint(child.__world, point)
|
|
112
|
+
if (!child.__.visible || (hitMask && !child.__.isMask)) continue
|
|
113
|
+
hit = child.__.hitRadius ? true : hitRadiusPoint(child.__world, point)
|
|
116
114
|
|
|
117
115
|
if (child.isBranch) {
|
|
118
116
|
if (hit || child.__ignoreHitWorld) {
|
package/src/Selector.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ILeaf, ILeafArrayMap, ILeafMap, ISelector, ISelectPathResult, ISelectPathOptions, IPointData, IEventListenerId, ISelectorConfig } from '@leafer/interface'
|
|
2
|
-
import { ChildEvent, LayoutEvent } from '@leafer/
|
|
3
|
-
import { DataHelper } from '@leafer/data'
|
|
4
|
-
import { Platform } from '@leafer/platform'
|
|
2
|
+
import { ChildEvent, LayoutEvent, DataHelper, Platform } from '@leafer/core'
|
|
5
3
|
|
|
6
4
|
import { FindPath } from './FindPath'
|
|
7
5
|
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ILeaf, ISelector, ILeafList, IRadiusPointData, IPointData, ISelectPathOptions, ISelectPathResult, ISelectorConfig, ILeafMap, ILeafArrayMap, IEventListenerId } from '@leafer/interface';
|
|
2
|
+
import { LeafList, ChildEvent } from '@leafer/core';
|
|
3
|
+
|
|
4
|
+
declare class FindPath {
|
|
5
|
+
protected target: ILeaf;
|
|
6
|
+
protected selector: ISelector;
|
|
7
|
+
protected findList: ILeaf[];
|
|
8
|
+
protected exclude: ILeafList;
|
|
9
|
+
protected point: IRadiusPointData;
|
|
10
|
+
constructor(target: ILeaf, selector: ISelector);
|
|
11
|
+
getByPoint(hitPoint: IPointData, hitRadius: number, options?: ISelectPathOptions): ISelectPathResult;
|
|
12
|
+
getBestMatchLeaf(): ILeaf;
|
|
13
|
+
getPath(leaf: ILeaf): LeafList;
|
|
14
|
+
getHitablePath(leaf: ILeaf): LeafList;
|
|
15
|
+
getThroughPath(list: ILeaf[]): LeafList;
|
|
16
|
+
protected eachFind(children: Array<ILeaf>, hitMask: boolean): void;
|
|
17
|
+
protected hitChild(child: ILeaf, point: IRadiusPointData): void;
|
|
18
|
+
protected clear(): void;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface IFind {
|
|
23
|
+
(leaf: ILeaf): boolean;
|
|
24
|
+
}
|
|
25
|
+
declare class Selector implements ISelector {
|
|
26
|
+
target: ILeaf;
|
|
27
|
+
config: ISelectorConfig;
|
|
28
|
+
protected findPath: FindPath;
|
|
29
|
+
protected innerIdList: ILeafMap;
|
|
30
|
+
protected idList: ILeafMap;
|
|
31
|
+
protected classNameList: ILeafArrayMap;
|
|
32
|
+
protected tagNameList: ILeafArrayMap;
|
|
33
|
+
protected __eventIds: IEventListenerId[];
|
|
34
|
+
constructor(target: ILeaf, userConfig?: ISelectorConfig);
|
|
35
|
+
getByPoint(hitPoint: IPointData, hitRadius: number, options?: ISelectPathOptions): ISelectPathResult;
|
|
36
|
+
find(name: number | string, branch?: ILeaf): ILeaf | ILeaf[];
|
|
37
|
+
getByInnerId(name: number, branch?: ILeaf): ILeaf;
|
|
38
|
+
getById(name: string, branch?: ILeaf): ILeaf;
|
|
39
|
+
getByClassName(name: string, branch?: ILeaf): ILeaf[];
|
|
40
|
+
getByTagName(name: string, branch?: ILeaf): ILeaf[];
|
|
41
|
+
protected loopFind(branch: ILeaf, find: IFind): void;
|
|
42
|
+
protected __onRemoveChild(event: ChildEvent): void;
|
|
43
|
+
protected __listenEvents(): void;
|
|
44
|
+
protected __removeListenEvents(): void;
|
|
45
|
+
destroy(): void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { Selector };
|