Installation
Available Primitives
The Solid adapter exports four primitives, 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
Primitive Return Values
Each primitive returns an object with:createZoomImage- Function to initialize zoom on a container elementzoomImageState- Reactive state store (varies by zoom mode)setZoomImageState- 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 primitives are fully typed. Import types from@zoom-image/core:
Reactive Stores
ThezoomImageState returned by each primitive is a reactive store created with Solid’s createStore. You can access properties directly in your JSX and Solid will automatically track dependencies:
Cleanup
All primitives automatically clean up on component unmount using Solid’sonCleanup lifecycle function.