首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带href的SVG animateTransform

带href的SVG animateTransform
EN

Stack Overflow用户
提问于 2018-07-06 14:29:40
回答 2查看 553关注 0票数 0

试图移动一个SVG元素使用javascript的互动游戏;

代码语言:javascript
复制
<!DOCTYPE html>
<html>
    <body>
        <svg width="300" height="300">
            <circle id="circ" cx="50" cy="50" r="40"   fill="black" ></circle>
            <animateTransform xlink:href="#circ" attributeName="transform" attributeType="XML" type="translate" from="50 50" to="200 200" dur="1s" repeatCount="1"></animateTransform>
        </svg> 
    </body>
</html>

但是,元素在动画之后会下降到它原来的位置。

有什么建议使这个元素留在新的位置上吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-07-06 14:36:25

如果希望在动画结束后应用最终动画状态,请添加填充=“冻结”。

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<body>

    <svg width="300" height="300">
       <circle id="circ" cx="50" cy="50" r="40"   fill="black" >
       </circle>

       <animateTransform xlink:href="#circ" attributeName="transform" attributeType="XML" type="translate" from="50 50" to="200 200" dur="1s" repeatCount="1" fill="freeze"></animateTransform>
    </svg> 

</body>
</html>

票数 1
EN

Stack Overflow用户

发布于 2018-07-06 14:39:35

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<body>

    <svg width="300" height="300">
       <circle id="circ" cx="50" cy="50" r="40"   fill="black" >
       </circle>

       <animateTransform xlink:href="#circ" attributeName="transform" attributeType="XML" type="translate" from="50 50" to="200 200" dur="1s" repeatCount="1" fill="freeze" ></animateTransform>
    </svg> 

</body>
</html>

你只是需要使用填充冻结。

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

https://stackoverflow.com/questions/51212614

复制
相关文章

相似问题

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