--- In [email protected], Holger Will <[EMAIL PROTECTED]> wrote: > 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
Hi again, I still get some error messages in asv 3 even with the new code you wrote, but since I installed asv 6 the first code worked fine! So, thanks a lot! Maria ----- 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/

