source: imaps-frontend/node_modules/react-use/lib/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: 799 bytes
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.useScrollbarWidth = void 0;
4var scrollbar_width_1 = require("@xobotyi/scrollbar-width");
5var react_1 = require("react");
6function useScrollbarWidth() {
7 var _a = react_1.useState(scrollbar_width_1.scrollbarWidth()), sbw = _a[0], setSbw = _a[1];
8 // this needed to ensure the scrollbar width in case hook called before the DOM is ready
9 react_1.useEffect(function () {
10 if (typeof sbw !== 'undefined') {
11 return;
12 }
13 var raf = requestAnimationFrame(function () {
14 setSbw(scrollbar_width_1.scrollbarWidth());
15 });
16 return function () { return cancelAnimationFrame(raf); };
17 }, []);
18 return sbw;
19}
20exports.useScrollbarWidth = useScrollbarWidth;
Note: See TracBrowser for help on using the repository browser.