You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.
Change the tool (one of none,pan,zoom-in,zoom-out,auto)
openMiniature
Open the miniature
closeMiniature
Close the miniature
Event attributes
To your event handlers will be passed an instance of ViewerMouseEvent or ViewerTouchEvent (as the case). They have some useful attributes that map event positions to SVG coords.
If, for your purpose, you need the original React event instance (SyntheticEvent), you can get it through event.originalEvent. You can't use event in async way, see React Event Pooling for more information.
Viewer Mouse Event
Property
Return
Description
originalEvent
SyntheticEvent
The original React event
SVGViewer
SVGSVGElement
Reference to SVGViewer
point
Object
Coordinates (x,y) of the event mapped to SVG coordinates
x
Number
x coordinate of the event mapped to SVG coordinates
y
Number
y coordinate of the event mapped to SVG coordinates
scaleFactor
Number
Zoom level
translationX
Number
x delta from the viewer origin
translationY
Number
y delta from the viewer origin
preventDefault()
-
alias originalEvent.preventDefault()
stopPropagation()
-
alias originalEvent.stopPropagation()
Viewer Touch Event
Property
Return
Description
originalEvent
SyntheticEvent
The original React event
SVGViewer
SVGSVGElement
Reference to SVGViewer
points
Array
Array with coordinates (x, y, identifier) of the touches mapped to SVG coordinates
changedPoints
Array
Coordinates (x, y, identifier) of the changed touches mapped to SVG coordinates
scaleFactor
Number
Zoom level
translationX
Number
x delta from the viewer origin
translationY
Number
y delta from the viewer origin
preventDefault()
-
alias originalEvent.preventDefault()
stopPropagation()
-
alias originalEvent.stopPropagation()
API
This is a list of components, functions and constants exported by the library.
import{//componentsReactSVGPanZoom,//Controlled componentUncontrolledReactSVGPanZoom,//Uncontrolled component//functions to manipulate the state. The signature is quite similar to component methods, expect for the first parameter that is the current value. These are usefull only for some advanced integrations (e.g. reducers). setPointOnViewerCenter,//setPointOnViewerCenter(value, SVGPointX, SVGPointY, zoomLevel)reset,//reset(value)pan,//pan(value, SVGDeltaX, SVGDeltaY)zoom,//zoom(value, SVGPointX, SVGPointY, scaleFactor)fitSelection,//fitSelection(value, selectionSVGPointX, selectionSVGPointY, selectionWidth, selectionHeight)fitToViewer,//fitToViewer(value, SVGAlignX = "left", SVGAlignY = "top")zoomOnViewerCenter,//zoomOnViewerCenter(value, scaleFactor)openMiniature,closeMiniature,//constantsMODE_IDLE,MODE_PANNING,MODE_ZOOMING,TOOL_AUTO,TOOL_NONE,TOOL_PAN,TOOL_ZOOM_IN,TOOL_ZOOM_OUT,POSITION_NONE,POSITION_TOP,POSITION_RIGHT,POSITION_BOTTOM,POSITION_LEFT,ACTION_ZOOM,ACTION_PAN,ACTION_AUTO_PAN,ALIGN_CENTER,ALIGN_LEFT,ALIGN_RIGHT,ALIGN_TOP,ALIGN_BOTTOM,ALIGN_COVER,INITIAL_VALUE}from'react-svg-pan-zoom'