Skip to content

Scroll Location

AutoscrollToBottom<Data, Context> = ItemLocationCallback<Data, Context> | NonNullable<ScrollToOptions["behavior"]> | boolean

Specifies whether append-like data changes or rendered-item size changes should scroll to the bottom.

Passing false or undefined preserves the current viewport. Passing true is equivalent to 'auto'. Passing a ScrollBehavior directly applies only when the list is already at the bottom.

Use the callback form when the policy needs access to scrollLocation, atBottom, scrollInProgress, context, or the operation data. In callback form, return false to preserve position, a ScrollBehavior to scroll the last item into view, or an ItemLocation for custom alignment.

Type ParameterDefault typeDescription
DataunknownThe type of the data items in the list.
ContextunknownThe type of the context passed to the list.

ItemLocation = number | ItemLocationWithAlign

A location in the list to scroll to. Passing a number scrolls instantly to the item at the specified index aligned to the top. See ItemLocationWithAlign for more advanced options.


ItemLocationCallback<Data, Context> = (params) => ScrollBehavior | boolean | ItemLocation

A callback function that determines whether a data or rendered-item size change should scroll.

Return false to preserve the current viewport. Return true or a ScrollBehavior to scroll to the bottom. Return an ItemLocation to scroll to a specific item.

The callback receives the scroll location from before the change is applied. In callback form, returning a ScrollBehavior or ItemLocation scrolls even when atBottom is false; return false when a scrolled-up user should stay where they are.

Type ParameterDefault typeDescription
DataunknownThe type of the data items in the list.
ContextunknownThe type of the context passed to the list.
ParameterType
paramsItemLocationCallbackParams<Data, Context>

ScrollBehavior | boolean | ItemLocation


The parameters passed to the ItemLocationCallback function.

Type ParameterDefault typeDescription
DataunknownThe type of the data items in the list.
ContextunknownThe type of the context passed to the list.

boolean

Whether the list is at the bottom before the data change.


Context

The context passed to the list.


Data[]

The data supplied by the operation that triggered the policy. For append and insert operations, this is the added data. For declarative data updates, this is the next data array. For notifyItemsChanged, this is the current list data.


boolean

Indicates whether the list is currently scrolling. If you receive fast updates and use 'smooth' scrolling, there’s a chance that the list will be in the middle of a scroll when new data arrives.


ListScrollLocation

The location of the list before the data or rendered-item size change. See ListScrollLocation for the details of the parameter received.


Specifies a location in the list to scroll to.

align?: "start" | "center" | "end" | "start-no-overflow"

Section titled “align?: "start" | "center" | "end" | "start-no-overflow"”

How to align the item in the viewport.


Set 'smooth' to have an animated transition to the specified location.


optional done: () => void

A callback that’s invoked when the scroll is complete.

void


number | "LAST"

The index of the item to scroll to. Use 'LAST' to scroll to the last item.


Use the offset for additional adjustment of the position - can be a positive or negative number.


Options for notifying the list that rendered item content may have changed size without changing the data array.

Type ParameterDefault type
Dataunknown
Contextunknown

AutoscrollToBottom<Data, Context>

Specifies whether the list should scroll to the bottom if rendered items grow.

Use the callback form to inspect the pre-change scrollLocation, atBottom, scrollInProgress, context, and current data. Return false to keep a scrolled-up user at the same location.


ScrollModifier = null | undefined | { location: ItemLocation; purgeItemSizes?: boolean; type: "item-location"; } | { autoScroll: AutoscrollToBottom; type: "auto-scroll-to-bottom"; } | { behavior: ScrollBehavior | { location: () => ItemLocation | null | undefined; }; type: "items-change"; } | ScrollModifierOptionValue

Describes the scroll modification to perform when the data of the list is updated. See the scroll modifier documentation section for examples of how to use this type.


const ScrollModifierOption: object

Predefined scroll modifier options for common data operations.

"prepend"

"remove-from-end"

"remove-from-start"


ScrollModifierOptionType = typeof ScrollModifierOption

The type of the ScrollModifierOption constant.


ScrollModifierOptionValue = ScrollModifierOptionType[keyof ScrollModifierOptionType]

The possible values of the ScrollModifierOption constant.


scrollToBottomAlways<Data, Context>(__namedParameters): ItemLocation

Always scrolls the last item into view.

The helper uses a smooth scroll while the list is already at the bottom or scrolling to the bottom, and an instant scroll otherwise. Use this for local actions, such as sending the current user’s message, where the new item should become visible even if the user was scrolled up.

Type ParameterDefault type
Dataunknown
Contextunknown
ParameterType
__namedParametersItemLocationCallbackParams<Data, Context>

ItemLocation


scrollToBottomIfAtBottom<Data, Context>(__namedParameters): false | ScrollBehavior

Scrolls to the bottom only if the list was already at the bottom or is already scrolling to the bottom.

Use this for incoming messages or row growth where a scrolled-up user should stay at their current location.

Type ParameterDefault type
Dataunknown
Contextunknown
ParameterType
__namedParametersItemLocationCallbackParams<Data, Context>

false | ScrollBehavior


ShortSizeAlign = "top" | "bottom" | "bottom-smooth"

Specifies the alignment of the items when the content of the list is smaller than the viewport height.

  • 'top' (default), the items will be aligned to the top
  • 'bottom', the items will be aligned to the bottom.
  • 'bottom-smooth', the items will be aligned to the bottom and the scroll will be animated.