How to add extra space in a ScrollContainer?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Felipe

I have a ScrollContainer with nodes in it. It scrolls fine, but when I reach the bottom of ScrollContainer, the scrolling stops. I would like it scroll up a bit longer, leaving a blank space at the bottom (like a margin).
I know how to do this using empty TextureRects or Labels, but I this it is a workaround. I think that add elements that will not be used is not a good solution.
Any ideas of how to add this space?

:bust_in_silhouette: Reply From: exuin

Add a MarginContainer inside the ScrollContainer, then put whatever was inside the ScrollContainer inside the MarginContainer. Under the MarginContainer’s “Custom Constants” properties, set “Margin Bottom” to whatever value you desire.

Sadly it have to be one more node to to this, but as that is the function of the MarginContainer, i think it is the best option. Solved my problem. Thant you.

Felipe | 2021-01-14 17:20

:bust_in_silhouette: Reply From: exuin

Found another solution when adding a theme today. It’s a bit convoluted but doesn’t require any extra nodes.

  1. Make a new theme for the ScrollContainer.
  2. Add a new ScrollContainer->Styles->Bg item to the theme.
  3. Add a new StyleBoxEmpty (or a different StyleBox if you want the ScrollContainer to have a background) to the previous item.
  4. Go to Content Margin and set “Bottom” to a positive value.
1 Like