@leafer/selector 1.0.0-beta.11 → 1.0.0-beta.15

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,12 +1,15 @@
1
1
  {
2
2
  "name": "@leafer/selector",
3
- "version": "1.0.0-beta.11",
3
+ "version": "1.0.0-beta.15",
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/event": "1.0.0-beta.11",
23
- "@leafer/math": "1.0.0-beta.11",
24
- "@leafer/list": "1.0.0-beta.11"
25
+ "@leafer/core": "1.0.0-beta.15"
25
26
  },
26
27
  "devDependencies": {
27
- "@leafer/interface": "1.0.0-beta.11"
28
+ "@leafer/interface": "1.0.0-beta.15"
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/math'
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) {
@@ -137,8 +135,7 @@ export class FindPath {
137
135
  }
138
136
 
139
137
  public destroy(): void {
140
- this.target = null
141
- this.selector = null
138
+ this.clear()
142
139
  }
143
140
 
144
141
  }
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/event'
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
 
@@ -129,19 +127,17 @@ export class Selector implements ISelector {
129
127
 
130
128
  protected __removeListenEvents(): void {
131
129
  this.target.off_(this.__eventIds)
130
+ this.__eventIds.length = 0
132
131
  }
133
132
 
134
133
  public destroy(): void {
135
- if (this.target) {
134
+ if (this.__eventIds.length) {
136
135
  this.__removeListenEvents()
137
136
  this.findPath.destroy()
138
-
139
- this.target = null
140
- this.findPath = null
141
- this.innerIdList = null
142
- this.idList = null
143
- this.classNameList = null
144
- this.tagNameList = null
137
+ this.innerIdList = {}
138
+ this.idList = {}
139
+ this.classNameList = {}
140
+ this.tagNameList = {}
145
141
  }
146
142
  }
147
143
 
@@ -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 };