Skip to content

Latest commit

 

History

History
executable file
·
46 lines (35 loc) · 864 Bytes

useScrollbarWidth.md

File metadata and controls

executable file
·
46 lines (35 loc) · 864 Bytes

useScrollbarWidth

Vue function that gets current browser's scrollbar width.

Reference

function useScrollbarWidth(
  runOnMount?: boolean
): {
  scrollbarWidth: Ref<number>
  getScrollbarWidth: () => void
}

Parameters

  • runOnMount: boolean whether to get scrollbar width on mount, true by default

Returns

  • scrollbarWidth: Ref<number> the scrollbar width
  • getScrollbarWidth: Function the function to call to get the scrollbar width

Usage

<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>