Improved button group stack sorting.
This commit is contained in:
@@ -2029,15 +2029,24 @@ export default class ButtonGroup extends PIXI.Container {
|
||||
// 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))
|
||||
}
|
||||
@@ -2077,15 +2086,24 @@ export default class ButtonGroup extends PIXI.Container {
|
||||
// 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))
|
||||
}
|
||||
@@ -2103,7 +2121,7 @@ export default class ButtonGroup extends PIXI.Container {
|
||||
|
||||
<footer class="content-size">
|
||||
<div class="footer">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Thu Aug 01 2019 10:30:39 GMT+0200 (Mitteleuropäische Sommerzeit)
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Thu Aug 01 2019 11:26:03 GMT+0200 (Mitteleuropäische Sommerzeit)
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user