@leafer/selector
Advanced tools
+5
-5
| { | ||
| "name": "@leafer/selector", | ||
| "version": "1.0.0-alpha.9", | ||
| "version": "1.0.0-alpha.10", | ||
| "description": "@leafer/selector", | ||
@@ -22,9 +22,9 @@ "author": "Chao (Leafer) Wan", | ||
| "dependencies": { | ||
| "@leafer/event": "1.0.0-alpha.9", | ||
| "@leafer/math": "1.0.0-alpha.9", | ||
| "@leafer/list": "1.0.0-alpha.9" | ||
| "@leafer/event": "1.0.0-alpha.10", | ||
| "@leafer/math": "1.0.0-alpha.10", | ||
| "@leafer/list": "1.0.0-alpha.10" | ||
| }, | ||
| "devDependencies": { | ||
| "@leafer/interface": "1.0.0-alpha.9" | ||
| "@leafer/interface": "1.0.0-alpha.10" | ||
| } | ||
| } |
@@ -27,3 +27,3 @@ import { ILeaf, ILeafList, IPointData, IRadiusPointData, ISelectPathResult, ISelectPathOptions, ISelector } from '@leafer/interface' | ||
| const through = options ? options.through : false | ||
| this.exclude = options ? options.exclude : undefined | ||
| this.exclude = options ? options.exclude : null | ||
@@ -121,13 +121,13 @@ this.isStop = false | ||
| protected clear(): void { | ||
| this.point = undefined | ||
| this.leaf = undefined | ||
| this.throughPath = undefined | ||
| this.exclude = undefined | ||
| this.point = null | ||
| this.leaf = null | ||
| this.throughPath = null | ||
| this.exclude = null | ||
| } | ||
| public destroy(): void { | ||
| this.target = undefined | ||
| this.selector = undefined | ||
| this.target = null | ||
| this.selector = null | ||
| } | ||
| } |
+28
-27
@@ -16,7 +16,5 @@ import { ILeaf, ILeafArrayMap, ILeafMap, ISelector, ISelectPathResult, ISelectPathOptions, IPointData, ILeafList, IEventListenerId } from '@leafer/interface' | ||
| public target: ILeaf | ||
| protected pathFinder: PathFinder | ||
| public defaultPath: ILeafList | ||
| protected eventIds: IEventListenerId[] | ||
| protected pathFinder: PathFinder | ||
@@ -28,2 +26,4 @@ protected innerIdList: ILeafMap = {} | ||
| protected __eventIds: IEventListenerId[] | ||
| constructor(target: ILeaf) { | ||
@@ -33,21 +33,5 @@ this.target = target | ||
| this.pathFinder = new PathFinder(target, this) | ||
| this.listenEvents() | ||
| this.__listenEvents() | ||
| } | ||
| protected listenEvents(): void { | ||
| this.eventIds = [ | ||
| this.target.on__(ChildEvent.REMOVE, this.onRemoveChild, this) | ||
| ] | ||
| } | ||
| protected removeListenEvents(): void { | ||
| this.target.off__(this.eventIds) | ||
| } | ||
| protected onRemoveChild(event: ChildEvent): void { | ||
| const target = event.target as ILeaf | ||
| if (this.idList[target.id]) this.idList[target.id] = undefined | ||
| if (this.innerIdList[target.id]) this.innerIdList[target.innerId] = undefined | ||
| } | ||
| public getHitPointPath(hitPoint: IPointData, hitRadius: number, options?: ISelectPathOptions): ISelectPathResult { | ||
@@ -134,13 +118,30 @@ return this.pathFinder.getHitPointPath(hitPoint, hitRadius, options) | ||
| protected __onRemoveChild(event: ChildEvent): void { | ||
| const target = event.target as ILeaf | ||
| if (this.idList[target.id]) this.idList[target.id] = null | ||
| if (this.innerIdList[target.id]) this.innerIdList[target.innerId] = null | ||
| } | ||
| protected __listenEvents(): void { | ||
| this.__eventIds = [ | ||
| this.target.on__(ChildEvent.REMOVE, this.__onRemoveChild, this) | ||
| ] | ||
| } | ||
| protected __removeListenEvents(): void { | ||
| this.target.off__(this.__eventIds) | ||
| } | ||
| public destroy(): void { | ||
| if (this.target) { | ||
| this.removeListenEvents() | ||
| this.__removeListenEvents() | ||
| this.pathFinder.destroy() | ||
| this.target = undefined | ||
| this.pathFinder = undefined | ||
| this.innerIdList = undefined | ||
| this.idList = undefined | ||
| this.classNameList = undefined | ||
| this.tagNameList = undefined | ||
| this.target = null | ||
| this.pathFinder = null | ||
| this.innerIdList = null | ||
| this.idList = null | ||
| this.classNameList = null | ||
| this.tagNameList = null | ||
| } | ||
@@ -147,0 +148,0 @@ } |
9993
-0.51%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated