@nextcloud/vue
Version:
Nextcloud vue components
26 lines (25 loc) • 869 B
JavaScript
import { ref, readonly } from "vue";
const MOBILE_BREAKPOINT = 1024;
const MOBILE_SMALL_BREAKPOINT = MOBILE_BREAKPOINT / 2;
const isLessThanBreakpoint = (breakpoint) => document.documentElement.clientWidth < breakpoint;
const isMobile = ref(isLessThanBreakpoint(MOBILE_BREAKPOINT));
const isSmallMobile = ref(isLessThanBreakpoint(MOBILE_SMALL_BREAKPOINT));
window.addEventListener("resize", () => {
isMobile.value = isLessThanBreakpoint(MOBILE_BREAKPOINT);
isSmallMobile.value = isLessThanBreakpoint(MOBILE_SMALL_BREAKPOINT);
}, { passive: true });
function useIsMobile() {
return readonly(isMobile);
}
function useIsSmallMobile() {
return readonly(isSmallMobile);
}
const isMobileState = readonly(isMobile);
export {
MOBILE_BREAKPOINT,
MOBILE_SMALL_BREAKPOINT,
isMobileState,
useIsMobile,
useIsSmallMobile
};
//# sourceMappingURL=useIsMobile.mjs.map