@leafer/selector 1.0.0-alpha.10 → 1.0.0-alpha.23

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/selector",
3
- "version": "1.0.0-alpha.10",
3
+ "version": "1.0.0-alpha.23",
4
4
  "description": "@leafer/selector",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -19,11 +19,11 @@
19
19
  "leaferjs"
20
20
  ],
21
21
  "dependencies": {
22
- "@leafer/event": "1.0.0-alpha.10",
23
- "@leafer/math": "1.0.0-alpha.10",
24
- "@leafer/list": "1.0.0-alpha.10"
22
+ "@leafer/event": "1.0.0-alpha.23",
23
+ "@leafer/math": "1.0.0-alpha.23",
24
+ "@leafer/list": "1.0.0-alpha.23"
25
25
  },
26
26
  "devDependencies": {
27
- "@leafer/interface": "1.0.0-alpha.10"
27
+ "@leafer/interface": "1.0.0-alpha.23"
28
28
  }
29
29
  }
package/src/PathFinder.ts CHANGED
@@ -30,7 +30,7 @@ export class PathFinder {
30
30
  this.point = { x: hitPoint.x, y: hitPoint.y, radiusX: hitRadius, radiusY: hitRadius }
31
31
 
32
32
  // path
33
- this.eachFind(this.target.children)
33
+ this.eachFind(this.target.children, this.target.__hasMask)
34
34
 
35
35
  const { leaf } = this
36
36
  const { defaultPath } = this.selector
@@ -42,7 +42,7 @@ export class PathFinder {
42
42
  // throughPath
43
43
  if (through) {
44
44
  const throughPath = this.throughPath = new LeafList()
45
- this.eachThroughFind(this.target.children)
45
+ this.eachThroughFind(this.target.children, this.target.__hasMask)
46
46
  throughPath.pushList(defaultPath.list)
47
47
  result = { path, leaf, throughPath }
48
48
  } else {
@@ -64,47 +64,44 @@ export class PathFinder {
64
64
  return list
65
65
  }
66
66
 
67
- protected eachThroughFind(children: Array<ILeaf>): void {
67
+ protected eachThroughFind(children: Array<ILeaf>, hasMask: boolean): void {
68
68
  let child: ILeaf
69
69
  const { point } = this, len = children.length
70
70
  for (let i = len - 1; i > -1; i--) {
71
71
  child = children[i]
72
- if (child.__interactionOff) continue
72
+ if (hasMask ? child.isMask && child.__.hittable : child.__.hittable) {
73
+ if (hitRadiusPoint(child.__world, point)) {
74
+ if (child.__isBranch && child.__.hitChildren) this.eachThroughFind(child.children, child.__hasMask)
73
75
 
74
- if (hitRadiusPoint(child.__world, point)) {
75
- if (child.__isBranch) {
76
- child.__childrenInteractionOff || this.eachThroughFind(child.children)
76
+ if (this.exclude && this.exclude.has(child)) continue
77
+ if (child.__hitWorld(point)) this.throughPath.push(child)
77
78
  }
78
-
79
- if (this.exclude && this.exclude.has(child)) continue
80
- if (child.__hitWorld(point)) this.throughPath.push(child)
81
79
  }
82
-
83
80
  }
84
81
  }
85
82
 
86
- protected eachFind(children: Array<ILeaf>): void {
83
+ protected eachFind(children: Array<ILeaf>, hasMask: boolean): void {
87
84
  let child: ILeaf
88
85
  const { point } = this, len = children.length
89
86
  for (let i = len - 1; i > -1; i--) {
90
87
  child = children[i]
91
- if (child.__interactionOff) continue
88
+ if (hasMask ? child.isMask && child.__.hittable : child.__.hittable) {
89
+ if (hitRadiusPoint(child.__world, point)) {
90
+ if (child.__isBranch) {
92
91
 
93
- if (hitRadiusPoint(child.__world, point)) {
94
- if (child.__isBranch) {
92
+ if (child.__.hitChildren) this.eachFind(child.children, child.__hasMask)
95
93
 
96
- child.__childrenInteractionOff || this.eachFind(child.children)
94
+ if (child.__isBranchLeaf) { // 填充了背景色的Group, 如画板/Frame元素
95
+ if (!this.isStop) this.hitChild(child, point)
96
+ }
97
97
 
98
- if (child.__isBranchLeaf) { // 填充了背景色的Group, 如画板/Frame元素
99
- if (!this.isStop) this.hitChild(child, point)
98
+ } else {
99
+ this.hitChild(child, point)
100
100
  }
101
-
102
- } else {
103
- this.hitChild(child, point)
104
101
  }
105
- }
106
102
 
107
- if (this.isStop) break
103
+ if (this.isStop) break
104
+ }
108
105
  }
109
106
  }
110
107
 
package/src/Selector.ts CHANGED
@@ -96,7 +96,7 @@ export class Selector implements ISelector {
96
96
  if (!branch) branch = this.target
97
97
  let find: Array<ILeaf | ILeaf> = []
98
98
  this.loopFind(branch, (leaf) => {
99
- if (leaf.tag === name) find.push(leaf)
99
+ if (leaf.__tag === name) find.push(leaf)
100
100
  return false
101
101
  })
102
102
  return find