title: How refactor element class toggle function svelteKit
body: <p>i generated an bottom sticky menu with svelteKit. When clicked an menu, its element toggling animate classes using animate.style library.
  Its working, how to refactor this code?</p>
  <pre><code>&lt;script&gt;
      import { getStores, navigating, page, session, updated } from '$app/stores';
      export let activeMenu;
      const animates = {'home': false, 'menu': false, 'profile': false, 'messages': false, 'notifications': false};
  
      function setAnimate(target){
          animates[target] = false;
          setTimeout(function(){
          animates[target] = true;
          }, 1000);
      }
  
      
  &lt;/script&gt;
  &lt;section class=&quot;w-100 bottom&quot;&gt;
      &lt;div class=&quot;elem {activeMenu === 'home' ? 'active' : ''}&quot;&gt;
          &lt;a class=&quot;{animates.home === true ? 'animate__animated animate__jello' : ''}&quot; on:click={() =&gt; setAnimate('home')} href=&quot;/&quot; title=&quot;Home&quot;&gt;&lt;span class=&quot;lnr lnr-home&quot;&gt;&lt;/span&gt;&lt;/a&gt;
      &lt;/div&gt;
      &lt;div class=&quot;elem {activeMenu === 'notifications' ? 'active' : ''}&quot;&gt;
          &lt;a class=&quot;{animates.notifications === true ? 'animate__animated animate__jello' : ''}&quot; on:click={() =&gt; setAnimate('notifications')} title=&quot;Notifications&quot;&gt;&lt;span class=&quot;lnr lnr-alarm&quot;&gt;&lt;/span&gt;&lt;/a&gt;
      &lt;/div&gt;
      &lt;div class=&quot;elem {activeMenu === 'messages' ? 'active' : ''}&quot;&gt;
          &lt;a class=&quot;{animates.messages === true ? 'animate__animated animate__jello' : ''}&quot; on:click={() =&gt; setAnimate('messages')} title=&quot;Home&quot;&gt;&lt;span class=&quot;lnr lnr-envelope&quot;&gt;&lt;/span&gt;&lt;/a&gt;
      &lt;/div&gt;
      &lt;div class=&quot;elem {activeMenu === 'profile' ? 'active' : ''}&quot;&gt;
          &lt;a class=&quot;{animates.profile === true ? 'animate__animated animate__jello' : ''}&quot; on:click={() =&gt; setAnimate('profile')} href=&quot;/profile&quot; title=&quot;Home&quot;&gt;&lt;span class=&quot;lnr lnr-user&quot;&gt;&lt;/span&gt;&lt;/a&gt;
      &lt;/div&gt;
      &lt;div class=&quot;elem {activeMenu === 'menu' ? 'active' : ''}&quot;&gt;
          &lt;a class=&quot;{animates.menu === true ? 'animate__animated animate__jello' : ''}&quot; on:click={() =&gt; setAnimate('menu')} href=&quot;/menu&quot; title=&quot;Home&quot;&gt;&lt;span class=&quot;lnr lnr-menu&quot;&gt;&lt;/span&gt;&lt;/a&gt;
      &lt;/div&gt;
      
  &lt;/section&gt;
  </code></pre>