Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
setAttribute smooth transition

I trying to recreate this smil animation with pure javascript

<svg viewBox="0 0 600 600">
<path id="foo" d="M10 10 C 20 20, 40 20, 50 10" stroke="black" fill="black">
  <animate
       attributeName="d"  to="M500 500 C 20 20, 40 20, 50 10"
       dur="5s" repeatCount="indefinite" />
  </path>
</svg>

The problem here is when I use setAttribute to recreate the animation on click the animation is sudden

var path = document.getElementById('foo');
path.addEventListener("click", function(){path.setAttribute('d','M500 500 C 20 20, 40 20, 50 10');});

and I can't figure out how to make it smooth like the smil Is there a way to make it in pure js ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can begin an animation on a click event.

<svg viewBox="0 0 600 600">
<path id="foo" d="M10 10 C 20 20, 40 20, 50 10" stroke="black" fill="black">
  <animate
       attributeName="d"  to="M500 500 C 20 20, 40 20, 50 10"
       dur="5s" begin="0s;foo.click" repeatCount="indefinite" />
  </path>
</svg>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda