You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by ACE91 <ad...@hotmail.com> on 2007/12/10 03:29:45 UTC

Re: Adding animations to the SVG DOM during runtime


Klaus Reimer wrote:
> 
> Hello,
> 
> I have an application which displays an SVG document in a JSVGCanvas and
> I'm adding content to the document during runtime. This works pretty
> well but when I add animation nodes to the DOM then they are simply
> ignored. The animation nodes which are already present in the DOM when I
> pass it to the canvas (with the setURI method) are working fine.
> 
> Is there a special trick I have to perform so animations added during
> runtime are actually played?
> 
> -- 
> Bye, K <http://www.ailis.de/~k/>
> [A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391]
> (Finger k@ailis.de to get public key)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

I've been having this same problem, so I took a look around the W3C's SMIL
specification, and it turns out there is a special trick that you have to
perform.

You see, by default, SMIL animations are timed by their "begin" attribute,
and if that attribute is not present, they will begin when the document
loads. So, if you want an animation to play as soon as it is added to the
document, simply appending the node to the document will not work. You have
to tell the animation node when to start.

The way to do this is the beginElement() function, which all animation
elements have. In Javascript/ECMAScript, you can start an animation like so:

document.getElementById(name).beginElement();

It's that simple.

I'm not sure how to do it in Java with the Batik APIs, though, because
Java's strict typing makes it a little more difficult. You see,
beginElement() is a method of the ElementTimeControl interface, not the
Element object. I can't help you there; you'll have to figure this out
yourself if you need it. Try looking around the Batik Javadocs.

Hope this helps
~ Ace
-- 
View this message in context: http://www.nabble.com/Adding-animations-to-the-SVG-DOM-during-runtime-tp13944995p14246331.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org