Here is a little wrapper that I made for ScrollingFrame
class, to make the UI element automatically adjust (vertically) to the content inside of the ScrollingFrame
. It does a couple other nifty things, such as:
- Implements an expansion policy for maximum size (By an offset, or by number of items, or no expansion policy!).
- Supports implementing an order policy, so you can adjust the SortOrder without having to actually find the
UIListLayout
object. - Supports sorting, and will adjust size when internal elements shift in size.
- Allows an offset on the bottom of the canvas, in case you want some extra room.
- Allows for a tween on the expansion of the canvas, so when something changes, it tweens to match the change. You can turn that on and off. Sets tweens properties as well.
- Padding changes to the UIListLayout, etc, is all supported as well.
- Implements
BindableEvents
for SizeChange and CanvasSizeChange - Updates the canvas size and the size of the UI itself whenever a child is added, so you can continue to use the
ScrollingFrame
as you were before. - If you give a child object an attribute called “NewSize”, and set a value to it, it will override the
AbsoluteSize
of the object in Y size calculation. So, if you want to have a child object tween, but not trigger more calculations, set that.
I found this useful for making some UI, and it for sure isn’t perfect, but it is a start. Take it, use it, improve it. If you do improve it, please post changes, so other people can use it and have a useful library to deal with their ScrollingFrames. Hope you all like it!
Github: GitHub - princeeriktheblue/smartscroller: SmartScroller, a wrapper for the ScrollingFrame class
SmartScroller.lua (9.7 KB)