Try to use gestures with this image 👆
Introduction
@beoe/pan-zoom
↗ is a small client-side script that adds pan and zoom capabilities to SVG images (or any DOM node, actually).
There are many similar scripts, but the main difference is that this one supports gestures for all types of devices:
Intention | Mouse | Trackpad/Touchpad | Touchscreen |
---|
Pan | Click + move | Click + move | Two-finger drag |
Zoom | Ctrl + wheel | Pinch | Pinch |
Reset | Double click | Double click | Double tap |
| | | |
Scroll | Wheel | Two-finger drag | One-finger drag |
Pay attention to the following:
- Gestures are intentionally selected to avoid interfering with the system’s default scroll gestures, to prevent “scroll traps.”
- Cmd + click - zoom in.
- Alt + click - zoom out.
- The first double click (or tap) - zooms in by 2x.
Installation
-
Install dependencies
-
Add svgpanzoom.ts
-
Use svgpanzoom.ts
in the base layout
Starlight specific code
-
Use svgpanzoom.ts
in the PageFrame
-
Override PageFrame
in Astro config