UNPKG

ideaz-element

Version:

<p align="center"> <a href="" target="_blank" rel="noopener noreferrer"> <img src="./docs/public/logo.svg" alt="Ideaz Element" width="180" style="width: 180px;" /> </a> </p>

1 lines 1.42 kB
{"version":3,"file":"useWindowReactiveSize.mjs","sources":["../../../packages/hooks/useWindowReactiveSize.ts"],"sourcesContent":["export const useWindowReactiveSize = () => {\n const width = ref(0);\n\n const windowReactiveSize = computed(() => {\n if (width.value >= 1920) {\n return 'xl';\n }\n if (width.value >= 1200) {\n return 'lg';\n }\n if (width.value >= 992) {\n return 'md';\n }\n if (width.value >= 768) {\n return 'sm';\n }\n if (width.value < 768) {\n return 'xs';\n }\n return 'xs';\n });\n\n const update = () => {\n if (window) {\n width.value = window.innerWidth;\n }\n };\n\n onMounted(() => {\n update();\n window.addEventListener('resize', update);\n });\n\n onUnmounted(() => {\n window.removeEventListener('resize', update);\n });\n\n return { windowReactiveSize };\n};\n"],"names":["useWindowReactiveSize","width","ref","windowReactiveSize","computed","update","onMounted","onUnmounted"],"mappings":";AAAO,MAAAA,IAAA,MAAA;AACL,QAAAC,IAAAC,EAAA,CAAA,GAEAC,IAAAC,EAAA,MACEH,EAAA,SAAA,OACE,OAEFA,EAAA,SAAA,OACE,OAEFA,EAAA,SAAA,MACE,OAEFA,EAAA,SAAA,MACE,QAEFA,EAAA,QAAA,KACE,KAEK,GAGTI,IAAA,MAAA;AACE,IAAA,WACEJ,EAAA,QAAA,OAAA;AAAA,EACF;AAGF,SAAAK,EAAA,MAAA;AACE,IAAAD,EAAA,GACA,OAAA,iBAAA,UAAAA,CAAA;AAAA,EAAwC,CAAA,GAG1CE,EAAA,MAAA;AACE,WAAA,oBAAA,UAAAF,CAAA;AAAA,EAA2C,CAAA,GAG7C,EAAA,oBAAAF,EAAA;AACF;"}