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:
itemCountintegerThe number of list item Client Controls to instantiate.
callbackfun(control: ClientControlType, index: integer) -> nilThe function invoked for each instantiated item, where
controlis the instantiated Client Control andindexis 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.
controlClientControlTypeThe Client Control to get the index of.
indexintegerThe 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.
widthnumberThe width of list items.
heightnumberThe height of list items.
function ClientUIGridScrollerControl:GetItemSpacing() -> (horizontalSpacing number, verticalSpacing number)
Returns the horizontal and vertical list item spacing.
horizontalSpacingnumberThe horizontal spacing between list items.
verticalSpacingnumberThe vertical spacing between list items.
function ClientUIGridScrollerControl:GetPadding() -> (top number, bottom number, left number, right number)
Returns the content area padding.
topnumberThe padding from the top of the content area.
bottomnumberThe padding from the bottom of the content area.
leftnumberThe padding from the left of the content area.
rightnumberThe 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:
- Enum.ScrollAlignType for all scroll alignment types.
indexintegerThe index of the list item to scroll to. Automatically clamped within the valid range of indices.
scrollAlignTypeEnumItem.ScrollAlignTypeThe 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.
contentLengthnumberThe 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.