I'm not sure if this can work at all but maybe someone has an idea or solution for this.
I've got a JSVGCanvas rendering a document wich has a defined initial size <svg width="400" height="400">.
It is important to distinguish between the requested area in the
UserAgent (width and height) and the canvas area to be rendered
(viewBox). Since you are not providing a viewBox they are assumed to be the same.
Now I'm adding elements to the document via the UpdateManager. I do not know exactly at which coordinates the elements are added to the document so some of them may have bigger x/y coordinates and thus be placed "outside" the document
(the doc has overflow="visible")
What I want to do is to automatically resize the JSVGCanvas to fit all "outside" elements in, kind of resize it to a bounding box of all elements in the doc.
When you say 'resize' do you mean physically resize the window on
the screen? (good if everything will be drawn within the confines of
a typical screen, say less than 1024x768 or so), or rescaled to fit the current window (good for just about any size)?
Can this be done with any listeners?
Not directly. The only place the true Bounding box of the document
is available is the GraphicsNode tree. You can attach listeners to
DOM Mutation events which will tell you when elements are added to
the tree (but presumably you already know that). What you really need
to do is get the Bounding Box of the document (canvas.getGraphicsNode().getBounds()) and use this to either
update the viewBox attribute on the SVG element or to resize the
canvas.
Is this already solved by the JSVGScrollCanvas I just read about?
The JSVGScrollCanvas uses the viewBox to know what area of the canvas it should allow scrolling over. So you may prefer a scrolling interface but you still need to update the viewBox so the canvas knows what area it is supposed to work with.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
