W3C home > Mailing lists > Public > www-svg@w3.org > October 2010

Re: Accessing the animated position of an SVG element

From: Alex Danilo <alex@abbra.com>
Date: Wed, 20 Oct 2010 15:17:42 +1100
Message-Id: <ILMKAL.4VE4HHE6L9DI@abbra.com>
To: Shane Stephens <shans@google.com>
Cc: www-svg@w3.org
Hi Shane,

--Original Message--:
>I have the following fragment of SVG:
>  <g transform="translate(300,30)">
>    <rect width="40" height="40"/>
>    <animateMotion dur="1s" repeatCount="1" rotate="auto" path="M
>100,250 C 100,50 400,50 500,250"/>
>  </g>
>I want to access the animated position of the rect using javascript,
>but I can't figure out how to do it.  The transform, x and y values on
>rect are SVGAnimated values, but the rect is not directly animated.
>The transform on <g> is also an SVGAnimated value, but the animVal
>only ever contains the result of translate(300,30). rect.getCTM() and
>g.getCTM() seem to return the base value only (i.e. not the animated
>value).  Is there something I'm missing?

I think you're seeing a bug in the viewer.

getCTM() says "Returns the transformation matrix from current
user units (i.e., after application of the ‘transform’ attribute,
if any) to the viewport coordinate system for the

So if there's an animateMotion happening, the transform from
user to device space is changing and so should getCTM() for
the rect for sure.

My guess is that the implementation is just walking the tree
to calculate the transforms hanging off the DOM nodes without
taking the animations into account (you don't cache a matrix
at each node after all).


>    -Shane
Received on Wednesday, 20 October 2010 04:18:29 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:54:28 UTC