SmartScroller, class wrapper for ScrollingFrame

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:

  1. Implements an expansion policy for maximum size (By an offset, or by number of items, or no expansion policy!).
  2. Supports implementing an order policy, so you can adjust the SortOrder without having to actually find the UIListLayout object.
  3. Supports sorting, and will adjust size when internal elements shift in size.
  4. Allows an offset on the bottom of the canvas, in case you want some extra room.
  5. 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.
  6. Padding changes to the UIListLayout, etc, is all supported as well.
  7. Implements BindableEvents for SizeChange and CanvasSizeChange
  8. 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.
  9. 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)

8 Likes

Before I look into the module itself, I would suggest setting up a GitHub repository so you can seamlessly append the projects source with pull requests, feature requests, etc.

1 Like

Good idea, haven’t done much code sharing before, so thank you for the suggestion.

1 Like