Cleanup Switcher code

This commit is contained in:
2021-11-17 21:41:08 +01:00
parent 873c2d94ac
commit 78cacbcd46

View File

@@ -1,14 +1,9 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte'
// Components
import Icon from '$components/atoms/Icon.svelte'
let switcherEl: HTMLElement
let isOpen = false
const dispatch = createEventDispatcher()
// Links
const links = [
{
@@ -44,9 +39,9 @@
* Detect outside click
*/
const windowClick = ({ target }) => {
if (!switcherEl.contains(target)) {
if (!switcherEl.contains(target) && isOpen) {
// Close switcher
isOpen = false
toggleSwitcher()
}
}
</script>