Right now, I have a menu which on click of a hamburger button can be expanded or collapsed. The default state of the menu is true
meaning its expanded, but when I go to a different route where the menu is not there
, it plays the collapsed animation. Here is a sample code:
<script>
import { slide } from 'svelte/transition';
let isExpanded = true;
</script>
<button on:click={()=>isExpanded=!isExpanded}>Expand/Collapse</button>
{#if isExpanded}
<nav transition:slide>
Content
</nav>
{/if}
<a href="/some-page">There is no menu in this page</a>
This is the current behavior of the code:
On page load/reload, the menu expand transition plays (weirdly, this only happens sometimes) and on clicking the link, the menu collapse transition plays for a split second while the redirect is happening.
I'm not sure if this is a bug or something wrong in my implementation. Either case, would be grateful if a workaround is provided for this.
Thanks in advance!