How to loop SVG animation sequence?

2019-01-22 12:08发布

I have sequence of animationTransform:

<animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0" to="30" begin="0s" dur="0.4s" fill="freeze"/>
<animateTransform attributeName="transform" attributeType="XML" type="rotate" from="30" to="0" begin="0.4s" dur="0.4s" fill="freeze"/>

If it possible to loop this sequence without using script?

I can set individual animation to loop by using repeatCount="indefinite" by I want to loop the whole sequence in order.

3条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-22 12:34

You can also just loop within a single animateTransform by providing a values attribute with a semi-colon separated list:

<animateTransform attributeName="transform" type="rotate"
     values="0;30;0" begin="0s" dur="0.8s" fill="freeze"
     repeatCount="indefinite" />

Here's an example (checked in Firefox 4.0 and Chrome).

查看更多
老娘就宠你
3楼-- · 2019-01-22 12:44

Figured it out already. Solution for those who are interested:

<animateTransform id="anim1" attributeName="transform" attributeType="XML" type="rotate" from="0" to="30" begin="0s; anim2.end" dur="0.4s" fill="freeze"/>
<animateTransform id="anim2" attributeName="transform" attributeType="XML" type="rotate" from="30" to="0" begin="anim1.end" dur="0.4s" fill="freeze"/>
查看更多
Viruses.
4楼-- · 2019-01-22 12:54

it's also possible to add/subtract (milli)seconds:

  begin="anim2.end-500ms"
查看更多
登录 后发表回答