Mobile JS photo preview plug-in supports rotation and zoom (two fingers / double click), and comfort and smoothness is the biggest pursuit.
ImagePreview is an iOS-style, mobile-first, super smooth image viewer written in JavaScript.
Features:
- Zoom in / out with fingers.
- Allows you to rotate images.
- Switch between images with a swipe.
Must Read: A Simple File Upload That Shows A Preview of the Uploaded Image
How to make use of it:
1. Download and import the imagePreview
JavaScript library.
<script src="./release/image-preview/image-preview-iife.js"></script>
// OR as an ES module import {ImagePreview} from './release/image-preview/image-preview-esm.js'
2. Initialize the ImagePreview in your photographs.
<div class="gallery"> <img data-src="large.jpg" src="small.jpg" alt="Image 1" /> <img data-src="large.jpg" src="small.jpg" alt="Image 2" /> <img data-src="large.jpg" src="small.jpg" alt="Image 3" /> ... </div>
new imagePreviewModule.ImagePreview({ selector:'.gallery img' })
3. Or add photographs to the image viewer through JavaScript.
let imgViewer = new ImagePreview({ curImg:'current.jpg', imgs:[ '1.jpg', '2.jpg', '3.jpg' ] }) // then show an image imgViewer.show(1);
4. Destroy.
imgViewer.destroy();
API
new ImagePreview({imgs?: Array<string|HTMLImageElement>})
new ImagePreview({selector?: string})
Generate an ImagePreview instance.imagePreview.prototype.show(index:number)
Open index-th img on imagepreivew, index starts from 0.imagePreview.prototype.insertImageAfter( image: string | HTMLImageElement , index: number )
Insert a new image after the index, if the index < 0, then a new image will be inserted at the 0 positions. If the index is greater than imgs’ length, the new image will be inserted in the last position.- Note: If the param image is HTMLImageElement, and it is cross-origin, you’d better set the crossOrigin attribute.
imagePreview.prototype.delImage(index:number)
Delete index-th image. The index below 0 is 0, and greater than imgs’s length will be set to the last index.imagePreview.prototype.destroy()
Destroy image preview instance. Remove HTML generated by this ImagePreview instance and other resources. For better performance, then you can set imgObj = null;
See Demo And Download

Official Website(daxiazilong): Click Here
This superior jQuery/javascript plugin is developed by daxiazilong. For extra Advanced usage, please go to the official website.