mirror of
https://github.com/zadam/trilium.git
synced 2025-10-29 09:16:45 +01:00
chore(react/ribbon): react note map to height changes
This commit is contained in:
@@ -470,4 +470,25 @@ export function useResizeObserver(ref: RefObject<HTMLElement>, callback: ResizeO
|
||||
resizeObserver.disconnect();
|
||||
}
|
||||
}, [ ref, callback ]);
|
||||
}
|
||||
|
||||
export function useWindowSize() {
|
||||
const [ size, setSize ] = useState<{ windowWidth: number, windowHeight: number }>({
|
||||
windowWidth: window.innerWidth,
|
||||
windowHeight: window.innerHeight
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
function onResize() {
|
||||
setSize({
|
||||
windowWidth: window.innerWidth,
|
||||
windowHeight: window.innerHeight
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener("resize", onResize);
|
||||
return () => window.removeEventListener("resize", onResize);
|
||||
});
|
||||
|
||||
return size;
|
||||
}
|
||||
Reference in New Issue
Block a user