Plugin to Pan and Zoom elements, including SVG

Version 1.2


Based on:

https://timmywil.com/panzoom/


Sample App:
https://visualneo.com/tutorials/neopanzoom


Description


The neoPanZoom plugin for VisualNEO Web adds pan and zoom capabilities to HTML elements, including SVG graphics, allowing for interactive image and graphic navigation. This plugin is highly useful for applications involving maps, detailed images, or diagrams, providing users with an intuitive way to explore content. Here’s an overview of its functionalities and use cases:

Basic Pan and Zoom Initialization

The neoPanZoomInit command initializes pan and zoom on an element, setting the start position and zoom level.

    • Command: neoPanZoomInit
    • Syntax: neoPanZoomInit "elementName" startX startY theScale
      • elementName: ID of the element or SVG container.
      • startX and startY: Initial x and y positions.
      • theScale: Starting zoom level (e.g., 1 for default scale).

Example:

neoPanZoomInit "imageContainer" 0 0 1

This command initializes panning and zooming at the center of the element without scaling.

Setting Pan and Zoom Options

The neoPanZoomSetOptions command customizes pan and zoom behavior, such as setting minimum and maximum zoom levels, enabling zoom with the mouse wheel, and defining animation properties.

    • Command: neoPanZoomSetOptions
    • Syntax: neoPanZoomSetOptions "elementName" theMinScale theMaxScale theZoomWithWheel animationDuration theEasing theContain thePanOnlyWhenZoomed
      • theMinScale and theMaxScale: Define the zoom range.
      • theZoomWithWheel: Enable/disable zoom with the mouse wheel.
      • animationDuration and theEasing: Control zoom animation timing and easing.
      • theContain: Contain panning within element boundaries.
      • thePanOnlyWhenZoomed: Restrict panning to when zoomed in.

Example:

neoPanZoomSetOptions "imageContainer" 1 5 true 300 "ease" true true

This setup enables zooming up to 5x with wheel control, animated easing, and contained panning.

Pan and Zoom Controls

Additional commands manage specific pan and zoom interactions:

    • neoPanZoomSetPan: Sets pan coordinates directly.
    • neoPanZoomSetZoom: Sets zoom to a specified level.
    • neoPanZoomSetPanAndZoom: Combines pan and zoom adjustments in one command.

Example for Pan:

neoPanZoomSetPan "imageContainer" 100 150

This command pans to the coordinates (100, 150) within the container.

Locking Pan and Zoom Axes

For more control, the plugin offers axis locking:

    • neoPanZoomLockX and neoPanZoomLockY: Lock panning on the x or y axis.
    • neoPanZoomLockMouse: Disable mouse interactions for custom pan/zoom restrictions.

Practical Applications

The neoPanZoom plugin is suitable for:

    • Interactive Maps: Allowing users to navigate map content with smooth pan and zoom.
    • Image Exploration: Enhancing the user experience for detailed images or schematics.
    • Data Visualization: Enabling zooming in on specific data points within graphics or SVGs.

With flexible options for scaling, panning, and zooming, the neoPanZoom plugin is a valuable tool for creating interactive, user-friendly VisualNEO Web applications​​.

 

neoPanZoomInit

Purpose:

Initializes neoPanZoom plugin

Category:

neoPanZoom

Syntax:

neoPanZoomInit "elementName" startX startY theScale

 

elementName

Container or SVG element name

startX

Start X position (ie: 0)

startY

Start Y position (ie: 0)

theScale

Start scale factor (ie: 1)

 

neoPanZoomSetOptions

Purpose:

Set neoPanZoom plugin options

Category:

neoPanZoom

Syntax:

neoPanZoomSetOptions "elementName" theMinScale theMaxScale theZoomWithWheel animationDuration theEasing theContain thePanOnlyWhenZoomed

 

elementName

Container or SVG element name

theMinScale

Min scale (ie: 1)

theMaxScale

Max scale (ie: 5)

theZoomWithWheel

Allow mouse wheel zooming?

animationDuration

Duration of the transition (ms)

theEasing

Animation easing

theContain

Contain the panzoom element either inside or outside the parent.

thePanOnlyWhenZoomed

Disable panning while the scale is equal to the starting value

 

neoPanZoomSetPan

Purpose:

Pan the Panzoom element to the given x and y coordinates

Category:

neoPanZoom

Syntax:

neoPanZoomSetPan "elementName" posx posy

 

elementName

Container or SVG element name

posx

X pan

posy

Y pan

 

neoPanZoomSetPanRelative

Purpose:

Pan the Panzoom element to the given x and y relative to current position coordinates

Category:

neoPanZoom

Syntax:

neoPanZoomSetPanRelative "elementName" posx posy

 

elementName

Container or SVG element name

posx

X pan

posy

Y pan

 

neoPanZoomSetZoom

Purpose:

Zoom the Panzoom element to the given scale

Category:

neoPanZoom

Syntax:

neoPanZoomSetZoom "elementName" theZoom

 

elementName

Container or SVG element name

theZoom

Zoom factor

 

neoPanZoomSetPanAndZoom

Purpose:

Pan and Zoom the Panzoom element to the given x and y coordinates and zoom factor

Category:

neoPanZoom

Syntax:

neoPanZoomSetPanAndZoom "elementName" posx posy theZoom

 

elementName

Container or SVG element name

posx

X pan

posy

Y pan

theZoom

theZoom

 

neoPanZoomGetPanX

Purpose:

Get pan x displacement

Category:

neoPanZoom

Syntax:

neoPanZoomGetPanX "elementName" [panx]

 

elementName

Container or SVG element name

panx

Variable to store X pan

 

neoPanZoomGetPanY

Purpose:

Get pan y displacement

Category:

neoPanZoom

Syntax:

neoPanZoomGetPanY "elementName" [pany]

 

elementName

Container or SVG element name

pany

Variable to store Y pan

 

neoPanZoomGetZoom

Purpose:

Get the zoom factor

Category:

neoPanZoom

Syntax:

neoPanZoomGetZoom "elementName" [theZoom]

 

elementName

Container or SVG element name

theZoom

Variable to store zoom factor

 

neoPanZoomLockMouse

Purpose:

Locks mouse events.

Category:

neoPanZoom

Syntax:

neoPanZoomLockMouse "elementName"

 

elementName

Container or SVG element name

 

neoPanZoomLockX

Purpose:

Locks horizontal panning.

Category:

neoPanZoom

Syntax:

neoPanZoomLockX "elementName"

 

elementName

Container or SVG element name

 

neoPanZoomLockY

Purpose:

Locks vertical panning.

Category:

neoPanZoom

Syntax:

neoPanZoomLockY "elementName"

 

elementName

Container or SVG element name

Created with the Personal Edition of HelpNDoc: Make your documentation accessible on any device with HelpNDoc