Here is a simple description ..

<svg xmlns="http://www.w3.org/2000/svg";
     xmlns:xlink="http://www.w3.org/1999/xlink";
     onload="loadsvgcaller(evt);">

<script type="text/ecmascript"> <![CDATA[


function loadsvgcaller(evt) {
 window.setTimeout("updateVisualization();",1000);
}


 function updateVisualization(evt)
 {
        //some code for inits etc...
        itemLabelTextView1 = templateText.cloneNode(true);
        itemLabelTextPath1 = templateTextPath.cloneNode(true);
        itemLabelTextPath1.appendChild(document.createTextNode('someText'));
        itemLabelTextView1.appendChild(itemLabelTextPath1);
          
          var bbox = itemLabelTextView1.getBBox();
          var bboxWidth = bbox.width;
          var bboxHeight = height;

          // bbox is null even with the timeout trick.. 

          //further use bbox width, height to manipulate element positions

 };

  ]]> </script>

          <text font-family="Verdana" fill="blue" id='templateText'>
        <textPath xlink:href="#templateTextPathDef"                     
id='templateTextPath'></textPath>
</text>
</svg>


The bbox remained null with the timeout approach.

Thanks,
Nirmesh.

-----Original Message-----
From: Helder Magalhães [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 20, 2008 6:36 AM
To: [email protected]
Subject: Re: bbox on text node in onload javascript

> I am unable to get the bbox from text node in javascript function call at
> onload of svg element.

Using a onload event hander the SVG should work: the SVG document is
already displayed. There are a number of known issues with some SVG
implementations (such as Firefox [1], at least for version 2) while
attempting to compute bounding boxes before the SVG document is
displayed (for example, in a script which will be immediately
evaluated when available, before the document is actually displayed).

Which Batik version are you using? Can you attach a reduced test case
for your experienced behavior? Does it still occur if you use the
"setTimeout" trick [1]? If not, then the SVG wiki page should be
updated in order to state that the "setTimeout" trick also applies to
Batik version X (the one you are using).

Hope this helps,

 Helder Magalhães

[1] http://wiki.svg.org/GetBBox#Firefox_Support

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to