Miliastra Wonderland Lua API

ClientUIGridScrollerControl

The type that represents an instance of a Grid Scroller Control component. Contains functions for updating the grid and querying grid properties.

The Grid Scroller Control component maintains an internal list of managed Client Controls, which cannot be accessed or modified.

Methods7

function ClientUIGridScrollerControl:RefreshItems(itemCount: integer, callback: fun(control: ClientControlType, index: integer) -> nil)

Destroys all existing list item Client Controls, then instantiates the specified number of Client Controls as list items and invokes a callback for each item.

  • The corresponding lifecycle functions will be called for all affected Client Controls.

See:

Parameters
itemCountinteger

The number of list item Client Controls to instantiate.

callbackfun(control: ClientControlType, index: integer) -> nil

The function invoked for each instantiated item, where control is the instantiated Client Control and index is its 0-indexed position in the Grid Scroller's internal list.

function ClientUIGridScrollerControl:GetItemIndex(control: ClientControlType) -> index integer

Gets the 0-indexed position of the specified Client Control in the Grid Scroller's internal list.

  • Returns -1 if the specified Client Control is not in the Grid Scroller's internal list.
Parameters
controlClientControlType

The Client Control to get the index of.

Returns
indexinteger

The 0-indexed position of the specified Client Control in the Grid Scroller's internal list.

function ClientUIGridScrollerControl:GetItemSize() -> (width number, height number)

Returns the list item dimensions.

Returns
widthnumber

The width of list items.

heightnumber

The height of list items.

function ClientUIGridScrollerControl:GetItemSpacing() -> (horizontalSpacing number, verticalSpacing number)

Returns the horizontal and vertical list item spacing.

Returns
horizontalSpacingnumber

The horizontal spacing between list items.

verticalSpacingnumber

The vertical spacing between list items.

function ClientUIGridScrollerControl:GetPadding() -> (top number, bottom number, left number, right number)

Returns the content area padding.

Returns
topnumber

The padding from the top of the content area.

bottomnumber

The padding from the bottom of the content area.

leftnumber

The padding from the left of the content area.

rightnumber

The padding from the right of the content area.

function ClientUIGridScrollerControl:ScrollToItemAt(index: integer, scrollAlignType: EnumItem.ScrollAlignType)

Instantly scrolls to the list item at the specified index.

See:

Parameters
indexinteger

The index of the list item to scroll to. Automatically clamped within the valid range of indices.

scrollAlignTypeEnumItem.ScrollAlignType

The alignment type to determine where the specified list item should be when the scroll completes.

function ClientUIGridScrollerControl:GetContentLength() -> contentLength number

Returns the length of content along the scroll direction.

Calculated using the following:

BaseLength = Direction Start Padding + Direction End Padding - Direction List Item Spacing
ContentLength = BaseLength + (Direction Item Size + Direction List Item Spacing) * itemCount

For example, when the scroll direction is vertical, the top and bottom padding, vertical list item spacing, and list item height are used.

Returns
contentLengthnumber

The length of content along the scroll direction.

Fields9

ClientUIGridScrollerControl.itemCount : integer

[Read] The number of list items that were created in the most recent refresh.

ClientUIGridScrollerControl.itemPrefabIndex : integer

[Read/Write] The Client Control Template index used to create list items when RefreshItems is called.

ClientUIGridScrollerControl.raycastTarget : boolean

[Read/Write] Whether the Grid Scroller can be scrolled by dragging on empty space within its bounding box.

ClientUIGridScrollerControl.showScrollBar : boolean

[Read/Write] Whether to show the scrollbar.

ClientUIGridScrollerControl.interactable : boolean

[Read/Write] Whether the Grid Scroller can be scrolled by client input.

ClientUIGridScrollerControl.scrollDirection : EnumItem.ScrollDirection

[Read] The scroll direction.

ClientUIGridScrollerControl.layoutConstraint : EnumItem.ScrollLayoutConstraint

[Read] The list item layout constraint.

ClientUIGridScrollerControl.layoutConstraintFixedCount : number

[Read] The maximum list item count along the scroll direction. Always 0 when the layout constraint is set to Auto Wrap.

ClientUIGridScrollerControl.scrollProgress : NormalizedPercentage

[Read/Write/Tweenable] The normalized percentage representing the scroll position originating from the bottom-left corner. Values outside the range 0.0-1.0 may be returned during overscroll.