Home

Awesome

License: MIT build

<div align="center"> <img src="https://github.com/fchancel/v-image-magnifier/blob/main/examples/logo.png?raw=true"/> </div>

v-image-magnifier

A Vue 3 plugin that provides interactive image zoom functionality. Allow users to zoom in on an image by hovering over it, providing an enlarged view of the corresponding part of the image.

Installation

To install v-image-magnifier, run the following command:

npm install --save v-image-magnifier

Options

OptionTypeDefaultDescriptionRequired
altImagestringValue for the alt attribute of the image.
backgroundColorstring"#ffff"Image background color (Visible when zooming in on an image border).
boxShadowstring"0 5px 10px -2px rgba(0, 0, 0, 0.5)"Magnifying glass shadow style.
cursorNonebooleantrueHides the cursor in the middle of the magnifying glass.
deactivatebooleanfalseDisables the magnifying glass system (Allows the image to be displayed normally).
fitContentbooleantrueAllows you to specify whether the size of the box containing the image should automatically adapt to the size of the image. When this option is enabled (true), the box will have a width and height equal to the size of the image. When disabled (false), the box will have a width of 100% and a height of 100% of its container, and the image will be resized to fit this size.
imgClassstringA CSS class that will be placed on the image.
magnifiedBorderRadiusnumber50The radius of the magnifying glass.
magnifiedBorderSizenumber4The border size of the magnifying glass.
magnifiedBorderColorstring"#ffff"The amount of blur to apply to the element.
magnifiedBorderStylestring"solid"The border style of the magnifying glass (Solid, dotted, double...)
magnifiedTransitionstring"opacity 0.2s"Transition effect to be applied when the magnifying glass enters the image.
srcstringsource of the image to display.
zIndexnumber99z-index of the magnifying glass.
zoomSizenumber100Size of the magnifying glass.
zoomFactornumber1.8Zoom factor (Allows you to manage the power of the zoom).

Events

NameDescription
loadedEvent sent when the image is fully loaded by the browser

Usage

Global Usage

To use VImageMagnifier globally in your Vue.js application, you can install it using app.use in the entry point of your main application file.

import { createApp } from "vue";
import VImageMagnifier from "v-image-magnifier";

const app = createApp(App);
app.use(VImageMagnifierPlugin, {
         // Change options here
         zoomSize: 150,
         zoomFactor: 2,
         // ...
    });
app.mount("#app");

By passing an options object to app.use, you can customize the behavior of VImageMagnifier. In the example above, the zoomFactor option is set to 2, which increases the zoom level, and the zoomSize option is set to 150 for a bigger magnifying glass.

These options will be applied globally to all instances of the VImageMagnifier component in your application.

Example Usage

<template>
  <VImageMagnifier 
      src="path/to/my/file.png"
      :zoomSize="200
      :zoomFactore="2"
      :magnifiedBorderRadius="5"
   />
</template>

Example

Demo GIF of Magnifier

Demo GIF of Magnifier

Demo GIF of Magnifier

Contributing

Contributions, issues and feature requests are welcome! Feel free to check the issues page or create a pull request.

License

v-image-magnifier is licensed under the MIT License. See the LICENSE file for more information.