我正在尝试为简单的SVG SMIL动画添加时间函数。显然可以使用keySplines
属性设置时序/缓动,然而在我的例子中它无效:
<svg xmlns="http://www.w3.org/2000/svg" width="214" height="214" viewBox="0 0 24 24">
<rect style="fill:#000;" width="4" height="4" x="3" y="11">
<animateTransform attributeName="transform"
begin="0s" dur="2s" type="translate" from="0 0" to="40 0" repeatCount="4" fill="freeze"
calcMode="spline"
keySplines="0.4, 0, 0.2, 1"/>
</rect>
<rect style="fill:#ff0000;" width="4" height="4" x="3" y="16">
<animateTransform attributeName="transform"
begin="0s" dur="2s" type="translate" from="0 0" to="40 0" repeatCount="4" fill="freeze" />
</rect>
</svg>
这里有一个演示:http://jsfiddle.net/q4e4049s/,黑色的应该具有缓动功能。
keyTimes="0;1"
,它就能正常工作,本质上你依赖于一个隐式的keyTimes
,如果不添加它,这似乎对我来说也没问题。在我看来,SVG规范并没有完全明确,在这种情况下是否应该使用隐式的keyTimes
。 - Erik Dahlström