Skip to content

Zoom Image Component

Overview

The ZoomImg component allows users to zoom into an image within its original container. You can choose between two interaction modes: move-based zooming where the image follows the cursor position, or drag-based zooming where users can freely drag the zoomed area. The component supports click and hover triggers, customizable zoom scales, and more.

Basic Usage

Move

vue
<ZoomImg
  class="h-[30rem]"
  zoom-type="move"
  trigger="click"
  :src="imageSrc"
  :zoom-scale="3"
/>

Drag

vue
<ZoomImg
  class="h-[30rem]"
  zoom-type="drag"
  trigger="click"
  :src="imageSrc"
  :zoom-scale="3"
/>

Note

You can explore zoom controls such as buttons for managing zoom levels and a zoom map for navigating the image. To see these features in action, visit this link. Zoom Controllers

Multi Step Zoom

The Multi-Step Zoom feature allows users to zoom in and out with multiple clicks. You can set the step prop to control how much the zoom level changes each time. Starting at a scale of 1x, each click increases the zoom until the maximum level zoomScale. Clicking again at maximum zoom decreases the level in the same increments, smoothly cycling between the default and maximum zoom.

vue
<ZoomImg class="h-[30rem]" :src="imageSrc" :zoom-scale="5" :step="1" />

Note

Multi zoom is disabled by default. To enable it, provide a value to the step prop which accepts any number, including fractions.

Props and Events

Props

NameTypeDefaultDescription
srcStringrequiredThe source URL of the image to be zoomed.
zoomScaleNumber2The desired zoom scale of the image.
trigger"click" | "hover""click"The event that triggers the zoom functionality, either "click" or "hover".
zoomType"move" | "drag""move"The type of zoom interaction, either "move" or "drag".
stepNumber-The step value for the zoom scale.
persistBooleanfalseWhether the zoom state should persist on mouse leave.
showZoomBtnsBooleanfalseShow controls to increase or decrease the zoom scale from buttons.
showImgMapBooleanfalseWhether to display the image map overlay.

Events

NameDescription
loadTriggered when the image has successfully loaded.
errorTriggered when there is an error loading the image.

Released under the MIT License.