html - 如何重置 SVG 动画
问题描述
最近开始进入 SVG 动画,所以我想要做的是让这个圆圈回到矩形的中心并返回,它第一次这样做然后支持动画不断重复,这里是代码:
<svg style="border: 1px solid black; background-color: yellow;" width="750" height="500">
<circle id="kruzic" cy="250" cx="0" r="40" fill="blue">
<animate attributeName="cx" attributeType="XML" from="-50" to="335" dur="2s" repeatCount="indefinite" />
<animate attributeName="cx" attributeType="XML" from="335" to="-50" begin="2s" dur="2s" repeatCount="indefinite" />
</circle>
</svg>
谢谢!
解决方案
您可以使用值列表:
<svg style="border: 1px solid black; background-color: yellow;" width="750" height="500">
<circle id="kruzic" cy="250" cx="0" r="40" fill="blue">
<animate attributeName="cx" attributeType="XML" dur="4s" values="-50; 355; -50;" repeatCount="indefinite" />
</circle>
</svg>
推荐阅读
- flutter - Flutter 条件小部件但 {} 不等于 {}
- amazon-dynamodb - DynamoDB 表大小
- ios - 实例化视图控制器时出现 TypeMismatch 错误
- java - 制作一种在字符串中查找小写字母的方法
- mysql - 使用 MySql 5.7 中的动态列引用从另一个表更新表
- android - Android:如何使用 ViewModel 清除 Recyclerview 中的 Spannable 颜色?
- amazon-web-services - AWS ECS Fargate:应用程序负载均衡器返回 503 并带有奇怪的模式
- sql - 有没有办法在 PostgreSQL 函数中查询当前行值以及来自同一表的过滤结果集
- r - 如何对文件夹中的所有文件应用相同的转换
- swift - 如何在两个日期之间获取每个星期五的日期?