Installation
Available Hooks
The Qwik adapter exports four hooks, one for each zoom mode:useZoomImageWheel- Zoom with mouse wheel/pinch gesturesuseZoomImageHover- Zoom on hover with a separate zoom targetuseZoomImageMove- Zoom follows mouse/touch movementuseZoomImageClick- Toggle zoom on click
Hook Return Values
Each hook returns an object with:createZoomImage- QRL function to initialize zoom on a container elementzoomImageState- Reactive state store (varies by zoom mode)setZoomImageState- QRL function to update state (available for wheel and hover modes)
Wheel Zoom
Zoom in and out using the mouse wheel or pinch gestures. Supports programmatic zoom control, rotation, and image cropping.Basic Example
Complete Example with Controls
State Properties
currentZoom: number- Current zoom level (1 = 100%)enable: boolean- Whether zoom is enabledcurrentPositionX: number- X position offsetcurrentPositionY: number- Y position offsetcurrentRotation: number- Rotation angle in degrees
Hover Zoom
Display a zoomed version in a separate container when hovering over the image.Basic Example
State Properties
enabled: boolean- Whether hover is activezoomedImgStatus: string- Loading status (“idle” | “loading” | “loaded”)
Move Zoom
Zoom follows the mouse or touch movement within the image container.Basic Example
State Properties
zoomedImgStatus: string- Loading status (“idle” | “loading” | “loaded”)
Click Zoom
Toggle between zoomed and normal states by clicking the image.Basic Example
State Properties
zoomedImgStatus: string- Loading status (“idle” | “loading” | “loaded”)
TypeScript Support
All hooks are fully typed. Import types from@zoom-image/core:
Qwik-Specific Features
QRL Functions
ThecreateZoomImage and setZoomImageState functions are wrapped with Qwik’s $() optimizer, making them serializable for resumability.
useStore vs useSignal
The adapter usesuseStore for state management, which creates a reactive proxy object. You can access properties directly:
Serialization
The zoom instance is marked withnoSerialize() to prevent serialization since it contains DOM references and event handlers that cannot be serialized.
Cleanup
Cleanup is automatically handled usinguseVisibleTask$ cleanup callback. The zoom instance is destroyed when the component is removed from the DOM.