import { isFunction , MaybeRef , unRef } from '@react-hooks-library/shared' ; import { useMount } from '../useMount' ; export interface UseScrollIntoViewOptions extends ScrollIntoViewOptions { default block ? : ScrollLogicalPosition ; default inline ? : ScrollLogicalPosition ; default behavior ? : ScrollBehavior ; default scrollMargin ? : string ; default predicate ? : boolean | ( ( ) => boolean ) ; } param options { UseScrollIntoViewOptions } see https export function useScrollIntoView ( target , options = { } ) { const { behavior = 'auto' , block = 'start' , inline = 'nearest' , scrollMargin = '0px' , predicate = true } = options ; useMount ( ( ) => { const el = unRef ( target ) ; if ( ! ( el && ( isFunction ( predicate ) ? predicate ( ) : predicate ) ) ) { return ; } el . style . scrollMargin = scrollMargin ; el . scrollIntoView ( { behavior , block , inline } ) ; } ) ; }