CSS "d" path - attribute does not work in Safari, FireFox

I want to use CSS animation for the "d" attribute for the SVG path. This example works in Google Chrome:

body {
  background-color: #022040;
}

#path {
  d: path('M425,225 L475,275 L575,175 L675,275 L775,175 L875,275 L925,225'); 
  stroke: #1EFE64;
  fill: none;
  animation-name: path;
  animation-duration: 5s;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}


@keyframes path {

  0% {
     d: path('M425,225 L475,275');
  }

  25% {
     d: path('M425,225 L475,275 L575,175 L575,175 L575,175 L575,175 L575,175');
  }
  
  50% {
     d: path('M425,225 L475,275 L575,175 L675,275 L675,275 L675,275 L675,275'); 
  }
  
  75% {
     d: path('M425,225 L475,275 L575,175 L675,275 L775,175 L775,175 L775,175'); 
  }
  
  90% {
     d: path('M425,225 L475,275 L575,175 L675,275 L775,175 L875,275 L875,275'); 
  }
  
  100% {
     d: path('M425,225 L475,275 L575,175 L675,275 L775,175 L875,275 L925,225'); 
  }
}
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1000" height="400">
<path id="path" stroke-width="20"/>
</svg>
Run code

But it does not work in Safari Pc / Mobile and FireFox.

How to fix the error? Or should I use the "animate" tag in svg?

Help me, please) Thank you!

+4
source share
1 answer

dis an SVG geometry property defined in the SVG 2 specification at https://svgwg.org/svg2-draft/paths.html#TheDProperty . The Google Chromes Blink build engine is the only build engine that supports this property, and its implementation does not meet the current specification definition.

:

, , SVG animate:

<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1000 1000">
    <title>Path Animation</title>
    <path fill="none" stroke="hsl(139, 99%, 56%)" stroke-width="20">
        <animate attributeName="d" values="
            M 425 225 L 475 275;
            M 425 225 L 475 275 L 575 175 L 575 175 L 575 175 L 575 175 L 575 175;
            M 425 225 L 475 275 L 575 175 L 675 275 L 675 275 L 675 275 L 675 275;
            M 425 225 L 475 275 L 575 175 L 675 275 L 775 175 L 775 175 L 775 175;
            M 425 225 L 475 275 L 575 175 L 675 275 L 775 175 L 875 275 L 875 275;
            M 425 225 L 475 275 L 575 175 L 675 275 L 775 175 L 875 275 L 925 225
        " keyTimes="0; 0.25; 0.5; 0.75; 0.9; 1" calcMode="spline" keySplines="0.42 0 1 1; 0.42 0 1 1; 0.42 0 1 1; 0.42 0 1 1; 0.42 0 1 1" dur="5s" fill="freeze"/>
    </path>
</svg>

0.42 0 1 1 - ease-in animation-timing-function, CSS Timing Functions, 1: https://drafts.csswg.org/css-timing-1/#valdef-cubic-bezier-timing-function-ease-in.

+1

Source: https://habr.com/ru/post/1686496/


All Articles