Skip to main content

Interface: FlatScrollIntoViewLocation

Hierarchy

Properties

index

index: number


align

Optional align: "center" | "end" | "start"

Inherited from

ScrollIntoViewLocationOptions.align


behavior

Optional behavior: "auto" | "smooth"

Inherited from

ScrollIntoViewLocationOptions.behavior


done

Optional done: () => void

Will be called when the scroll is done, or immediately if no scroll is needed.

Type declaration

▸ (): void

Returns

void

Inherited from

ScrollIntoViewLocationOptions.done


calculateViewLocation

Optional calculateViewLocation: CalculateViewLocation

Use this function to fine-tune the scrollIntoView behavior. The function receives the item's top and bottom position in the viewport, and the viewport top/bottom. Return an location object to scroll, or null to prevent scrolling. Here's the default implementation:

const defaultCalculateViewLocation: CalculateViewLocation = ({
itemTop,
itemBottom,
viewportTop,
viewportBottom,
locationParams: { behavior, align, ...rest },
}) => {
if (itemTop < viewportTop) {
return { ...rest, behavior, align: align ?? 'start' }
}
if (itemBottom > viewportBottom) {
return { ...rest, behavior, align: align ?? 'end' }
}
return null
}

Inherited from

ScrollIntoViewLocationOptions.calculateViewLocation