Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

172
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda