10 lines
306 B
TypeScript
10 lines
306 B
TypeScript
export function scrollSelectedHTMLChildIntoView(
|
|
container: HTMLElement | null,
|
|
selectedIndex: number,
|
|
): void {
|
|
const selectedHTMLElement = container?.children.item(selectedIndex)
|
|
if (selectedHTMLElement instanceof HTMLElement) {
|
|
selectedHTMLElement.scrollIntoView({ block: 'nearest' })
|
|
}
|
|
}
|