Vue function that gets current browser's scrollbar width.
function useScrollbarWidth(
runOnMount?: boolean
): {
scrollbarWidth: Ref<number>
getScrollbarWidth: () => void
}
runOnMount: boolean
whether to get scrollbar width on mount,true
by default
scrollbarWidth: Ref<number>
the scrollbar widthgetScrollbarWidth: Function
the function to call to get the scrollbar width
<template>
<div>
scrollbarWidth: {{ scrollbarWidth }}px
</div>
</template>
<script lang="ts">
import Vue from 'vue'
import { useScrollbarWidth } from 'vue-use-kit'
export default Vue.extend({
name: 'UseScrollbarWidthDemo',
setup() {
const { scrollbarWidth } = useScrollbarWidth()
return { scrollbarWidth }
}
})
</script>