Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
Cómo refactorizar la función de alternancia de clase de elemento svelteKit

generé un menú pegajoso inferior con svelteKit. Cuando se hace clic en un menú, su elemento alterna clases animadas usando la biblioteca animate.style. Está funcionando, ¿cómo refactorizar este código?

 <script> 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); } </script> <section class="w-100 bottom"> <div class="elem {activeMenu === 'home' ? 'active' : ''}"> <a class="{animates.home === true ? 'animate__animated animate__jello' : ''}" on:click={() => setAnimate('home')} href="/" title="Home"><span class="lnr lnr-home"></span></a> </div> <div class="elem {activeMenu === 'notifications' ? 'active' : ''}"> <a class="{animates.notifications === true ? 'animate__animated animate__jello' : ''}" on:click={() => setAnimate('notifications')} title="Notifications"><span class="lnr lnr-alarm"></span></a> </div> <div class="elem {activeMenu === 'messages' ? 'active' : ''}"> <a class="{animates.messages === true ? 'animate__animated animate__jello' : ''}" on:click={() => setAnimate('messages')} title="Home"><span class="lnr lnr-envelope"></span></a> </div> <div class="elem {activeMenu === 'profile' ? 'active' : ''}"> <a class="{animates.profile === true ? 'animate__animated animate__jello' : ''}" on:click={() => setAnimate('profile')} href="/profile" title="Home"><span class="lnr lnr-user"></span></a> </div> <div class="elem {activeMenu === 'menu' ? 'active' : ''}"> <a class="{animates.menu === true ? 'animate__animated animate__jello' : ''}" on:click={() => setAnimate('menu')} href="/menu" title="Home"><span class="lnr lnr-menu"></span></a> </div> </section>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!