Skip to main content

Interface: ScrollIntoViewLocationOptions

Extended by

Properties

align?

optional align: "center" | "end" | "start"


behavior?

optional behavior: "auto" | "smooth"


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
}

done()?

optional done: () => void

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

Returns

void