mirror of
https://github.com/NoCrypt/migu.git
synced 2026-04-21 00:22:08 +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>
|
<script>
|
||||||
import Home from './views/Home/Home.svelte'
|
import Home from './views/Home/Home.svelte'
|
||||||
import MediaHandler from './views/Player/MediaHandler.svelte'
|
import MediaHandler from './views/Player/MediaHandler.svelte'
|
||||||
|
|
@ -10,11 +19,6 @@
|
||||||
|
|
||||||
export let page = 'home'
|
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'
|
$: minwidth = $isMobile ? '200px' : '35rem'
|
||||||
$: maxwidth = $isMobile ? '200px' : '60rem'
|
$: maxwidth = $isMobile ? '200px' : '60rem'
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue