diff --git a/dist/iwmlib.pixi.js b/dist/iwmlib.pixi.js index b172daa..83f6fdd 100644 --- a/dist/iwmlib.pixi.js +++ b/dist/iwmlib.pixi.js @@ -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)); } diff --git a/doc/out/AbstractPopup.html b/doc/out/AbstractPopup.html index 36edcba..65a3bce 100644 --- a/doc/out/AbstractPopup.html +++ b/doc/out/AbstractPopup.html @@ -2920,7 +2920,7 @@ a string, a number or a PIXI.Text object.

diff --git a/doc/out/Badge.html b/doc/out/Badge.html index 8ebe070..d82153d 100644 --- a/doc/out/Badge.html +++ b/doc/out/Badge.html @@ -2376,7 +2376,7 @@ a string, a number or a PIXI.Text object.

diff --git a/doc/out/BlurFilter.html b/doc/out/BlurFilter.html index 97bfd82..33f3d24 100644 --- a/doc/out/BlurFilter.html +++ b/doc/out/BlurFilter.html @@ -1800,7 +1800,7 @@ app.scene.filters = [blurFilter] diff --git a/doc/out/Button.html b/doc/out/Button.html index b0ca13c..a2e0c16 100644 --- a/doc/out/Button.html +++ b/doc/out/Button.html @@ -3818,7 +3818,7 @@ the tint property of the icon sprite.

diff --git a/doc/out/ButtonGroup.html b/doc/out/ButtonGroup.html index f051f1a..7d63851 100644 --- a/doc/out/ButtonGroup.html +++ b/doc/out/ButtonGroup.html @@ -3107,7 +3107,7 @@ app.scene.addChild(buttonGroup)
- buttongroup.js:602 + buttongroup.js:611
@@ -3692,7 +3692,7 @@ app.scene.addChild(buttonGroup) diff --git a/doc/out/DeepZoomImage.html b/doc/out/DeepZoomImage.html index 179e06b..f56db59 100644 --- a/doc/out/DeepZoomImage.html +++ b/doc/out/DeepZoomImage.html @@ -5098,7 +5098,7 @@ i.e. after loading a single tile

diff --git a/doc/out/DeepZoomInfo.html b/doc/out/DeepZoomInfo.html index 2433ff4..013f3c8 100644 --- a/doc/out/DeepZoomInfo.html +++ b/doc/out/DeepZoomInfo.html @@ -2611,7 +2611,7 @@ on completion.

diff --git a/doc/out/Flippable.html b/doc/out/Flippable.html index 188504e..601ecf3 100644 --- a/doc/out/Flippable.html +++ b/doc/out/Flippable.html @@ -2514,7 +2514,7 @@ front.on('click', event => flippable.toggle()) diff --git a/doc/out/FontInfo.html b/doc/out/FontInfo.html index a1f086b..7b98696 100644 --- a/doc/out/FontInfo.html +++ b/doc/out/FontInfo.html @@ -1561,7 +1561,7 @@ diff --git a/doc/out/Hypenate.html b/doc/out/Hypenate.html index e544a34..cfeac6c 100644 --- a/doc/out/Hypenate.html +++ b/doc/out/Hypenate.html @@ -1763,7 +1763,7 @@ diff --git a/doc/out/InteractivePopup.html b/doc/out/InteractivePopup.html index c310cd5..5283cb4 100644 --- a/doc/out/InteractivePopup.html +++ b/doc/out/InteractivePopup.html @@ -2345,7 +2345,7 @@ a string, a number or a PIXI.Text object.

diff --git a/doc/out/LabeledGraphics.exports.LabeledGraphics.html b/doc/out/LabeledGraphics.exports.LabeledGraphics.html index bf71bbc..e3ada67 100644 --- a/doc/out/LabeledGraphics.exports.LabeledGraphics.html +++ b/doc/out/LabeledGraphics.exports.LabeledGraphics.html @@ -1563,7 +1563,7 @@ diff --git a/doc/out/LabeledGraphics.html b/doc/out/LabeledGraphics.html index 81270b7..060e318 100644 --- a/doc/out/LabeledGraphics.html +++ b/doc/out/LabeledGraphics.html @@ -2628,7 +2628,7 @@ than wanted

diff --git a/doc/out/List.html b/doc/out/List.html index b561118..67dea74 100644 --- a/doc/out/List.html +++ b/doc/out/List.html @@ -2587,7 +2587,7 @@ app.scene.addChild(list) diff --git a/doc/out/Message.html b/doc/out/Message.html index 6387fc2..d1043fc 100644 --- a/doc/out/Message.html +++ b/doc/out/Message.html @@ -2443,7 +2443,7 @@ a string, a number or a PIXI.Text object.

diff --git a/doc/out/MessageInteractivePopup.html b/doc/out/MessageInteractivePopup.html index c8c77a5..c5c3ee1 100644 --- a/doc/out/MessageInteractivePopup.html +++ b/doc/out/MessageInteractivePopup.html @@ -1791,7 +1791,7 @@ like Popup, Message...

diff --git a/doc/out/MessageMessageInteractivePopup.html b/doc/out/MessageMessageInteractivePopup.html index 6a9f109..a755058 100644 --- a/doc/out/MessageMessageInteractivePopup.html +++ b/doc/out/MessageMessageInteractivePopup.html @@ -1791,7 +1791,7 @@ like Popup, Message...

diff --git a/doc/out/Modal.html b/doc/out/Modal.html index cc321ed..302cd6c 100644 --- a/doc/out/Modal.html +++ b/doc/out/Modal.html @@ -2344,7 +2344,7 @@ a string or a PIXI.Text object.

diff --git a/doc/out/ModalInteractivePopup.html b/doc/out/ModalInteractivePopup.html index a45a194..e65567c 100644 --- a/doc/out/ModalInteractivePopup.html +++ b/doc/out/ModalInteractivePopup.html @@ -1791,7 +1791,7 @@ like Popup, Message...

diff --git a/doc/out/ModalModalInteractivePopup.html b/doc/out/ModalModalInteractivePopup.html index b1ca8cb..097a079 100644 --- a/doc/out/ModalModalInteractivePopup.html +++ b/doc/out/ModalModalInteractivePopup.html @@ -1791,7 +1791,7 @@ like Popup, Message...

diff --git a/doc/out/PIXIApp.html b/doc/out/PIXIApp.html index 433900e..fcbc3a9 100644 --- a/doc/out/PIXIApp.html +++ b/doc/out/PIXIApp.html @@ -5745,7 +5745,7 @@ rejected with an error. diff --git a/doc/out/Popup.html b/doc/out/Popup.html index 4cbc968..56f368a 100644 --- a/doc/out/Popup.html +++ b/doc/out/Popup.html @@ -2338,7 +2338,7 @@ a string, a number or a PIXI.Text object.

diff --git a/doc/out/PopupInteractivePopup.html b/doc/out/PopupInteractivePopup.html index 4a54afe..313c7dc 100644 --- a/doc/out/PopupInteractivePopup.html +++ b/doc/out/PopupInteractivePopup.html @@ -1791,7 +1791,7 @@ like Popup, Message...

diff --git a/doc/out/PopupMenu.html b/doc/out/PopupMenu.html index b4d92dc..da8b85b 100644 --- a/doc/out/PopupMenu.html +++ b/doc/out/PopupMenu.html @@ -2392,7 +2392,7 @@ a string, a number or a PIXI.Text object.

diff --git a/doc/out/PopupMenuPopupInteractivePopup.html b/doc/out/PopupMenuPopupInteractivePopup.html index 1c78dff..d1bf56f 100644 --- a/doc/out/PopupMenuPopupInteractivePopup.html +++ b/doc/out/PopupMenuPopupInteractivePopup.html @@ -1791,7 +1791,7 @@ like Popup, Message...

diff --git a/doc/out/PopupMenuPopupMenuPopupInteractivePopup.html b/doc/out/PopupMenuPopupMenuPopupInteractivePopup.html index 3f2d007..7c10884 100644 --- a/doc/out/PopupMenuPopupMenuPopupInteractivePopup.html +++ b/doc/out/PopupMenuPopupMenuPopupInteractivePopup.html @@ -1791,7 +1791,7 @@ like Popup, Message...

diff --git a/doc/out/PopupMenuPopupMenuPopupPopupInteractivePopup.html b/doc/out/PopupMenuPopupMenuPopupPopupInteractivePopup.html index 8f5a7cf..d7e1f90 100644 --- a/doc/out/PopupMenuPopupMenuPopupPopupInteractivePopup.html +++ b/doc/out/PopupMenuPopupMenuPopupPopupInteractivePopup.html @@ -1791,7 +1791,7 @@ like Popup, Message...

diff --git a/doc/out/PopupMenuPopupPopupInteractivePopup.html b/doc/out/PopupMenuPopupPopupInteractivePopup.html index d9f8e47..e52e03a 100644 --- a/doc/out/PopupMenuPopupPopupInteractivePopup.html +++ b/doc/out/PopupMenuPopupPopupInteractivePopup.html @@ -1791,7 +1791,7 @@ like Popup, Message...

diff --git a/doc/out/PopupPopupInteractivePopup.html b/doc/out/PopupPopupInteractivePopup.html index 074ae22..59c7c3b 100644 --- a/doc/out/PopupPopupInteractivePopup.html +++ b/doc/out/PopupPopupInteractivePopup.html @@ -1791,7 +1791,7 @@ like Popup, Message...

diff --git a/doc/out/Progress.html b/doc/out/Progress.html index ebaed92..4761562 100644 --- a/doc/out/Progress.html +++ b/doc/out/Progress.html @@ -2877,7 +2877,7 @@ app.scene.addChild(progress) diff --git a/doc/out/Scrollview.html b/doc/out/Scrollview.html index 30b9589..fa58a7a 100644 --- a/doc/out/Scrollview.html +++ b/doc/out/Scrollview.html @@ -1709,7 +1709,7 @@ app.loader diff --git a/doc/out/Slider.html b/doc/out/Slider.html index d9115e2..2bee9df 100644 --- a/doc/out/Slider.html +++ b/doc/out/Slider.html @@ -2968,7 +2968,7 @@ app.scene.addChild(slider) diff --git a/doc/out/Switch.html b/doc/out/Switch.html index bbdfc6e..cf4e7d6 100644 --- a/doc/out/Switch.html +++ b/doc/out/Switch.html @@ -3398,7 +3398,7 @@ app.scene.addChild(switch1) diff --git a/doc/out/TextLabel.TextLabel.html b/doc/out/TextLabel.TextLabel.html index a3c69d1..6b45046 100644 --- a/doc/out/TextLabel.TextLabel.html +++ b/doc/out/TextLabel.TextLabel.html @@ -1692,7 +1692,7 @@ diff --git a/doc/out/Theme.html b/doc/out/Theme.html index aa87533..cd8b856 100644 --- a/doc/out/Theme.html +++ b/doc/out/Theme.html @@ -3167,7 +3167,7 @@ const app = new PIXIApp({ diff --git a/doc/out/ThemeDark.html b/doc/out/ThemeDark.html index 3bc0ba5..79fdda2 100644 --- a/doc/out/ThemeDark.html +++ b/doc/out/ThemeDark.html @@ -1588,7 +1588,7 @@ const app = new PIXIApp({ diff --git a/doc/out/ThemeLight.html b/doc/out/ThemeLight.html index a28f73e..f6915cd 100644 --- a/doc/out/ThemeLight.html +++ b/doc/out/ThemeLight.html @@ -1600,7 +1600,7 @@ const app = new PIXIApp({ diff --git a/doc/out/ThemeRed.html b/doc/out/ThemeRed.html index 7973730..f824138 100644 --- a/doc/out/ThemeRed.html +++ b/doc/out/ThemeRed.html @@ -1600,7 +1600,7 @@ const app = new PIXIApp({ diff --git a/doc/out/TileQuadNode.html b/doc/out/TileQuadNode.html index f9a246e..b7b5110 100644 --- a/doc/out/TileQuadNode.html +++ b/doc/out/TileQuadNode.html @@ -2052,7 +2052,7 @@ an indicator of tiles to free.

diff --git a/doc/out/Tooltip.html b/doc/out/Tooltip.html index ee4a325..339ee94 100644 --- a/doc/out/Tooltip.html +++ b/doc/out/Tooltip.html @@ -2514,7 +2514,7 @@ a string, a number or a PIXI.Text object.

diff --git a/doc/out/UITest.html b/doc/out/UITest.html index f3cae66..5bac7f0 100644 --- a/doc/out/UITest.html +++ b/doc/out/UITest.html @@ -4185,7 +4185,7 @@ test.start() diff --git a/doc/out/Volatile.html b/doc/out/Volatile.html index 499b324..241bb19 100644 --- a/doc/out/Volatile.html +++ b/doc/out/Volatile.html @@ -2101,7 +2101,7 @@ app.scene.addChild(button) diff --git a/doc/out/global.html b/doc/out/global.html index cd78fc0..085c1ee 100644 --- a/doc/out/global.html +++ b/doc/out/global.html @@ -3322,7 +3322,7 @@ diff --git a/doc/out/index.html b/doc/out/index.html index c28271b..0cd30e1 100644 --- a/doc/out/index.html +++ b/doc/out/index.html @@ -1487,7 +1487,7 @@ diff --git a/doc/out/pixi_abstractpopup.js.html b/doc/out/pixi_abstractpopup.js.html index c058bc9..14768f3 100644 --- a/doc/out/pixi_abstractpopup.js.html +++ b/doc/out/pixi_abstractpopup.js.html @@ -1810,7 +1810,7 @@ export default class AbstractPopup extends PIXI.Graphics { diff --git a/doc/out/pixi_app.js.html b/doc/out/pixi_app.js.html index 1a4def3..b7dc801 100644 --- a/doc/out/pixi_app.js.html +++ b/doc/out/pixi_app.js.html @@ -2191,7 +2191,7 @@ class FpsDisplay extends PIXI.Graphics { diff --git a/doc/out/pixi_badge.js.html b/doc/out/pixi_badge.js.html index f26bae8..f4333e6 100644 --- a/doc/out/pixi_badge.js.html +++ b/doc/out/pixi_badge.js.html @@ -1571,7 +1571,7 @@ export default class Badge extends AbstractPopup { diff --git a/doc/out/pixi_blurfilter.js.html b/doc/out/pixi_blurfilter.js.html index 4662a3a..d67139b 100644 --- a/doc/out/pixi_blurfilter.js.html +++ b/doc/out/pixi_blurfilter.js.html @@ -1729,7 +1729,7 @@ class TiltShiftYFilter extends TiltShiftAxisFilter { diff --git a/doc/out/pixi_button.js.html b/doc/out/pixi_button.js.html index 774da58..bc9063d 100644 --- a/doc/out/pixi_button.js.html +++ b/doc/out/pixi_button.js.html @@ -2153,7 +2153,7 @@ export default class Button extends PIXI.Container { diff --git a/doc/out/pixi_buttongroup.js.html b/doc/out/pixi_buttongroup.js.html index ddd859d..945ebeb 100644 --- a/doc/out/pixi_buttongroup.js.html +++ b/doc/out/pixi_buttongroup.js.html @@ -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 { diff --git a/doc/out/pixi_deepzoom_image.js.html b/doc/out/pixi_deepzoom_image.js.html index cf42d7f..2e05ac2 100644 --- a/doc/out/pixi_deepzoom_image.js.html +++ b/doc/out/pixi_deepzoom_image.js.html @@ -2553,7 +2553,7 @@ export class DeepZoomImage extends PIXI.Container { diff --git a/doc/out/pixi_flippable.js.html b/doc/out/pixi_flippable.js.html index 2c0699d..8e00349 100644 --- a/doc/out/pixi_flippable.js.html +++ b/doc/out/pixi_flippable.js.html @@ -1908,7 +1908,7 @@ export default class Flippable extends PIXI.projection.Camera3d { diff --git a/doc/out/pixi_labeledgraphics.js.html b/doc/out/pixi_labeledgraphics.js.html index d8055ad..7a30599 100644 --- a/doc/out/pixi_labeledgraphics.js.html +++ b/doc/out/pixi_labeledgraphics.js.html @@ -1857,7 +1857,7 @@ export class BitmapLabeledGraphics extends LabeledGraphics { diff --git a/doc/out/pixi_list.js.html b/doc/out/pixi_list.js.html index cb1e124..e73637b 100644 --- a/doc/out/pixi_list.js.html +++ b/doc/out/pixi_list.js.html @@ -1836,7 +1836,7 @@ export default class List extends PIXI.Container { diff --git a/doc/out/pixi_message.js.html b/doc/out/pixi_message.js.html index b047784..38287a9 100644 --- a/doc/out/pixi_message.js.html +++ b/doc/out/pixi_message.js.html @@ -1585,7 +1585,7 @@ export default class Message extends InteractivePopup { diff --git a/doc/out/pixi_modal.js.html b/doc/out/pixi_modal.js.html index a9ef14d..0cd78fd 100644 --- a/doc/out/pixi_modal.js.html +++ b/doc/out/pixi_modal.js.html @@ -1666,7 +1666,7 @@ export default class Modal extends PIXI.Container { diff --git a/doc/out/pixi_popup.js.html b/doc/out/pixi_popup.js.html index f22c6ca..a87b858 100644 --- a/doc/out/pixi_popup.js.html +++ b/doc/out/pixi_popup.js.html @@ -1676,7 +1676,7 @@ export default class Popup extends InteractivePopup { diff --git a/doc/out/pixi_popupmenu.js.html b/doc/out/pixi_popupmenu.js.html index 739f6be..386d3a7 100644 --- a/doc/out/pixi_popupmenu.js.html +++ b/doc/out/pixi_popupmenu.js.html @@ -1579,7 +1579,7 @@ export default class PopupMenu extends Popup { diff --git a/doc/out/pixi_progress.js.html b/doc/out/pixi_progress.js.html index a7b94df..31697e6 100644 --- a/doc/out/pixi_progress.js.html +++ b/doc/out/pixi_progress.js.html @@ -1761,7 +1761,7 @@ export default class Progress extends PIXI.Container { diff --git a/doc/out/pixi_scrollview.js.html b/doc/out/pixi_scrollview.js.html index 508015f..f76ebfc 100644 --- a/doc/out/pixi_scrollview.js.html +++ b/doc/out/pixi_scrollview.js.html @@ -1520,7 +1520,7 @@ export default class Scrollview extends Scrollbox { diff --git a/doc/out/pixi_slider.js.html b/doc/out/pixi_slider.js.html index 8d518b1..ef438c3 100644 --- a/doc/out/pixi_slider.js.html +++ b/doc/out/pixi_slider.js.html @@ -1925,7 +1925,7 @@ export default class Slider extends PIXI.Container { diff --git a/doc/out/pixi_switch.js.html b/doc/out/pixi_switch.js.html index 36e298a..9bcbfbc 100644 --- a/doc/out/pixi_switch.js.html +++ b/doc/out/pixi_switch.js.html @@ -1979,7 +1979,7 @@ export default class Switch extends PIXI.Container { diff --git a/doc/out/pixi_theme.js.html b/doc/out/pixi_theme.js.html index d21be7c..446c2ee 100644 --- a/doc/out/pixi_theme.js.html +++ b/doc/out/pixi_theme.js.html @@ -1720,7 +1720,7 @@ export class ThemeRed extends Theme { diff --git a/doc/out/pixi_tooltip.js.html b/doc/out/pixi_tooltip.js.html index 3017945..e31ed30 100644 --- a/doc/out/pixi_tooltip.js.html +++ b/doc/out/pixi_tooltip.js.html @@ -1613,7 +1613,7 @@ export default class Tooltip extends AbstractPopup { diff --git a/doc/out/pixi_volatile.js.html b/doc/out/pixi_volatile.js.html index 76b6af3..879319a 100644 --- a/doc/out/pixi_volatile.js.html +++ b/doc/out/pixi_volatile.js.html @@ -1617,7 +1617,7 @@ export default class Volatile { diff --git a/doc/out/uitest.js.html b/doc/out/uitest.js.html index 78efbc8..e585274 100644 --- a/doc/out/uitest.js.html +++ b/doc/out/uitest.js.html @@ -2468,7 +2468,7 @@ class Event { diff --git a/lib/pixi/buttongroup.html b/lib/pixi/buttongroup.html index 233061b..3c5a786 100644 --- a/lib/pixi/buttongroup.html +++ b/lib/pixi/buttongroup.html @@ -303,12 +303,33 @@ const buttonGroup17 = new ButtonGroup({ app }) +const buttonGroup18 = new ButtonGroup({ + x: 10, + y: 1340, + buttons: [ + {label: 'move'}, + {label: 'explanation dried'}, + {label: 'out catch'}, + {label: 'late either'}, + {label: 'tell pour'}, + {label: 'willing apart airplane'}, + {label: 'high war'}, + {label: 'future struck'}, + {label: 'sense image'}, + {label: 'never'}, + {label: 'mark cloth'}, + {label: 'everywhere due large'} + ], + maxWidth: 500, + app +}) + app.scene.addChild(buttonGroup1, buttonGroup2, buttonGroup3) app.scene.addChild(buttonGroup4) app.scene.addChild(buttonGroup5, buttonGroup6) app.scene.addChild(buttonGroup7, buttonGroup8) app.scene.addChild(buttonGroup9, buttonGroup10, buttonGroup11, buttonGroup12, buttonGroup13) -app.scene.addChild(buttonGroup14, buttonGroup15, buttonGroup16, buttonGroup17) +app.scene.addChild(buttonGroup14, buttonGroup15, buttonGroup16, buttonGroup17, buttonGroup18) diff --git a/lib/pixi/buttongroup.js b/lib/pixi/buttongroup.js index e5a8824..1c0f728 100644 --- a/lib/pixi/buttongroup.js +++ b/lib/pixi/buttongroup.js @@ -581,15 +581,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)) } @@ -629,15 +638,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)) }