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

174
Views
setAttribute transición suave

Estoy tratando de recrear esta animación smil con javascript puro

 <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>

El problema aquí es cuando uso setAttribute para recrear la animación al hacer clic, la animación es repentina

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

y no puedo entender cómo hacerlo suave como el smil ¿Hay alguna manera de hacerlo en js puro?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede comenzar una animación en un evento de clic.

 <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 Report
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!