Socket
Socket
Sign inDemoInstall

img-previewer

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    img-previewer

A light wight javascript image viewing plugin with smooth animation


Version published
Weekly downloads
11
decreased by-15.38%
Maintainers
1
Install size
65.2 kB
Created
Weekly downloads
 

Readme

Source

Img-previewer Js

Lightweight and powerful javascript image preview plug-in, silky animation allows you to elegantly preview the images in your website. Out of the box, you don't need extra configuration (by default) or change the page html code structure, you can easily enable the plugin in any type of website and upgrade your user experience

These functions are provided:

  1. Silky, interruptible transition animation
  2. Use mouse wheel to zoom picture
  3. Icon drag picture
  4. Previous & Next
  5. Shortcut key support
  6. Support for mobile gestures (zoom in with two fingers)
  7. Multi-language internationalization support
  8. Picture loading monitor

Other languages: English, Simplified Chinese.

tips: For performance reasons, the mobile terminal does not do swiper

Example

Preview

how to use

NPM

npm i img-previewer
# or
yarn add img-previewer

CDN

<script src="https://cdn.jsdelivr.net/npm/img-previewer@1.0.1/dist/img-previewer.min.js"></script>

Enable

//js
import ImgPreviewer from'img-previewer'
//css
import'img-previewer/dist/index.css'

const imgpreviewer = new ImgPreviewer(css selector,{options...})

Property list

TypeDescriptionDefault Value
fillRationumberThe proportion of the image that fills the preview area0.9(90%)
dataUrlKeystringThe key of the image address valuesrc
imageZoomobjectZoom image configuration{min: 0.1,max: 5,step: 0.1}
styleobjectStyle configuration{modalOpacity: 0.6,headerOpacity: 0,zIndex: 99}
i18nobjecttooltips International configurationzh_cn or es

options.imageZoom

DescriptionDefault value
minMinimum zoom ratio0.1(10%)
maxMaximum zoom ratio5(500%)
stepThe change ratio of the scroll wheel each time0.1

options.style

DescriptionDefault value
modalOpacityPreview area mask transparency0.6
headerOpacityToolbar transparency0
zIndexLevel of plug-in rendering99

options.i18n

Simplified Chinese and English are supported by default, others need to be configured by themselves

Description
RESETReset
ROTATE_LEFTRotate Left
ROTATE_RIGHTRotate right
CLOSEClose preview
NEXTNext
PREVPrevious

hot key

ButtonDescription
EscClose preview
<=Previous
=>Next

Update picture

Some dynamically updated picture lists use

const a = new ImgPreviewer('body')
// Called after the image is rendered on the page
a.update()

Keywords

FAQs

Last updated on 27 Dec 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc