0.7.8 • Published 2 years ago

h5-imageviewer v0.7.8

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

H5 image viewer

Build Status Coverage Status node npm Maintainability

Image viewer for mobile browser, supported React/Vue/AngularJS.

Features

  • Supported rotate、pinch、move、swipe、scale and double tap gestures.
  • Page turning.
  • Supported landscape and portrait screen.
  • Supported React/Vue/AngularJS.
  • Scroll through long figure.

Demo

QRCODE
Image slider video
Portrait screen video
Landscape screen video

Install

You can install it via npm:

npm i h5-imageviewer

Or get it from CDN:

https://unpkg.com/h5-imageviewer@0.7.7/umd/h5-imageviewer.js

Usage

Show single image viewer

import * as viewer from 'h5-imageviewer'
viewer.showViewer(imgObj, options)
// hide image viewer
viewer.hideImgViewer()

Show image list viewer

import * as viewer from 'h5-imageviewer'
viewer.showImgListViewer(imgObjList, options)
// hide image list viewer
viewer.hideImgListViewer()

Please check EXAMPLE1 or EXAMPLE2 for detail.

Apis

Show single image viewer(viewer.showViewer(imgObj, options))

PropertyTypeDefaultRequiredDescription
imgObj.srcstringyesimg src attr (base64 also supported)
imgObj.altstringnoimg alt attr
options.errorPlhstringnoplaceholder when image onerror
options.onViewerHideListenerfunction()nolistener for viewer hide
options.restDomsarraynothe attach dom array
options.imgMoveFactornumber1.5nomovement speed (imgMoveFactor * translateX or translateY)
options.imgMinScalenumber1nominimum scale of the image
options.imgMaxScalenumber2nomaximum scale of the image
options.zIndexnumber999nothe viewer z-index
options.viewerBgstring#000000nothe viewer background
options.clickClosablebooleantruenohide the viewer if click

Show image list viewer(viewer.showImgListViewer(imgObjList, options))

PropertyTypeDefaultRequiredDescription
imgObj.srcstringyesimg src attr (base64 also supported)
imgObj.altstringnoimg alt attr
options.defaultPageIndexnumber0nodefault page index
options.errorPlhstringnoplaceholder when image onerror
options.onViewerHideListenerfunction()nolistener for viewer hide
options.restDomsarraynothe attach dom array
options.imgMoveFactornumber1.5nomovement speed (imgMoveFactor * translateX or translateY)
options.imgMinScalenumber1nominimum scale of the image
options.imgMaxScalenumber2nomaximum scale of the image
options.zIndexnumber999nothe viewer z-index
options.viewerBgstring#000000nothe viewer background
options.onPageChangedfunction(pageIndex)nothe page changed listener
options.limitnumber5nohow many pages will be kept offscreen in an idle state
options.pageThresholdnumber0.1nothreshold of go to next or prev page (window.innerWidth * pageThreshold)
options.pageDampingFactornumber0.9nodamping factor
options.clickClosablebooleantruenohide the viewer if click

Dependencies

License

This content is released under the MIT License.

0.7.8

2 years ago

0.7.6

3 years ago

0.7.7

3 years ago

0.7.4

3 years ago

0.7.3

3 years ago

0.7.5

3 years ago

0.7.2

3 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.9

4 years ago

0.6.8

4 years ago

0.6.7

4 years ago

0.6.6

4 years ago

0.6.5

5 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.9

5 years ago

0.4.8

5 years ago

0.4.7

5 years ago

0.4.6

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago