Interface: ScrollIntoViewLocationOptions
Hierarchy
-
ScrollIntoViewLocationOptions
Properties
align
• Optional
align: "center"
| "end"
| "start"
behavior
• Optional
behavior: "auto"
| "smooth"
done
• Optional
done: () => void
Will be called when the scroll is done, or immediately if no scroll is needed.
Type declaration
▸ (): void
Returns
void
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
}