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

144
Views
La animación de trazos SVG no funciona en Safari

Mi código JS revisa cada ruta y agrega un stroke-dasharray y stroke-dashoffset según la longitud de la ruta:

 setTimeout(() => { const $paths = document.getElementsByTagName('path'); for (const path of $paths) { const totalLength = path.getTotalLength(); path.style.strokeDashoffset = totalLength; path.style.strokeDasharray = totalLength; } }, 300);

Luego, My CSS simplemente anima el dashoffset a 0 , mientras reduce la opacidad del trazo y aumenta la opacidad del relleno:

 .character path { fill-opacity: 0; stroke-opacity: 1; stroke-width: 2px; stroke: white; -webkit-animation: path 4s linear 1s both; animation: path 4s linear 1s both; } @keyframes path { 70% { fill-opacity: 0; } 80% { stroke-dashoffset: 0; stroke-opacity: 1; } 100% { stroke-opacity: 0; stroke-dashoffset: 0; fill-opacity: 1; } }

Esto funciona perfectamente en Chrome: la animación muestra los caminos que se están dibujando, pero en Safari, los caminos simplemente aparecen sin ninguna animación.
Intenté prefijar pero no funciona.
EDITAR: Esto está relacionado de alguna manera con el tiempo de espera que configuré, solo lo agregué al código de la pregunta. Tengo que agregar ese tiempo de espera porque el svg se carga dinámicamente. Aquí hay un Fiddle que muestra el problema (funciona en Chrome, no en Safari), gracias @kaiido.

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

0

Resolví esto haciendo dos cosas:

  1. Ponga la propiedad de animation en el JS también
  2. Descubrí que Safari no maneja animaciones en setTimeout si el retraso de la animación es mayor que el tiempo de espera. Así que bajé el retraso a 200 ms.

JS actualizado:

 setTimeout(() => { const $paths = document.getElementsByTagName('path'); for (const path of $paths) { const totalLength = path.getTotalLength(); path.style.strokeDashoffset = totalLength; path.style.strokeDasharray = totalLength; path.style.animation = 'path 4s linear 0.2s both'; }; }, 300);

violín de trabajo

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!