File size: 441 Bytes
4d70170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { ref } from 'vue'

const orientation = ref('landscape')

export function useOrientation() {
  return {
    orientation,
  }
}

const mediaQuery = window.matchMedia('(min-width: 685px)')
switchOrientation(mediaQuery)
mediaQuery.addEventListener('change', switchOrientation)

function switchOrientation(mediaQueryEvent: MediaQueryListEvent | MediaQueryList) {
  orientation.value = mediaQueryEvent.matches ? 'landscape' : 'portrait'
}