source: imaps-frontend/node_modules/react-use/esm/useScrollbarWidth.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 605 bytes
Line 
1import { scrollbarWidth } from '@xobotyi/scrollbar-width';
2import { useEffect, useState } from 'react';
3export function useScrollbarWidth() {
4 var _a = useState(scrollbarWidth()), sbw = _a[0], setSbw = _a[1];
5 // this needed to ensure the scrollbar width in case hook called before the DOM is ready
6 useEffect(function () {
7 if (typeof sbw !== 'undefined') {
8 return;
9 }
10 var raf = requestAnimationFrame(function () {
11 setSbw(scrollbarWidth());
12 });
13 return function () { return cancelAnimationFrame(raf); };
14 }, []);
15 return sbw;
16}
Note: See TracBrowser for help on using the repository browser.