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

Re: DOM APIs - Accessing The viewBox Attribute

From: Jeff Schiller <codedread@gmail.com>
Date: Fri, 22 Jan 2010 08:06:17 -0600
Message-ID: <da131fde1001220606h2407aefdx5ac49027887ce178@mail.gmail.com>
To: Francis Hemsher <fhemsher@gmail.com>
Cc: Robert Longson <longsonr@gmail.com>, www-svg@w3.org
Hi Francis,

It is already possible to get the viewBox attributes (though it's very
verbose due to animation possibilities).  See the SVGFitToViewBox
interface in the DOM IDL: http://www.w3.org/TR/SVG11/idl.html from
which the <svg>, <symbol>, and <marker> elements all inherit:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300">
<script>
  var svgroot = document.documentElement;
  var vb = svgroot.viewBox.baseVal;
  alert([vb.x, vb.y, vb.width, vb.height]);
</script>
</svg>

Works in Firefox, Opera, Safari and Chrome.

Regards,
Jeff

On Fri, Jan 22, 2010 at 7:40 AM, Francis Hemsher <fhemsher@gmail.com> wrote:
> Hi Robert,
> I haven't used Batik, but I see the getViewBox listed in their classes:
> http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/dom/svg/SVGOMSVGElement.html
>
> Could we invite the Batik folks to participate in this thread? They
> have alot of methods that look very good.
>
> Francis
>
> On 1/22/10, Robert Longson <longsonr@gmail.com> wrote:
>> Francis,
>>
>> Doesn't symbolElement.GetViewBox or markerElement.GetViewBox etc meet your
>> needs?
>>
>> Robert
>>
>
>
Received on Friday, 22 January 2010 14:06:53 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:44 GMT