Pan and zoom SVG viewbox with redux.
https://reviz.github.io/redux-svg/
see example/src/ for the source
Initialize viewport
size and viewBox
size.
width
: (Number
) - the viewport widthheight
: (Number
) - the viewport height
Pan to given coordinates.
x
: (Number
)y
: (Number
)
Pan by the direction vector between {x, y} and previous
point.
use to pan with mouse drag
x
: (Number
)y
: (Number
)previous
: (Number
)x
: (Number
)y
: (Number
)
Pan to given coordinates.
x
: (Number
)y
: (Number
)
Reset pan.
Center the viewbox.
Relatively zoom by given scale.
scale
: (Number
)
Helper action that take mouse input to compute the scale.
e
: (WheelEvent
)timeDelta
: (Number
) time passed since the last mouse wheel event
Reset zoom to 1.
Allow pan usage.
Forbid pan usage.
Allow zoom usage.
Forbid zoom usage.
Reset pan and zoom.
Simply clone the repo, npm install, and run npm test.
- Understanding SVG Coordinate Systems by @SaraSoueidan
- svg-pan-zoom by @ariutta
- ducks-modular-redux