UNPKG

vuestic-ui

Version:
27 lines (26 loc) 763 B
import { reactive, computed, watch } from "vue"; import { b as isClient } from "../utils/ssr.mjs"; import { u as useEvent } from "./useEvent.mjs"; function useWindowSize() { const windowSizes = reactive({ width: void 0, height: void 0 }); const setCurrentWindowSizes = () => { windowSizes.width = window == null ? void 0 : window.innerWidth; windowSizes.height = window == null ? void 0 : window.innerHeight; }; const isMounted = computed(isClient); watch(isMounted, (newValue) => { if (!newValue) { return; } setCurrentWindowSizes(); }, { immediate: true }); useEvent("resize", setCurrentWindowSizes, true); return { windowSizes }; } export { useWindowSize as u }; //# sourceMappingURL=useWindowSize.mjs.map