GithubHelp home page GithubHelp logo

tubb / h5-imageviewer Goto Github PK

View Code? Open in Web Editor NEW
13.0 1.0 5.0 18.45 MB

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

License: MIT License

HTML 7.72% JavaScript 88.98% Less 3.30%
alloyfinger gallery-viewer gallery-images mobile-web slider slider-component image-slider

h5-imageviewer's Introduction

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/[email protected]/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))

Property Type Default Required Description
imgObj.src string yes img src attr (base64 also supported)
imgObj.alt string no img alt attr
options.errorPlh string no placeholder when image onerror
options.onViewerHideListener function() no listener for viewer hide
options.restDoms array no
options.imgMoveFactor number 1.5 no movement speed (imgMoveFactor * translateX or translateY)
options.imgMinScale number 1 no minimum scale of the image
options.imgMaxScale number 2 no maximum scale of the image
options.zIndex number 999 no the viewer z-index
options.viewerBg string #000000 no the viewer background
options.clickClosable boolean true no hide the viewer if click

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

Property Type Default Required Description
imgObj.src string yes img src attr (base64 also supported)
imgObj.alt string no img alt attr
options.defaultPageIndex number 0 no default page index
options.errorPlh string no placeholder when image onerror
options.onViewerHideListener function() no listener for viewer hide
options.restDoms array no
options.imgMoveFactor number 1.5 no movement speed (imgMoveFactor * translateX or translateY)
options.imgMinScale number 1 no minimum scale of the image
options.imgMaxScale number 2 no maximum scale of the image
options.zIndex number 999 no the viewer z-index
options.viewerBg string #000000 no the viewer background
options.onPageChanged function(pageIndex) no the page changed listener
options.limit number 5 no how many pages will be kept offscreen in an idle state
options.pageThreshold number 0.1 no threshold of go to next or prev page (window.innerWidth * pageThreshold)
options.pageDampingFactor number 0.9 no damping factor
options.clickClosable boolean true no hide the viewer if click

Dependencies

License

This content is released under the MIT License.

h5-imageviewer's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

h5-imageviewer's Issues

在react中调用,图片消失时会报错,请问该如何解决?

bundle.js:1 Uncaught TypeError: Cannot read property 'childNodes' of undefined at pe (bundle.js:1) at multipointEndListener (bundle.js:1) at HTMLDivElement.multipointEnd (bundle.js:1) at HandlerAdmin.dispatch (alloy_finger.js:57) at AlloyFinger.end (alloy_finger.js:224) pe @ bundle.js:1 multipointEndListener @ bundle.js:1 multipointEnd @ bundle.js:1 HandlerAdmin.dispatch @ alloy_finger.js:57 end @ alloy_finger.js:224 Wave.js:31 image list viewer hide
在react中调用,图片消失时会报错,请问该如何解决?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.