【发布时间】:2017-07-05 14:04:03
【问题描述】:
我想让我的 svg 在点击时缩小,并在缩小时在点击时增长。
这是如何实现的?我在 Javascript 中尝试了一些东西,但找不到简单的方法。
例如这个 SVG:
<svg id="MyRect" width="100" height="100" viewbox="0 0 100 100">
<polygon fill="#000000" points="0,0 0,100 100,100 100,0">
<animate id="shrink" attributeName="points" begin="undefined" restart="whenNotActive" dur="1s" from="0,0 0,100 100,100 100,0" to="30,30 30,70 70,70 70,30" fill="freeze" />
<animate id="grow" attributeName="points" begin="undefined" restart="whenNotActive" dur="1s" from="30,30 30,70 70,70 70,30" to="0,0 0,100 100,100 100,0" fill="freeze" />
</polygon>
</svg>
如何根据他的“状态”触发动画或其他?
谢谢。
【问题讨论】:
标签: javascript svg