mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-04-05 17:15:40 +00:00
24 lines
621 B
JavaScript
24 lines
621 B
JavaScript
export default {
|
|
data() {
|
|
const pointerQuery =
|
|
typeof window !== 'undefined' ? window.matchMedia('(pointer: coarse)') : null
|
|
return {
|
|
isTouchDevice: pointerQuery ? pointerQuery.matches : false,
|
|
pointerQuery,
|
|
}
|
|
},
|
|
mounted() {
|
|
if (this.pointerQuery) {
|
|
this.onPointerChange = (e) => {
|
|
this.isTouchDevice = e.matches
|
|
}
|
|
this.pointerQuery.addEventListener('change', this.onPointerChange)
|
|
}
|
|
},
|
|
beforeDestroy() {
|
|
if (this.pointerQuery && this.onPointerChange) {
|
|
this.pointerQuery.removeEventListener('change', this.onPointerChange)
|
|
}
|
|
},
|
|
}
|