A couple of simple components for displaying content with pan and zoom capabilities.
- Pan and zoom capabilities
- Works with any HTML element
- Supports mouse and touchscreen interactions
https://svelte-image-viewer.vercel.app/
msedge_jx2Xc9iyyG.mp4
Screen_Recording_20240928_130651_Chrome.2.mp4
npm install svelte-image-viewer
pnpm add svelte-image-viewer
bun add svelte-image-viewer
The ImageViewer
component is a simple image viewer that displays an image with pan and zoom capabilities.
<script>
import { ImageViewer } from "svelte-image-viewer";
</script>
<div
style="position: relative; height: 512px; user-select: none; border: 1px solid white;"
>
<ImageViewer src="https://picsum.photos/256" />
</div>
The Viewer
component displays its children inside a container with pan and zoom capabilities.
<script>
import { Viewer } from "svelte-image-viewer";
</script>
<div
style="position: relative; height: 512px; user-select: none; border: 1px solid white;"
>
<Viewer>
<img src="https://picsum.photos/256" alt="" />
</Viewer>
</div>
If you find this project useful, consider supporting it by buying me a coffee:
Your support is appreciated. Thank you!