phaser3-rex-notes icon indicating copy to clipboard operation
phaser3-rex-notes copied to clipboard

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

Open dtturcotte opened this issue 2 years ago • 3 comments

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?

dtturcotte avatar Aug 27 '23 22:08 dtturcotte

  • Set child game object to invisible : parentSizer.setChildVisible(child, visible) ref. Parent does not know (does not check child's properties) if child is set to invisible.
  • Hide child and don't layout this child : scene.rexUI.hide(child) ref. Invisible child will be layout with other children if not hide

rexrainbow avatar Aug 28 '23 04:08 rexrainbow

@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.

dtturcotte avatar Oct 27 '23 20:10 dtturcotte

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

rexrainbow avatar Oct 28 '23 02:10 rexrainbow