Hi,

I use these functions, which are called in my case as javascript in the
HTML, but you could as easily put them in the SVG document and build a
graphical interface.

This code was cobbled together by examining:
http://alzt.tau.ac.il/~dagan/tools/panZoom.svg

Here's another source:  http://pilat.free.fr/routines/zoom_pan.htm


function SVG_zoom(k)
    {
    svgdoc = document.embeds[0].getSVGDocument();
    var root = svgdoc.documentElement;
    var old_scale = root.currentScale;
    var new_scale = old_scale * k;
    root.currentScale = new_scale;

    var oldTranslate = { x: root.currentTranslate.x, y:
root.currentTranslate.y };

    var vp_width = 1050;  //the root translate is in pixels.  This should be
got.
    var vp_height = 730;
      // correct currentTranslate so zooming is to the center of the
viewport:
      root.currentTranslate.x = vp_width/2 -
                 (root.currentScale/old_scale) * (vp_width/2 -
oldTranslate.x);
      root.currentTranslate.y = vp_height/2 -
                 (root.currentScale/old_scale) * (vp_height/2 -
oldTranslate.y);
    }

function SVG_pan(k1,k2)
    {
        svgdoc=document.embeds[0].getSVGDocument();
        var root = svgdoc.documentElement;
        var old_value=root.currentScale;
        if (k1!=0)
        {
            old_x=root.currentTranslate.x;
            x=old_x + k1 * 40;
            root.currentTranslate.x=x;
        }
    else
        {
            old_y=root.currentTranslate.y;
            y=old_y + k2 * 40;
            root.currentTranslate.y=y;
        }
    }

function SVG_reset()
    {
        svgdoc = document.embeds[0].getSVGDocument();
        var root = svgdoc.documentElement;
        root.currentTranslate.x=0;
        root.currentTranslate.y=0;
        root.currentScale=1;
    }


Stephen



On 3/26/07, Richard Pearman <[EMAIL PROTECTED]> wrote:
>
>   Hi,
>
> Perhaps I should have said that I really want something that works in
> ASV3 as well as Firefox and Opera if possible.
>
> --- In [email protected] <svg-developers%40yahoogroups.com>,
> "Charles McCathieNevile"
> <[EMAIL PROTECTED]> wrote:
>
> > Try it with Opera. The current release (9.1) and my internal
> development version both handle it, as far as I can tell. (I am not
> sure why it is necessary - Opera handles pan and zoom natively already,
> same as it does for HTML etc).
>
> How do you pan in Opera? Alt drag doesn't seem to do it.
>
> Richard Pearman http://www.pixelpalaces.com/
> The next stage in the evolution of web comics:
> http://www.onlinecomics.net/pages/details/listing.php?comicID=4415
>
>  
>


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



-----
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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> 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