mirror of
https://github.com/NoCrypt/migu.git
synced 2026-01-11 20:10:22 +00:00
fix: mobile check event listener leak
This commit is contained in:
parent
b9f3042e1f
commit
1f8a13bd22
1 changed files with 9 additions and 5 deletions
|
|
@ -1,3 +1,12 @@
|
|||
<script context='module'>
|
||||
const mql = matchMedia('(min-width: 769px)')
|
||||
const isMobile = readable(!mql.matches, set => {
|
||||
const check = ({ matches }) => set(!matches)
|
||||
mql.addEventListener('change', check)
|
||||
return () => mql.removeEventListener('change', check)
|
||||
})
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import Home from './views/Home/Home.svelte'
|
||||
import MediaHandler from './views/Player/MediaHandler.svelte'
|
||||
|
|
@ -10,11 +19,6 @@
|
|||
|
||||
export let page = 'home'
|
||||
|
||||
const mql = matchMedia('(min-width: 769px)')
|
||||
const isMobile = readable(!mql.matches, set => {
|
||||
mql.addEventListener('change', ({ matches }) => set(!matches))
|
||||
})
|
||||
|
||||
$: minwidth = $isMobile ? '200px' : '35rem'
|
||||
$: maxwidth = $isMobile ? '200px' : '60rem'
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue