Spaces:
Paused
Paused
Download fronted/src/composables/useMediaQuery.js from phuc7/linguaielts-api: direct link, hf CLI and curl.
- Browser
- Download file 493 Bytes
-
https://huggingface.co/spaces/phuc7/linguaielts-api/resolve/main/fronted/src/composables/useMediaQuery.js
- Command line
-
hf download hf://spaces/phuc7/linguaielts-api/fronted/src/composables/useMediaQuery.js
-
curl -L -o useMediaQuery.js https://huggingface.co/spaces/phuc7/linguaielts-api/resolve/main/fronted/src/composables/useMediaQuery.js
493 Bytes
| import { ref, onMounted, onUnmounted } from 'vue' | |
| export function useMediaQuery(query) { | |
| const matches = ref( | |
| typeof window !== 'undefined' ? window.matchMedia(query).matches : false, | |
| ) | |
| let mql = null | |
| function update() { | |
| matches.value = mql?.matches ?? false | |
| } | |
| onMounted(() => { | |
| mql = window.matchMedia(query) | |
| mql.addEventListener('change', update) | |
| update() | |
| }) | |
| onUnmounted(() => { | |
| mql?.removeEventListener('change', update) | |
| }) | |
| return matches | |
| } | |