Smooth Zoom is a lightweight javascript library for enlarging images like Medium, and Google Photos, which displays images at a large size just like you saw it on Medium.com.
Features:
- Smooth transitions.
- Automatically adjust the background color based on the average color of the image.
- Zoom in on the high-resolution picture provided.
How to make use of it:
1. Install the package deal.
# Yarn $ yarn add smooth-zoom # NPM $ npm i smooth-zoom
2. Import the Zoom.js as an ES module.
import Zoom from "smooth-zoom";
3. Directly load the JavaScript file from a CND.
<script src="https://cdn.jsdelivr.net/npm/smooth-zoom/dist/zoom.browser.js"></script>
4. Initialize the library on target pictures and complete them.
<img src="1.jpg" class="zoomable" alt="Image Alt" />
Zoom(".zoomable");
5. Determine the background colour of the picture.
Zoom(".zoomable",{ background: "auto" });
6. Replace the picture supply when the picture is opened.
Zoom(".zoomable",{ originalizer: (src) => src.replace(/-[0-9]+\.jpg/, ".jpg"), });
Property | Type | Default | Description |
---|---|---|---|
background | string | rgba(0, 0, 0, 0.95) | Image’s background color. Use auto to get the average color of the image |
useMaximumSize | boolean | true | Find the longest width through the image’s natural width and srcset attribute |
onClick | (img: HTMLImageElement) => void | undefined | A function that fires on click. Note that IMG is the original image element. |
onTransitionEnd | (img: HTMLImageElement) => void | undefined | A function that fires after zoom animation. Note that the image is cloned image element. |
Tiny Smooth Image Zoom Library Inspired By Medium.com, Smooth Zoom Plugin/Github
See Demo And Download
Official Website(marshall-ku): Click Here
This superior jQuery/javascript plugin is developed by marshall-ku. For extra Advanced usage, please go to the official website.