Download web/src/composables/useMobileWidth.js from jimlv/ssh: direct link, hf CLI and curl.
- Browser
- Download file 460 Bytes
-
https://huggingface.co/spaces/jimlv/ssh/resolve/main/web/src/composables/useMobileWidth.js
- Command line
-
hf download hf://spaces/jimlv/ssh/web/src/composables/useMobileWidth.js
-
curl -L -o useMobileWidth.js https://huggingface.co/spaces/jimlv/ssh/resolve/main/web/src/composables/useMobileWidth.js
460 Bytes
| import { ref, onMounted, onUnmounted } from 'vue' | |
| export default function useMobileWidth(maxWidth = 968) { | |
| const isMobileScreen = ref(window.innerWidth < maxWidth) | |
| function updateScreenWidth() { | |
| isMobileScreen.value = window.innerWidth < maxWidth | |
| } | |
| onMounted(() => { | |
| window.addEventListener('resize', updateScreenWidth) | |
| }) | |
| onUnmounted(() => { | |
| window.removeEventListener('resize', updateScreenWidth) | |
| }) | |
| return { isMobileScreen } | |
| } | |