Improved button group stack sorting.
This commit is contained in:
Vendored
+34
-16
@@ -3502,15 +3502,24 @@
|
||||
// z-index
|
||||
sorted
|
||||
.sort((a, b) => {
|
||||
const distanceA = Math.abs(a.x - center);
|
||||
const distanceB = Math.abs(b.x - center);
|
||||
if (distanceA < distanceB) {
|
||||
return 1
|
||||
} else if (distanceA > distanceB) {
|
||||
return -1
|
||||
} else {
|
||||
return 0
|
||||
const centerA = a.x + a.button.width / 2;
|
||||
const centerB = b.x + b.button.width / 2;
|
||||
|
||||
if (centerA < center && centerB < center) {
|
||||
if (a.x < b.x) {
|
||||
return -1
|
||||
} else if (b.x < a.x) {
|
||||
return 1
|
||||
}
|
||||
} else if (centerA > center && centerB > center) {
|
||||
if (a.x + a.button.width > b.x + b.button.width) {
|
||||
return -1
|
||||
} else if (b.x + b.button.width < a.x + a.button.x) {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
})
|
||||
.forEach(it => it.parent.addChild(it));
|
||||
}
|
||||
@@ -3550,15 +3559,24 @@
|
||||
// z-index
|
||||
sorted
|
||||
.sort((a, b) => {
|
||||
const distanceA = Math.abs(a.y - center);
|
||||
const distanceB = Math.abs(b.y - center);
|
||||
if (distanceA < distanceB) {
|
||||
return 1
|
||||
} else if (distanceA > distanceB) {
|
||||
return -1
|
||||
} else {
|
||||
return 0
|
||||
const centerA = a.y + a.button.height / 2;
|
||||
const centerB = b.y + b.button.height / 2;
|
||||
|
||||
if (centerA < center && centerB < center) {
|
||||
if (a.y < b.y) {
|
||||
return -1
|
||||
} else if (b.y < a.y) {
|
||||
return 1
|
||||
}
|
||||
} else if (centerA > center && centerB > center) {
|
||||
if (a.y + a.button.height > b.y + b.button.height) {
|
||||
return -1
|
||||
} else if (b.y + b.button.height < a.y + a.button.y) {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
})
|
||||
.forEach(it => it.parent.addChild(it));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user