XML technologies / SVG / Interactive graphics / Manipulating graphic elements / Starting animations with scripts
(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)
Animations too can easily start on a mouse click. Although JavaScript can control animations directly, defining an animation and starting it with a simple hyperlink is even easier. A variation of this chapter’s first example demonstrates this. An animation is added to the button that changes color on hover, shrinking the circle to a radius of one pixel. Set the attribute begin to indefinite. All other parameters must be defined so the animation works.
Note:
First test the animation by assigning the value 1s to the attribute begin. Only after verifying the animation itself can you be sure a later failure comes from its invocation or start.
To start the animation, an <a> tag is enough. Set its xlink:href attribute to the animation name defined by the id attribute of the <animate> tag.
<a xlink:href="#animieren" >
<circle onmouseover="farbeAendern(evt)" onmouseout="farbeAendern(evt)" cx="100" cy="100" r="20" style="fill:red">
<animate id="animieren" attributeName="r" begin="indefinite" from="20" to="1" by="-1" dur="5s" fill="freeze"/>
</circle>
</a>
Copyright © verlag moderne industrie GmbH 2001
You may print the online version for your private use.
Otherwise, this chapter from “Das Einsteigerseminar SVG — Webgrafiken mit XML” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
verlag moderne industrie GmbH, Justus-von-Liebig-Straße 1, D-86899 Landsberg/Lech, fon ++49 (0) 81 91 / 125 – 0, leserservice(at)mi-verlag.de
back to top