Documentation Index
Fetch the complete documentation index at: https://mintlify.com/willnguyen1312/zoom-image/llms.txt
Use this file to discover all available pages before exploring further.
Overview
createZoomImageWheel enables zooming on images using mouse wheel scrolling, trackpad pinch gestures, and touch interactions. It supports pan & zoom, rotation, double-tap to zoom, and multi-touch gestures.
Function Signature
Parameters
The HTML element that contains the image to be zoomed. The function will automatically find the first
<img> element inside this container as the zoom target.Configuration options for the zoom behavior.
Maximum zoom scale allowed. The image cannot be zoomed beyond this value.
Zoom increment ratio per wheel scroll event. Higher values result in faster zooming.
Animation duration in milliseconds for the double-tap zoom transition.
Partial or full initial state. Useful for restoring a previous zoom state when re-initializing.
Predicate function to determine if zoom should be triggered on single touch actions. Return
false to disable single-touch zoom and pan.The element to apply zoom transformations to. Defaults to the first image element inside the container.
Return Value
Returns an object with the following methods:Removes all event listeners and cleans up the zoom instance. Call this when the component unmounts or when zoom functionality is no longer needed.
Subscribe to state changes. The listener function is called whenever the zoom state changes. Returns an unsubscribe function.
Programmatically update the zoom state. Use this to enable/disable zoom, change zoom level, or rotate the image.
Get the current zoom state including zoom level, position, rotation, and enabled status.
State Types
ZoomImageWheelState
ZoomImageWheelStateUpdate
Usage Examples
Basic Usage
With Custom Options
Subscribe to State Changes
Programmatic Control
Restore Previous State
Features
- Mouse wheel zoom: Scroll to zoom in/out at cursor position
- Pinch-to-zoom: Two-finger pinch gesture support on touch devices
- Double-tap zoom: Double-tap to zoom in/out with smooth animation
- Pan when zoomed: Click and drag to pan when image is zoomed
- Image rotation: Supports 0°, 90°, 180°, and 270° rotation
- Zoom limits: Automatically constrains pan to image boundaries
- Scroll lock: Disables page scrolling during zoom interactions
Related Types
- ZoomImageWheelOptions - Options type for wheel zoom
Source Reference
Implementation:/packages/core/src/createZoomImageWheel.ts:45