首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SVG animateTransform转换和缩放同时失败

SVG animateTransform转换和缩放同时失败
EN

Stack Overflow用户
提问于 2019-03-17 01:01:32
回答 1查看 2.3K关注 0票数 3

我有一个我想要使用animateTransform动画的路径。我想同时平移和缩放路径。它不起作用。显然,只有第二个动画有效:在本例中是scale。我做错了什么?

代码语言:javascript
复制
svg{
width:300px; 
border:1px solid;
fill:none;
stroke:black;
}
代码语言:javascript
复制
<svg viewBox="-100 -100 200 200">

<path d="M-36.911,0C-36.911,-19.833,-19.833,-35.911,0,-35.911C19.833,-35.911,35.911,-19.833,35.911,0C35.911,19.833,19.833,35.911,0,35.911C-19.833,35.911,-36.911,19.833,-36.911,0z">

     <animateTransform
      attributeType="xml" 
      attributeName="transform"
      type="translate"
      dur="5s"
      values="0,0; 0,-50; 0,0; 0,50;0,0"
      repeatCount="indefinite"/>
   <animateTransform 
     attributeType="xml" 
     attributeName="transform" 
     type="scale"
     dur='5s'
     values="1;1.2;1;1.2;1"
     repeatCount="indefinite"/>
            
  </path>
  
  <circle r="1" />
</svg>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-17 01:08:55

第二个转换需要为additive="sum",这样它才不会替换第一个转换。

代码语言:javascript
复制
svg{
width:300px; 
border:1px solid;
fill:none;
stroke:black;
}
代码语言:javascript
复制
<svg viewBox="-100 -100 200 200">

<path d="M-36.911,0C-36.911,-19.833,-19.833,-35.911,0,-35.911C19.833,-35.911,35.911,-19.833,35.911,0C35.911,19.833,19.833,35.911,0,35.911C-19.833,35.911,-36.911,19.833,-36.911,0z">

     <animateTransform
      attributeType="xml" 
      attributeName="transform"
      type="translate"
      dur="5s"
      values="0,0; 0,-50; 0,0; 0,50;0,0"
      repeatCount="indefinite"/>
   <animateTransform 
     attributeType="xml" 
     attributeName="transform" 
     type="scale"
     dur='5s'
     values="1;1.2;1;1.2;1"
     repeatCount="indefinite"
      additive="sum"/>
            
  </path>
  
  <circle r="1" />
</svg>

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

https://stackoverflow.com/questions/55199311

复制
相关文章

相似问题

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