Declarative SVG Animations

You have already seen in this chapter several SVG animations. In this section, I will give you some more examples that will more fully illustrate some of the options available to you.

In SVG animations, you “declare” what you want to happen. You say which attribute you want to change, when you want the animation to start, how long it should take, what its starting value should be, what it's completion value should be, whether it repeats, and whether—when the animation has completed—the animated value is held or the original visual appearance is resumed.

So, suppose that we had code like the following:

<animate attributeName="x" begin="2s" dur="5s" 
from="50" to="800" repeatCount="5" fill="freeze"/>

We declare that ...

Get Special Edition Using XML, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.