SVG动画是否可以同时变换、旋转和缩放同一对象? [英] SVG animateTransform rotate and scale the same object at the same time?

查看:30
本文介绍了SVG动画是否可以同时变换、旋转和缩放同一对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望以动画的方式同时缩放和旋转对象。到目前为止,我的尝试都失败了。我只能链接动画(先旋转,然后缩放),但不能一起旋转和缩放。

我错过了什么?

我已尝试删除"add="sum",但这只是覆盖并忽略缩放动画.


<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
 width="200px" height="200px" viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve">

<rect x="29.2" y="33.6" width="136.7" height="136.7">

<animateTransform attributeName="transform" type="scale" 
from="0" to="1" dur="1s" additive="sum" accumulate="sum"/> 

<animateTransform attributeName="transform" type="rotate" 
from="0 100 100" to="100 100 100" dur="5s"  repeatCount="indefinite"  accumulate="sum" />


<animate attributeType="CSS" attributeName="opacity" 
from="1" to="0" dur="4s" fill="freeze"  />


</rect>
</svg>

感谢大家的帮助!

推荐答案

您只需要在两个动画元素上都加上="SUM"。我在Firefox上工作得很好,只有一处改动。

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
 width="200px" height="200px" viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve">

<rect x="29.2" y="33.6" width="136.7" height="136.7">

<animateTransform attributeName="transform" type="scale" 
from="0" to="1" dur="1s" additive="sum" accumulate="sum"/> 

<animateTransform attributeName="transform" type="rotate" 
from="0 100 100" to="100 100 100" dur="5s"  repeatCount="indefinite"  additive="sum" accumulate="sum" />


<animate attributeType="CSS" attributeName="opacity" 
from="1" to="0" dur="4s" fill="freeze"  />


</rect>
</svg>

这篇关于SVG动画是否可以同时变换、旋转和缩放同一对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆