1
0
Fork 0

refactor(react): refactor full height logic

This commit is contained in:
François Chalifour 2020-11-24 11:42:21 +01:00
parent 0fadc8b7dd
commit 371c788ab7

View file

@ -336,16 +336,20 @@ export function DocSearchModal({
// because all mobile browsers don't compute their height the same way.
// See https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
React.useEffect(() => {
const setFullViewportHeight = () => {
function setFullViewportHeight() {
if (modalRef.current) {
const vh = window.innerHeight * 0.01;
modalRef.current.style.setProperty('--docsearch-vh', `${vh}px`);
}
};
}
setFullViewportHeight();
window.addEventListener('resize', setFullViewportHeight);
return () => window.removeEventListener('resize', setFullViewportHeight);
return () => {
window.removeEventListener('resize', setFullViewportHeight);
};
}, []);
return (