触发反向 SVG 动画,通过单击按钮触发,随后单击

问题描述

假设您有以下 Hello 标签的 SVG 动画,当您单击小方块时会触发该动画:

<svg viewBox="0 0 100 50" style="width:200px; height:100px;">
<rect x="40" width="10" height="10" y="40">
<animateTransform id="myanim" begin="click"></animateTransform>
</rect>
<text x="45" y="20" width="50" height="10" text-anchor="middle">Hello
<animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0 45 20" to="90 45 20" dur="0.5s" begin="myanim.begin" repeatCount="1" additive="sum" fill="freeze"></animateTransform>
</text>
</svg>

如果再次单击按钮,如何以相反的逻辑执行相同的动画;即在每 (2n) 次点击时将 hello 元素旋转回其原始状态,并在每 (2n - 1) 次点击时旋转它以再次垂直显示

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)