If you want your animation to alternate (similar to what animation-direction: alternate;
does in CSS), and you want to have a different delay for the initial/start/first repetition vs subsequent repetitions, here I provide two workarounds. See this GitHub issue in SVG Working Group repo.
Solution 1: Using two animation elements
<circle fill="#f5ca20" r="5" cx="12" cy="12">
<animate id="anim1" attributeName="r" dur="1s" fill="freeze" begin="3s; anim2.end + 5s" to="10" keyTimes="0; 1" calcMode="spline" keySplines="0.37, 0, 0.63, 1"/>
<animate id="anim2" attributeName="r" dur="1s" fill="freeze" begin="anim1.end + 5s" to="5" keyTimes="0; 1" calcMode="spline" keySplines="0.37, 0, 0.63, 1"/>
</circle>
Solution 2: Using combination of values
and keyTimes
attributes
<circle fill="#f5ca20" r="5" cx="12" cy="12">
<animate attributeName="r" dur="12s" begin="3s" values="5; 10; 10; 5; 5" keyTimes="0; 0.083; 0.5; 0.583; 1" repeatDur="indefinite" calcMode="spline" keySplines="0.37, 0, 0.63, 1; 0, 0, 1, 1; 0.37, 0, 0.63, 1; 0, 0, 1, 1"/>
</circle>
In this approach you should calculate the total duration of animations plus delays and assign it to dur
and also calculate the keyTimes
values for your durations. For my example, the total duration is 12s
and the times 3s 🡲 1s 🡲 5s 🡲 1s 🡲 5s maps to keyTimes="0; 0.083; 0.5; 0.583; 1"
.
Notes for my examples
calcMode="..."
and keySplines="..."
are optional (they specify timing interpolation)
- The initial animation delay is 3 seconds
- The animations (shrinking and expansion) each take 1 second
- The delay before starting to shrink/expand is 5 Seconds
Both of the above produce the following result: