All Projects → newming → view-bigimg

newming / view-bigimg

Licence: MIT license
a pure javascript library to view image and support touch, pinch and mousewheel

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to view-bigimg

Imageviewer
A simple and customizable Android full-screen image viewer 一个简单且可自定义的Android全屏图像浏览器
Stars: ✭ 1,889 (+10394.44%)
Mutual labels:  imageviewer
Stfalconimageviewer
A simple and customizable Android full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" gestures
Stars: ✭ 1,734 (+9533.33%)
Mutual labels:  imageviewer
SwiftyBase
SwiftyBase - A Swift library for Create Project in iOS ( Base Project)
Stars: ✭ 33 (+83.33%)
Mutual labels:  imageviewer

view-bigimg

a pure library for zooming and panning your web images

demo

Features

  • Support touch devices
  • Smooth dragging and panning images
  • Pinch in / Pinch out to zoom in/ zoom out

How to use

A. with inline script

<link rel="stylesheet" href="view-bigimg.css">
<script src="view-bigimg.js"></script>
<script>
  var viewer = new ViewBigimg()

  var wrap = document.getElementById('wrap')
  wrap.onclick = function (e) {
    if (e.target.nodeName === 'IMG') {
      viewer.show(e.target.src.replace('.jpg', '-big.jpg'))
    }
  }
</script>

B. with npm

npm i view-bigimg
import 'view-bigimg/lib/view-bigimg.css'
import ViewBigimg from 'view-bigimg'

var viewer = new ViewBigimg
viewer.show(imgsrc)

API

  • new ViewBigimg(options)
    • show(imgsrc)
    • destroy()

new ViewBigimg(options)

Creates an instance of ViewBigimg

Param Type Default Description
options Object {} options
options.zoomValue Number 100 default zoom size
options.maxZoom Number 500 maxium zoom size
options.refreshOnResize Boolean true whether refresh when window resize, default is true
options.zoomOnMouseWheel Boolean true enable mousewheel to zoom images
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].