export const scrollIntoViewIfNeeded = ( target ) => { const isOptsSupported = 'scrollBehavior' in document . documentElement . style ; if ( target . getBoundingClientRect ( ) . bottom > window . innerHeight ) { target . scrollIntoView ( isOptsSupported ? { block : 'end' , inline : 'nearest' , behavior : 'smooth' } : false ) ; } if ( target . getBoundingClientRect ( ) . top < 0 ) { target . scrollIntoView ( isOptsSupported ? { block : 'start' , inline : 'nearest' , behavior : 'smooth' } : true ) ; } } ;