Svg fill animation for the given path

后端 未结 3 1241
無奈伤痛
無奈伤痛 2020-12-03 02:31

I am trying to animate an arrow from left to right.The code of my arrow\'s path is given below:

3条回答
  •  醉酒成梦
    2020-12-03 02:46

    I don't think this is possible with the fill attribute. But instead, you can invert your SVG path to a rectangle with a triangle like hole. Now you just need a second element behind that path, where you can simply animate the scale in x-direction, to fill the hole from left to right.

    Here is an image showing the technique:

    An here is a working example:

    
      
        
      
      
    

    Note: The answer was updated from triangle to arrow, I won't update my answer as the technique is the same for every shape.

提交回复
热议问题