Search the web
Sign In
New User? Sign Up
svg-developers · SVG Developers
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
zoom/pan svg image, only inside a frame   Message List  
Reply | Forward Message #50789 of 63018 |
Re: [svg-developers] Re: zoom/pan svg image, only inside a frame

Hi Maria

>
>
> Hi Holger,
>
> I tried it in internet explorer with svgviewer 3 and there is an
> error message: Microsoft JScript runtime error- "Object doesn't
> support this property or method Line: 4, column: 0"

i forgot that getScreenCTM() is not implemented in ASV3. i use ASV6.
the workaround for ASV3 is a bit more complicated. see code at the end
of this post.

>
> I also tried it in Opera (no error messages), but all elements seem
> to zoomed in/out together...nothing stays stable in shape.

Opera only supports SVGTiny 1.1 there is not script controll !!!

>
> Do I do something wrong?

no, my mistake!

>
> Thanks,
>
>
here is the working code for ASV3,
of course it works in ASV6 as well as in firefox with native svg support,
though in firefox, zoom and pan events are not implemented.

<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" onload="reposition()"
onscroll="reposition()" onzoom="reposition()" onresize="reposition()"
viewBox="0 0 1024 768" >
<script><![CDATA[
function reposition(){

g=document.getElementById("fixedContent")
m=getScreenCTM(document.documentElement)
m=m.inverse()
g.setAttribute("transform","matrix("+m.a+",0,0,"+m.d+","+m.e+","+m.f+")")
}



function getScreenCTM(doc){
//my own implementation of getScreenCTM as the one found in gecko is
currently broken see bug:
var root=doc
var sCTM= root.createSVGMatrix()

var tr= root.createSVGMatrix()
var par=root.getAttribute("preserveAspectRatio")
if (par==null || par=="") par="xMidYMid meet"//setting to default value
parX=par.substring(0,4) //xMin;xMid;xMax
parY=par.substring(4,8)//YMin;YMid;YMax;
ma=par.split(" ")
mos=ma[1] //meet;slice

//get dimensions of the viewport
sCTM.a= 1
sCTM.d=1
sCTM.e= 0
sCTM.f=0



w=root.getAttribute("width")
if (w==null || w=="") w=innerWidth
h=root.getAttribute("height")
if (h==null || h=="") h=innerHeight

// get the ViewBox
vba=root.getAttribute("viewBox")
if(vba==null) vba="0 0 "+w+" "+h
var vb=vba.split(" ")//get the viewBox into an array

//--------------------------------------------------------------------------
//create a matrix with current user transformation
tr.a= root.currentScale
tr.d=root.currentScale
tr.e= root.currentTranslate.x
tr.f=root.currentTranslate.y



//scale factors
sx=w/vb[2]
sy=h/vb[3]

//meetOrSlice
if(mos=="slice"){
s=(sx>sy ? sx:sy)
}else{
s=(sx<sy ? sx:sy)
}

//preserveAspectRatio="none"
if (par=="none"){
sCTM.a=sx//scaleX
sCTM.d=sy//scaleY
sCTM.e=- vb[0]*sx //translateX
sCTM.f=- vb[0]*sy //translateY
sCTM=tr.multiply(sCTM)//taking user transformations into acount

return sCTM
}


sCTM.a=s //scaleX
sCTM.d=s//scaleY
//-------------------------------------------------------
switch(parX){
case "xMid":
sCTM.e=((w-vb[2]*s)/2) - vb[0]*s //translateX

break;
case "xMin":
sCTM.e=- vb[0]*s//translateX
break;
case "xMax":
sCTM.e=(w-vb[2]*s)- vb[0]*s //translateX
break;
}
//------------------------------------------------------------
switch(parY){
case "YMid":
sCTM.f=(h-vb[3]*s)/2 - vb[1]*s //translateY
break;
case "YMin":
sCTM.f=- vb[1]*s//translateY
break;
case "YMax":
sCTM.f=(h-vb[3]*s) - vb[1]*s //translateY
break;
}
sCTM=tr.multiply(sCTM)//taking user transformations into acount

return sCTM
}
]]> </script>
<g>
<rect x="0" y="0" width="1024" height="768"/>
</g>
<g id="fixedContent">
<rect x="0" y="0" width="200" height="768" fill="green"/>
</g>
</svg>

hth
Holger



Tue Jul 19, 2005 9:16 am

holger492
Offline Offline
Send Email Send Email

Forward
Message #50789 of 63018 |
Expand Messages Author Sort by Date

How can I have an svg frame that can not be panned or zoomed, and an svg image inside the frame that allows zoom and pan? Thanks, Maria...
spanakimaria
Offline Send Email
Jul 18, 2005
1:17 pm

... Hi Maria i believe its not directly possible, what you can do is allow zoom/pan on your outer svg frame, and then have a group holding the content that ...
Holger Will
holger492
Offline Send Email
Jul 18, 2005
2:57 pm

... and an ... zoom/pan ... that ... apply ... ()" ... ("+m.a+",0,0,"+m.d+","+m.e+","+m.f+")") ... Hi Holger, I tried it in internet explorer with svgviewer 3...
spanakimaria
Offline Send Email
Jul 19, 2005
8:39 am

Hi Maria ... i forgot that getScreenCTM() is not implemented in ASV3. i use ASV6. the workaround for ASV3 is a bit more complicated. see code at the end of...
Holger Will
holger492
Offline Send Email
Jul 19, 2005
9:16 am

... ASV6. ... the end ... seem ... support, ... ()" ... ("+m.a+",0,0,"+m.d+","+m.e+","+m.f+")") ... is ... value ... Hi again, I still get some error messages...
spanakimaria
Offline Send Email
Jul 19, 2005
11:01 am

... ASV6. ... the end ... seem ... support, ... ()" ... ("+m.a+",0,0,"+m.d+","+m.e+","+m.f+")") ... is ... value ... Hi again, I still get some error messages...
spanakimaria
Offline Send Email
Jul 19, 2005
11:01 am

Hi, at the moment I'm doing some trials with the filter feGaussianBlur, applied to a rectangle. It works fine but I have one problem: i want the "shadow...
Manuel Ca€ ¢Ã±Ã³n L€ ...
mr_manuel_canon
Offline Send Email
Jul 19, 2005
11:53 am

... Hi Manuel rounded corners shouldnt be a problem. if you post your code here, i may be able to help. cheers Holger...
Holger Will
holger492
Offline Send Email
Jul 19, 2005
12:05 pm

... Hi Holger, tranks for answering, the code is something like: <defs> <filter id="gaussFilter"> <feGaussianBlur stdDeviation="10.0"/> <feOffset dx="10.0"...
Manuel Cañón Ló...
mr_manuel_canon
Offline Send Email
Jul 19, 2005
1:31 pm

... Manuel, what you are seeing here, is that the filter output gets cliped. you can enlarge the clipping region by specifieing x/y/width/height on the filter...
Holger Will
holger492
Offline Send Email
Jul 19, 2005
2:03 pm

... Hi, I've been reading something and trying this things you told me, but the corners are still normal, they are not rounded (the corners of the rect element...
Manuel Ca€ ¢Ã±Ã³n L€ ...
mr_manuel_canon
Offline Send Email
Jul 19, 2005
3:20 pm

... you can ... the ... height="3"> ... me, but ... the ... The effect of the Gaussian filtr is to spread out the element by diffusion - as result what you...
Garry Haywood
gh_urban
Offline Send Email
Jul 20, 2005
9:08 am

... Great... I did not realize until now of the limited view... ... Yes, it did! thanks!!!! ... It helped a lot, overall the width and height filter...
Manuel Ca€ ¢Ã±Ã³n L€ ...
mr_manuel_canon
Offline Send Email
Jul 20, 2005
12:33 pm

you may also want add the x and y to the filter with negative amounts so you can see the full effect of the filter glad it worked for you Garry <svg...
Garry Haywood
gh_urban
Offline Send Email
Jul 20, 2005
4:24 pm

... An alternative to the reverse transforms suggested (which I believe can be slightly buggy, I've read one viewers misimplements a CTM function, possibly not...
Bart
scarfboy
Offline Send Email
Jul 19, 2005
11:54 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help