import { ref , onMounted , Ref } from '@src/api' ; export function useScrollbarWidth ( runOnMount = true ) { const scrollbarWidth = ref ( 0 ) ; const getScrollbarWidth = ( ) => { const outer = document . createElement ( 'div' ) ; outer . style . visibility = 'hidden' ; outer . style . overflow = 'scroll' ; outer . style . msOverflowStyle = 'scrollbar' ; document . body . appendChild ( outer ) ; const inner = document . createElement ( 'div' ) ; outer . appendChild ( inner ) ; const scrollbarWidthValue = outer . offsetWidth - inner . offsetWidth ; if ( outer . parentNode ) outer . parentNode . removeChild ( outer ) ; scrollbarWidth . value = scrollbarWidthValue ; } ; onMounted ( ( ) => runOnMount && getScrollbarWidth ( ) ) ; return { scrollbarWidth , getScrollbarWidth } ; }