MCPcopy Create free account
hub / github.com/dailydotdev/apps / useScrollbarWidth

Function useScrollbarWidth

packages/shared/src/hooks/useScrollbarWidth.ts:8–22  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6 * modals hide body overflow and the scrollbar disappears.
7 */
8export function useScrollbarWidth(): void {
9 useEffect(() => {
10 const update = () => {
11 const width = window.innerWidth - document.documentElement.clientWidth;
12 document.documentElement.style.setProperty(
13 '--scrollbar-width',
14 `${width}px`,
15 );
16 };
17
18 update();
19 window.addEventListener('resize', update);
20 return () => window.removeEventListener('resize', update);
21 }, []);
22}

Callers 2

AppFunction · 0.90
InternalAppFunction · 0.90

Calls 1

updateFunction · 0.70

Tested by

no test coverage detected