首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >svg animateTransform同时触发多个动画

svg animateTransform同时触发多个动画
EN

Stack Overflow用户
提问于 2014-05-19 11:46:33
回答 1查看 9.3K关注 0票数 4

在下面的示例中,我需要同时执行所有动画。但只在最后一个起作用。

代码语言:javascript
复制
<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>

js触发了以下行动:

代码语言:javascript
复制
var animations = $( $this ).find( 'animateTransform' );
animations[0].beginElement();
animations[1].beginElement();
animations[2].beginElement();
EN

回答 1

Stack Overflow用户

发布于 2014-07-06 07:10:32

您的脚本中几乎没有错误:

Begin=“不定”

应:

RepeatCount=“不定”

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

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

additive="sum“

因此,您的代码应该如下所示:

代码语言:javascript
复制
<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>

顺便说一下,在0.5度旋转你的图像是不明显的,所以为什么要麻烦呢?!

在这里你可以读到更多关于它的信息:SVG-SMIL animation tutorial

票数 17
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23736938

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档