update() calculates the transform that is need to prevent an object from being scaled or transformed. This transformation is applied to all nodes managed by this object.

Properties

svgNodes is an array of SVG nodes. This is the collection of all nodes that are being manages by this object.

x_trans is a number that is equivalent to the current x translation that azap is applying to the managed SVG nodes.

y_trans is a number that is equivalent to the current y translation that azap is applying to the managed SVG nodes.

scale is a number that is equivalent to the current scale that azap is applying to the managed SVG nodes.

Example

The following example registers a <g> element with an AntiZoomAndPan object. Try panning and zooming the image. Notice that only the circle is effected by these actions.

This example recreates the last example but defines a viewBox on the root svg element. You may find it interesting to open this example in its own window and then resize the window. You will notice that the circle is resized according to the rules of the viewBox; however, the text remains visually uneffected.

Revision History

Version 1.2

Removed dependency on viewBox object. The viewBox will not be taken into effect if the ViewBox object has not been loaded in the SVG document. I still haven't addressed the transformation problem mentioned in version 1.1 below.

Version 1.1

Add initial support for viewBox; however, there is a problem in my transformation logic which requires you to use screen coordinates on elements that are managed by azap even when a viewBox viewport is in effect on the element.

Version 1.0

Initial release of the AntiZoomAndPan object. Currently does not support SVG documents using a viewBox.