Installation
Available Hooks
The Preact 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 unmounts using theuseEffect hook. The cleanup removes event listeners and frees resources.
Combining Multiple Zoom Types
You can combine multiple zoom behaviors in a single component:TypeScript Support
The Preact 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
- Svelte Adapter - Svelte implementation