svg animateTransform同时触发多个动画

Ser*_*nko 3 svg svg-animate

在以下示例中,我需要同时执行所有动画.但作品只有一个.

<g>
    <animateTransform attributeName="transform" attributeType="XML"
    type="rotate" values="2 100 100; -1 100 100; 1 100 100; -0.5 100 100 0.5 100 100" begin="indefinite" dur="0.35s" fill="freeze" />

    <animateTransform attributeName="transform" attributeType="XML"
                      type="scale" values="1; 1.2; 1" begin="indefinite" dur="0.35s" fill="freeze" />

    <animateTransform attributeName="transform" attributeType="XML"
                      type="translate" values="0 0; -100 -100; 0; 0" begin="indefinite" dur="0.35s" fill="freeze" />

    <image x="0" y="0" width="200" height="200"  xlink:href="<?php  echo $cck->getValue('project_icon'); ?>" />
</g>
Run Code Online (Sandbox Code Playgroud)

行动已由js触发:

var animations = $( $this ).find( 'animateTransform' );
animations[0].beginElement();
animations[1].beginElement();
animations[2].beginElement();
Run Code Online (Sandbox Code Playgroud)

Cod*_*ems 9

您的脚本中有很少的错误:

开始="无限期"

应该:

repeatCount = "不定"

旋转值中,您忘记用分号分隔最后一个,并且在翻译部分中有一个额外的分号.

为了执行少量转换,您需要通过添加来对结果求和(无需将其添加到第一次转换)

添加剂="总和"

所以你的代码应该是这样的:

<g>
   <animateTransform attributeName="transform" attributeType="XML"
       type="rotate" values="2 100 100;-1 100 100;1 100 100;-0.5 100 100;0.5 100 100" repeatCount="indefinite" dur="0.35s" fill="freeze" />

   <animateTransform attributeName="transform" attributeType="XML"
                      type="scale" values="1;1.2;1" repeatCount="indefinite" dur="0.35s" fill="freeze" additive="sum"/>

   <animateTransform attributeName="transform" attributeType="XML"
                      type="translate" values="0 0;-100 -100;0 0" repeatCount="indefinite" dur="0.35s" fill="freeze" additive="sum"/>

   <image x="0" y="0" width="200" height="200"  xlink:href="<?php  echo $cck->getValue('project_icon'); ?>" />
</g>
Run Code Online (Sandbox Code Playgroud)

BTW在0.5度旋转你的图像是不明显的,所以为什么要打扰?!

在这里你可以阅读更多关于它: SVG-SMIL动画教程