@leafer/selector 1.0.0-alpha.21 → 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.21",
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.21",
23
- "@leafer/math": "1.0.0-alpha.21",
24
- "@leafer/list": "1.0.0-alpha.21"
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.21"
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,14 +64,14 @@ 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.__.hittable) {
72
+ if (hasMask ? child.isMask && child.__.hittable : child.__.hittable) {
73
73
  if (hitRadiusPoint(child.__world, point)) {
74
- if (child.__isBranch && child.__.hitChildren) this.eachThroughFind(child.children)
74
+ if (child.__isBranch && child.__.hitChildren) this.eachThroughFind(child.children, child.__hasMask)
75
75
 
76
76
  if (this.exclude && this.exclude.has(child)) continue
77
77
  if (child.__hitWorld(point)) this.throughPath.push(child)
@@ -80,16 +80,16 @@ export class PathFinder {
80
80
  }
81
81
  }
82
82
 
83
- protected eachFind(children: Array<ILeaf>): void {
83
+ protected eachFind(children: Array<ILeaf>, hasMask: boolean): void {
84
84
  let child: ILeaf
85
85
  const { point } = this, len = children.length
86
86
  for (let i = len - 1; i > -1; i--) {
87
87
  child = children[i]
88
- if (child.__.hittable) {
88
+ if (hasMask ? child.isMask && child.__.hittable : child.__.hittable) {
89
89
  if (hitRadiusPoint(child.__world, point)) {
90
90
  if (child.__isBranch) {
91
91
 
92
- if (child.__.hitChildren) this.eachFind(child.children)
92
+ if (child.__.hitChildren) this.eachFind(child.children, child.__hasMask)
93
93
 
94
94
  if (child.__isBranchLeaf) { // 填充了背景色的Group, 如画板/Frame元素
95
95
  if (!this.isStop) this.hitChild(child, point)
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