Carlos
06-23-2004, 09:53 AM
Hey,
I added an eventlistener:
svgDoc.rootElement.addEventListener("SVGZoom", sync, false);
sync is a function that keeps sizes of some shapes constant as the background map zooms.
In order to do that without hard-coding values in, I need to know whether the used clicked zoom-in or zoom-out.
Is there a way to retrieve that information?
Thanks in advance!
Carlos
Anonymous
06-23-2004, 10:30 AM
You can find zoom scale with
document.rootElement.currentScale
Also for pan, currentTranslate return SVGPoint
Michel
wayhang
12-18-2004, 01:46 AM
Hi,
By default, svg enable us to press "CTRL" + left click to zoom in
and each time we zoom in, the scale will b...
newScale = currentScale * 2...So what i'm trying to do is set it to
b...
newScale = currentScale * 1.5
Below is my code, when i try to zoom in, i get a "Stack overflow"
error. The way i do it is wrong? Can anyone show me the correct way
to do it?
Thanks in advance
<svg id="root" width="200" height="200" viewBox="0 0 200 200"
onload="Initialize(evt)">
<script language="javascript">
<![CDATA[
var currentScale;
var newScale;
function Initialize(evt)
{
var SVGDoc = evt.getTarget().getOwnerDocument
();
SVGRoot = SVGDoc.getElementById("root");
SVGDoc.rootElement.addEventListener
("SVGZoom", zoomScale, false);
}
function zoomScale()
{
currentScale = SVGRoot.currentScale;
newScale = currentScale * 1.5;
SVGRoot.setCurrentScale(newScale);
}
]]></script>
<circle cx="20" cy="20" r="15" style="fill: blue"/>
<rect x="100" y="100" width="10" height="20" style="fill:
green"/>
</svg>