use window matchMedia.

This commit is contained in:
Miroslav Šedivý 2023-04-19 12:28:14 +02:00
parent f9417db520
commit 9b851aac61
3 changed files with 4 additions and 4 deletions

View File

@ -89,7 +89,7 @@
this.unsubscribePixelRatioChange()
}
const media = matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)
const media = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)
media.addEventListener('change', this.onPixelRatioChange)
this.unsubscribePixelRatioChange = () => {
media.removeEventListener('change', this.onPixelRatioChange)

View File

@ -249,9 +249,9 @@
// check if the device has a touch screen
('ontouchstart' in window || navigator.maxTouchPoints > 0) &&
// we also check if the device has a pointer
!matchMedia('(pointer:fine)').matches &&
!window.matchMedia('(pointer:fine)').matches &&
// and is capable of hover, then it probably has a mouse
!matchMedia('(hover:hover)').matches
!window.matchMedia('(hover:hover)').matches
)
}

View File

@ -513,7 +513,7 @@
this.unsubscribePixelRatioChange()
}
const media = matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)
const media = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)
media.addEventListener('change', this.onPixelRatioChange)
this.unsubscribePixelRatioChange = () => {
media.removeEventListener('change', this.onPixelRatioChange)