Hi Holger,
OK your advice yesterday was actually correct and I am using a viewBox. My
mistake was this:
.setAttribute("preserveAspectRatio ","xMinYMin");
 
.........after the "preserveAspectRatio " I had a space character! So this
command was being ignored I think and no error was generated. When I removed
the space and changed the yMin into YMin it all worked. I resize the SVG and
it stays in the top left corner and does not shift down. :-) 
 
Thanks for your assistance.
 
Cheers,
James
 

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED]
On Behalf Of Holger Will
Sent: Thursday, 20 July 2006 3:16 PM
To: [email protected]
Subject: Re: [svg-developers] Absolute positioning of the SVG



>>Thanks for you assistance. Tried both "xMinYMin" and "none" both 
before and
>>after the height/width adjustments and appears to have no effect.

well, sorry i totally forgot... preserveAspectRatio has only an effect 
if you have a viewBox.
and the AspectRation of your viewBox is different to the aspectRatio set 
by width and height.

here is a little example that works for me:

<svg xmlns="http://www.w3. <http://www.w3.org/2000/svg> org/2000/svg">
<rect x="0" y="0" width="100" height="100" rx="10" ry="10" 
onclick="test()"/>
<script><![CDATA[
function test(){

// setting width/height different to the boundidng box of your drawing
document.documentElement.setAttributeNS(null,"width",100)
document.documentElement.setAttributeNS(null,"height",200)

// setting viewBox to the dimension of our drawing.
document.documentElement.setAttributeNS(null,"viewBox","0 0 100 100")

document.documentElement.setAttributeNS(null,"preserveAspectRatio","none")

}
]]></script>
</svg>

as to calculating the space, it should not be necessary to calculate it, 
but if you really want to...:

the height of our svg is larger than the height of the viewBox. so the 
image gets scaled to exactly fit the width.
after saling ( in this example the scalefactor is 1) the difference 
between width and viewBox width is exactly 100.
as the default for preserveAspectRatio is xMidYMid, you have the same 
space above and below the drawing, thats 100/2 = 50.
so currentTramslate.y - 50 should have the same effect as setting 
preserveAspectRation ="xMidYMin meet", but again it should not be 
necessary to do this.

if all that does not help, maybe you could write a little testcase 
and/or provide a link, so i can take a look at your code, it might be 
possible to help more.

cheers
Holger

-- 
if this information was useful, please try to help someone else !
My Private Homepage: http://www.treebuil <http://www.treebuilder.de> der.de
My Companys Website: http://www.klimapar <http://www.klimapartner-berlin.de>
tner-berlin.de



 



Australia Post is committed to providing our customers with excellent service. 
If we can assist you in any way please telephone 13 13 18 or visit our website.

The information contained in this e-mail communication may be proprietary, 
confidential or legally professionally privileged.  It is intended exclusively 
for the individual or entity to which it is addressed. You should only read, 
disclose, re-transmit, copy, distribute, act in reliance on or commercialise 
the information if you are authorised to do so. Australia Post does not 
represent, warrant or guarantee the integrity of this e-mail communication has 
been maintained nor that the communication is free of errors, virus or 
interference. 

If you are not the addressee or intended recipient please notify us by replying 
direct to the sender and then destroy any electronic or paper copy of this 
message. Any views expressed in this e-mail communication are taken to be those 
of the individual sender, except where the sender specifically attributes those 
views to Australia Post and is authorised to do so.

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/1U_rlB/TM
--------------------------------------------------------------------~-> 

-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to