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";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | exports.useScrollbarWidth = void 0;
|
---|
4 | var scrollbar_width_1 = require("@xobotyi/scrollbar-width");
|
---|
5 | var react_1 = require("react");
|
---|
6 | function 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 | }
|
---|
20 | exports.useScrollbarWidth = useScrollbarWidth;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.