W3C home > Mailing lists > Public > www-svg@w3.org > June 2000

Re: Zooming by defining rectangle and changing viewbox atttributes

From: Jon Ferraiolo <jferraio@Adobe.COM>
Date: Sat, 24 Jun 2000 10:43:46 -0700
Message-Id: <200006241740.KAA06033@mail-345.corp.Adobe.COM>
To: "Dany Bouchard" <db@dbxgeomatics.com>
Cc: <www-svg@w3.org>
Dany,
Sorry, I only have time to take a quick look at your SVG file.

The recommended way to control zooming through scripting is via the
'currentScale' and 'currentTranslate' attributes on the SVGSVGElement
interface
(corresponds to 'svg' elements). Here is the URL from the March 3 spec:
http://www.w3.org/TR/2000/03/WD-SVG-20000303/struct.html#InterfaceSVGSVGElem
ent.
I have extracted the description of these two DOM attributes:

float currentScale 
In certain interactive environments, the user can zoom and pan into the
current
SVG document fragment. The attribute indicates the current scale factor
relative to the initial view to take into account user zooming. DOM attributes
currentScale and currentTranslate are equivalent to the 2x3 matrix [a b c d e
f] = [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y] 
SVGPoint currentTranslate 
The corresponding translation factor that takes into account user zooming and
panning. 

I'm not sure whether Adobe or anyone else has implemented these DOM attributes
yet. My guess is "no". Also, be warned that a new public draft may be coming
soon, and there might be changes in this area.

A cheap trick for accomplishing zooming which will indeed work with the
current
version of the Adobe SVG Viewer or anyone else who supports the Core DOM
facilities from DOM 1 is to just stuff in new values for the 'viewBox'
attribute on the outermost SVG. For example, try out your file with each of
the
following two 'svg' elements at the top of your file:

< svg xml:space="preserve" width="450" height="314"
enableZoomAndPanControls="false" viewBox="0 0 450 450" >

< svg xml:space="preserve" width="450" height="314"
enableZoomAndPanControls="false" viewBox="50 50 250 250" >

You'll see that the second 'svg' element above has the effect of zooming in on
the drawing.

I didn't have time to look at your code which attempts to interactively draw a
zooming rectangle.

Also, 'g' element doesn't have attributes 'width' and 'height'.

Jon Ferraiolo
SVG Editor
Adobe Systems Incorporated

At 09:33 PM 6/23/00 -0400, Dany Bouchard wrote: 
>
> Following a few examples on this list and in other places, I have tryied to
> implement custom zooming functions using javascript and the DOM.
> I think I am almost there, there is only one problem. When the viewbox of
the
> main svg document is changed (after defining the first rectangle) , the
> references that I use in javascript to draw the rectangle don't match with
> the view of the document. How can I ensure that subsequent drawing occurs in
> the current view of the document ? I think I am forgetting something here !
> Hopefully someone can help !
> I have placed a version of the svg document at
>
<http://www.dbxgeomatics.com/zoomtest2.svg>www.dbxgeomatics.com/zoomtest2.svg
> so that you can see what I am referring to.
>  
> Thanks in advance.
>  
> Dany Bouchard
> DBx Geomatics
> 38 de l'Orbite
> Hull, Québec
> Canada
> J9A 3C7
> Téléphone/Telephone: 819.743.3870
> Télécopieur/Fax: 819.775.3264
> Courrier électronique/Email: <mailto:db@dbxgeomatics.com>db@dbxgeomatics.com
> Page Web/Web site:
> <http://www.dbxgeomatics.com/home.asp>http://www.dbxgeomatics.com/home.asp
Received on Saturday, 24 June 2000 13:40:55 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 5 November 2012 23:52:47 GMT