Function
scrollElementIntoView
(element: HTMLElement, options?: ScrollIntoViewOptions)
Source from the content-addressed store, hash-verified
| 7 | }; |
| 8 | |
| 9 | export const scrollElementIntoView = (element: HTMLElement, options?: ScrollIntoViewOptions) => { |
| 10 | if (element) { |
| 11 | // @ts-expect-error -- scrollIntoViewIfNeeded is not a standard method |
| 12 | element.scrollIntoViewIfNeeded ? element.scrollIntoViewIfNeeded() : element.scrollIntoView(options); |
| 13 | } |
| 14 | }; |
| 15 | |
| 16 | // modify base on react-spectrum |
| 17 | // https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/data/src/useListData.ts#L279 |
Tested by
no test coverage detected