Reorganise code - use src folder

This commit is contained in:
Timothy Armes
2023-10-11 14:05:27 +02:00
committed by Owen Rees
parent 2dc5f477c9
commit b5061b1c78
89 changed files with 70 additions and 69 deletions
+49
View File
@@ -0,0 +1,49 @@
export const useDynamicViewportUnits = () => {
const setVh = function () {
var svh = document.documentElement.clientHeight * 0.01;
document.documentElement.style.setProperty("--1svh", svh + "px");
var dvh = window.innerHeight * 0.01;
document.documentElement.style.setProperty("--1dvh", dvh + "px");
};
const isMobile = function () {
if (
/Android|iPhone|iPad|iPod/i.test(navigator.userAgent) ||
(navigator.userAgent.match(/Mac/) &&
navigator.maxTouchPoints &&
navigator.maxTouchPoints > 2)
) {
return true;
}
return false;
};
// SSR support
if (typeof window === "undefined") {
return;
}
// Don't run polyfill if browser supports the units natively
if (
"CSS" in window &&
"supports" in window.CSS &&
window.CSS.supports("height: 100svh") &&
window.CSS.supports("height: 100dvh") &&
window.CSS.supports("height: 100lvh")
) {
return;
}
// Don't run on desktop browsers
if (!isMobile) {
return;
}
window.addEventListener("resize", setVh);
setVh();
return () => {
window.removeEventListener("resize", setVh);
};
};