Cleanup Switcher code
This commit is contained in:
@@ -1,14 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher } from 'svelte'
|
|
||||||
// Components
|
|
||||||
import Icon from '$components/atoms/Icon.svelte'
|
import Icon from '$components/atoms/Icon.svelte'
|
||||||
|
|
||||||
let switcherEl: HTMLElement
|
let switcherEl: HTMLElement
|
||||||
let isOpen = false
|
let isOpen = false
|
||||||
|
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
|
||||||
|
|
||||||
// Links
|
// Links
|
||||||
const links = [
|
const links = [
|
||||||
{
|
{
|
||||||
@@ -44,9 +39,9 @@
|
|||||||
* Detect outside click
|
* Detect outside click
|
||||||
*/
|
*/
|
||||||
const windowClick = ({ target }) => {
|
const windowClick = ({ target }) => {
|
||||||
if (!switcherEl.contains(target)) {
|
if (!switcherEl.contains(target) && isOpen) {
|
||||||
// Close switcher
|
// Close switcher
|
||||||
isOpen = false
|
toggleSwitcher()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user