Installation
Available Hooks
The Svelte adapter exports four hooks that correspond to different zoom behaviors:useZoomImageWheel- Zoom with mouse wheeluseZoomImageHover- Zoom on hover with separate zoom targetuseZoomImageMove- Zoom on mouse moveuseZoomImageClick- Zoom on click
useZoomImageWheel
Enables zooming with mouse wheel/trackpad scrolling.API
State
Example
useZoomImageHover
Displays a zoomed version in a separate container when hovering over the image.API
State
Example
useZoomImageMove
Zooms the image as the mouse moves over it.API
State
Example
useZoomImageClick
Toggles zoom when clicking on the image.API
State
Example
Cleanup
All hooks automatically handle cleanup when the component is destroyed using Svelte’sonDestroy lifecycle hook. The cleanup removes event listeners and frees resources.
TypeScript Support
The Svelte adapter is written in TypeScript and provides full type definitions. Import types from@zoom-image/core:
Related
- createZoomImageWheel - Core wheel zoom function
- createZoomImageHover - Core hover zoom function
- createZoomImageMove - Core move zoom function
- createZoomImageClick - Core click zoom function
- React Adapter - React implementation
- Vue Adapter - Vue implementation