@leafer/selector 1.0.0-alpha.1 → 1.0.0-alpha.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 +8 -6
- package/src/PathFinder.ts +7 -7
- package/src/Selector.ts +28 -27
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/selector",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.10",
|
|
4
4
|
"description": "@leafer/selector",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
|
-
"files": [
|
|
8
|
+
"files": [
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
9
11
|
"repository": {
|
|
10
12
|
"type": "git",
|
|
11
13
|
"url": "https://github.com/leaferjs/leafer.git"
|
|
@@ -17,11 +19,11 @@
|
|
|
17
19
|
"leaferjs"
|
|
18
20
|
],
|
|
19
21
|
"dependencies": {
|
|
20
|
-
"@leafer/event": "1.0.0-alpha.
|
|
21
|
-
"@leafer/math": "1.0.0-alpha.
|
|
22
|
-
"@leafer/list": "1.0.0-alpha.
|
|
22
|
+
"@leafer/event": "1.0.0-alpha.10",
|
|
23
|
+
"@leafer/math": "1.0.0-alpha.10",
|
|
24
|
+
"@leafer/list": "1.0.0-alpha.10"
|
|
23
25
|
},
|
|
24
26
|
"devDependencies": {
|
|
25
|
-
|
|
27
|
+
"@leafer/interface": "1.0.0-alpha.10"
|
|
26
28
|
}
|
|
27
29
|
}
|
package/src/PathFinder.ts
CHANGED
|
@@ -24,7 +24,7 @@ export class PathFinder {
|
|
|
24
24
|
|
|
25
25
|
public getHitPointPath(hitPoint: IPointData, hitRadius: number, options?: ISelectPathOptions): ISelectPathResult {
|
|
26
26
|
const through = options ? options.through : false
|
|
27
|
-
this.exclude = options ? options.exclude :
|
|
27
|
+
this.exclude = options ? options.exclude : null
|
|
28
28
|
|
|
29
29
|
this.isStop = false
|
|
30
30
|
this.point = { x: hitPoint.x, y: hitPoint.y, radiusX: hitRadius, radiusY: hitRadius }
|
|
@@ -117,15 +117,15 @@ export class PathFinder {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
protected clear(): void {
|
|
120
|
-
this.point =
|
|
121
|
-
this.leaf =
|
|
122
|
-
this.throughPath =
|
|
123
|
-
this.exclude =
|
|
120
|
+
this.point = null
|
|
121
|
+
this.leaf = null
|
|
122
|
+
this.throughPath = null
|
|
123
|
+
this.exclude = null
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
public destroy(): void {
|
|
127
|
-
this.target =
|
|
128
|
-
this.selector =
|
|
127
|
+
this.target = null
|
|
128
|
+
this.selector = null
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
}
|
package/src/Selector.ts
CHANGED
|
@@ -13,38 +13,22 @@ interface IFind {
|
|
|
13
13
|
export class Selector implements ISelector {
|
|
14
14
|
|
|
15
15
|
public target: ILeaf
|
|
16
|
-
protected pathFinder: PathFinder
|
|
17
|
-
|
|
18
16
|
public defaultPath: ILeafList
|
|
19
17
|
|
|
20
|
-
protected
|
|
18
|
+
protected pathFinder: PathFinder
|
|
21
19
|
|
|
22
20
|
protected innerIdList: ILeafMap = {}
|
|
23
21
|
protected idList: ILeafMap = {}
|
|
24
22
|
protected classNameList: ILeafArrayMap = {}
|
|
25
23
|
protected tagNameList: ILeafArrayMap = {}
|
|
26
24
|
|
|
25
|
+
protected __eventIds: IEventListenerId[]
|
|
26
|
+
|
|
27
27
|
constructor(target: ILeaf) {
|
|
28
28
|
this.target = target
|
|
29
29
|
this.defaultPath = new LeafList(target)
|
|
30
30
|
this.pathFinder = new PathFinder(target, this)
|
|
31
|
-
this.
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
protected listenEvents(): void {
|
|
35
|
-
this.eventIds = [
|
|
36
|
-
this.target.on__(ChildEvent.REMOVE, this.onRemoveChild, this)
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
protected removeListenEvents(): void {
|
|
41
|
-
this.target.off__(this.eventIds)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
protected onRemoveChild(event: ChildEvent): void {
|
|
45
|
-
const target = event.target as ILeaf
|
|
46
|
-
if (this.idList[target.id]) this.idList[target.id] = undefined
|
|
47
|
-
if (this.innerIdList[target.id]) this.innerIdList[target.innerId] = undefined
|
|
31
|
+
this.__listenEvents()
|
|
48
32
|
}
|
|
49
33
|
|
|
50
34
|
public getHitPointPath(hitPoint: IPointData, hitRadius: number, options?: ISelectPathOptions): ISelectPathResult {
|
|
@@ -128,17 +112,34 @@ export class Selector implements ISelector {
|
|
|
128
112
|
}
|
|
129
113
|
}
|
|
130
114
|
|
|
115
|
+
protected __onRemoveChild(event: ChildEvent): void {
|
|
116
|
+
const target = event.target as ILeaf
|
|
117
|
+
if (this.idList[target.id]) this.idList[target.id] = null
|
|
118
|
+
if (this.innerIdList[target.id]) this.innerIdList[target.innerId] = null
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
protected __listenEvents(): void {
|
|
123
|
+
this.__eventIds = [
|
|
124
|
+
this.target.on__(ChildEvent.REMOVE, this.__onRemoveChild, this)
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
protected __removeListenEvents(): void {
|
|
129
|
+
this.target.off__(this.__eventIds)
|
|
130
|
+
}
|
|
131
|
+
|
|
131
132
|
public destroy(): void {
|
|
132
133
|
if (this.target) {
|
|
133
|
-
this.
|
|
134
|
+
this.__removeListenEvents()
|
|
134
135
|
this.pathFinder.destroy()
|
|
135
136
|
|
|
136
|
-
this.target =
|
|
137
|
-
this.pathFinder =
|
|
138
|
-
this.innerIdList =
|
|
139
|
-
this.idList =
|
|
140
|
-
this.classNameList =
|
|
141
|
-
this.tagNameList =
|
|
137
|
+
this.target = null
|
|
138
|
+
this.pathFinder = null
|
|
139
|
+
this.innerIdList = null
|
|
140
|
+
this.idList = null
|
|
141
|
+
this.classNameList = null
|
|
142
|
+
this.tagNameList = null
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
|