rexrainbow / phaser3-rex-notes

Notes of phaser3 engine
MIT License
1.21k stars 263 forks source link

"hidden" objects added to scrollable panel (both fixWidthSizer and Sizer) reappear on scroll #380

Closed dtturcotte closed 6 months ago

dtturcotte commented 1 year ago

I've added several rexUI bbcode text elements to a scrollable panel.

I hide one of the text elements using bbcodeText.setVisible(false). The text element within the scrollablePanel immediately hides in as expected.

When I scroll, the bbcodeText element reappears.

I've tried finding the element using on('scroll' then sifting through the panel's children, but cannot locate the text elements.

How can I prevent this unwanted behavior from happening?

rexrainbow commented 1 year ago
dtturcotte commented 11 months ago

@rexrainbow Hi, I've finally gotten back to this. If I use parentSizer.setChildVisible(child, false), or a workaround such as child.setAlpha(0), it hides, and keeps the child hidden even on scroll, but the children still take up space in the layout, even if I call "scrollablePanel.layout()` again.

Not hidden:

Screen Shot 2023-10-27 at 4 30 33 PM

Hidden:

Screen Shot 2023-10-27 at 4 29 27 PM

But the elements should collapse to what's visible. It seems that my only option is to destroy the elements and re-add them to the scrollablePanel when a user selects different categories that should show/hide options.

rexrainbow commented 11 months ago

Please see my previous post.

Hide child and don't layout this child : scene.rexUI.hide(child) ref. Invisible child will be layout with other children if not hide