SVG SMIL animateTransform easing

I am trying to add sync functionality to a simple SVG SMIL animation. Apparently the time / relaxation can be set using an attribute keySplines

, however in my example it doesn't work:

<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>

      

Here is a demo: http://jsfiddle.net/q4e4049s/ black should have a relaxation

+3


source to share


1 answer




<svg xmlns="http://www.w3.org/2000/svg" width="100%" viewBox="0 0 50 50">
	<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; 0.4 0 0.2 1"
      values="0;30;0"
    />
	</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>
      

Run codeHide result


+3


source







All Articles