SVGZoomEvent errata - zoomRectScreen

Hi All,

I was recently asked what I thought an SVG 1.1 Full errata doc should say about 
the SVGZoomEvent interface. I'd like to make my answer public, so here goes:

If you're listening for SVGZoom events it's almost certainly because you have 
content in the target <svg> element that is dependent on its zoom level. One of 
the things I've frequently wanted to be able to do in response to an SVGZoom 
event is to reposition a child of the target <svg> element relative to the edges 
of the viewport established by the <svg> element. For example, if the <svg> 
element contains some SVG that provides zoom and pan controls to the user I 
probably don't want those controls to change size and move around as the user 
interacts with them. The problem is that in the general case (with viewBox and 
preserveAspectRatio set, and width/height specified in any unit) it is _very_ 
difficult to figure out where the top, bottom, left and right of the <svg> 
element are in the user space established _by_ the SVG element[1]. Unfortunately 
this user space is the only coordinate space you care about if you're concerned 
with the children of the <svg> element, since this is after all the coordinate 
space the children's attributes are in/rely on.

On the SVGZoomEvent interface we have a zoomRectScreen property rather 
underspecified by the single line:

     "The specified zoom rectangle in screen units." [2]

I suspect the only useful thing a rectangle on the SVGZoom event could specify 
is the user space rectangle described above. If that was the intention of 
zoomRectScreen then I suspect "screen" was a mistake and I'd really like to see 
an errata item saying something like:

     readonly SVGRect zoomRectScreen

       The rectangle established by the x, y, width, and height attributes
       of the <svg> element that is the target of the SVGZoomEvent. The
       rectangle is in the user space established _by_ the target <svg>
       element.

When implementing SVGZoomEvent for Mozilla I didn't implement zoomRectScreen 
because it was so unclear what it was meant to provide. Even if my suggested 
interpretation above was not the intention of zoomRectScreen I still suggest the 
above errata if at all possible, but one way or another it needs clarified.

I have other comments to make about SVGZoomEvent, but I'll send them in a follow 
up email since experience tells me that if my emails are too long they get 
misread or don't get read at all. ;-) The above is the issue I consider most 
important.

Regards,
Jonathan


[1] This is me speaking as the guy who implemented viewBox and 
preserveAspectRatio for Mozilla. If you think it's not very difficult try 
actually writing code and testing it with various units before saying "it's 
easy". It's not.

[2] http://www.w3.org/TR/SVG11/script.html#InterfaceSVGZoomEvent

Received on Wednesday, 7 March 2007 17:18:45 UTC