ZoomImageClickOptions type defines the configuration options for creating a click-based zoom interface where users click to activate zoom and move their cursor to pan the zoomed image.
Type Definition
Properties
The magnification level for the zoomed image. This determines how much larger the image appears when zoomed.Example:
URL of a higher resolution image to use for the zoomed view. If not provided, uses the source image’s
src attribute.This allows you to display a smaller preview image for performance while showing a high-resolution version when zoomed.Example:Whether to disable automatic scroll locking when the container is active. By default, scroll is locked on
pointerenter and unlocked on pointerleave to prevent accidental page scrolling during zoom interaction.Set to true to allow normal page scrolling even when the cursor is over the zoom container.Example:Additional HTML attributes to apply to the zoomed image element.Properties:
alt?: string- Alternative text for the zoomed image (for accessibility)
Related Types
ZoomImageClickState
The internal state managed by the click zoom component:ZoomedImgStatus
idle- Not yet started loadingloading- Image is currently loadingloaded- Image has loaded successfullyerror- Image failed to load
Usage Example
Interaction Flow
Click to Zoom
- First click: Activates zoom mode at the cursor position
- Mouse move: Pans the zoomed image while in zoom mode
- Second click: Deactivates zoom mode and returns to normal view
Visual Feedback
The zoomed image:- Is positioned absolutely within the container
- Starts hidden (
display: none) - Becomes visible when zoom is activated
- Follows cursor movement via CSS transforms
Boundary Constraints
The zoomed image position is automatically constrained:- Cannot pan beyond image edges
- Uses
calculatePositionXandcalculatePositionYto clamp values - Prevents showing empty space outside the image boundaries
Behavior Details
Scroll Lock
WhendisableScrollLock is false (default):
- Scroll is locked when pointer enters the container
- Scroll is unlocked when pointer leaves the container
- On
touchendevents, scroll is always re-enabled
Pointer Events
The component responds to standard pointer events:pointerdown- Toggles zoom on/offpointermove- Pans the image when zoom is activepointerenter- Locks scroll (if enabled)pointerleave- Unlocks scroll (if enabled)
Common Use Cases
E-commerce Product Images
Image Galleries
Documentation or Tutorial Images
Mobile-Friendly Implementation
Comparison with Other Zoom Types
| Feature | Click | Move | Hover | Wheel |
|---|---|---|---|---|
| Activation | Click | Pointer enter | Pointer enter | Wheel/Pinch |
| Zoom location | In-place | In-place | Separate target | In-place |
| Panning | Move cursor | Move cursor | Automatic | Drag |
| Mobile-friendly | Yes | Yes | No | Yes |
| Use case | Interactive images | Quick preview | Product details | Maps, diagrams |
See Also
- createZoomImageClick - Function that uses these options
- ZoomImageWheelOptions - Options for wheel-based zoom
- ZoomImageHoverOptions - Options for hover-based zoom
- ZoomImageMoveOptions - Options for move-based zoom