试图移动一个SVG元素使用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>但是,元素在动画之后会下降到它原来的位置。
有什么建议使这个元素留在新的位置上吗?
发布于 2018-07-06 14:36:25
如果希望在动画结束后应用最终动画状态,请添加填充=“冻结”。
<!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>
发布于 2018-07-06 14:39:35
<!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>
你只是需要使用填充冻结。
https://stackoverflow.com/questions/51212614
复制相似问题