Re: Accessing the animated position of an SVG element

Shane Stephens:
> I have the following fragment of SVG:
> 
> <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>
> </svg>
> 
> 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?

The transform due to the current motion animation is not exposed
anywhere in the SVG DOM, as far as I’m aware.  I think the best you
could do is to wrap the <rect> in a <g> and then call getBBox() on the
<g>.

-- 
Cameron McCormack ≝ http://mcc.id.au/

Received on Wednesday, 20 October 2010 04:06:25 UTC