All Projects → mobkits → images-preview

mobkits / images-preview

Licence: other
Images preview component for web pages on touch device.

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects
Makefile
30231 projects

Projects that are alternatives of or similar to images-preview

vue-active-preview
🌲 A PhotoSwipe Image Preview component for Vue
Stars: ✭ 22 (-35.29%)
Mutual labels:  previewimage
Hxphotopicker
图片/视频选择器 - 支持LivePhoto、GIF图片选择、3DTouch预览、在线下载iCloud上的资源、编辑图片/视频、浏览网络图片 功能 Imitation wx photo/image picker - support for LivePhoto, GIF image selection, 3DTouch preview, Download the resources on iCloud online, browse the web image function
Stars: ✭ 2,363 (+6850%)
Mutual labels:  previewimage

Images-preview

Images preview component for web pages on touch device.

Consider use imagebox for browser images on desktop browsers.

Visit demo with your phone

It's already used in production at jiangwoo

The standalone file could be ~12kb, if you use webpack and reuse components like tween, the increased file size could be much smaller.

Features

  • Swipe, pinchzoom and scroll (when necessary) event support.
  • Tap to show and hide.
  • Scale in and out current image with animation.
  • Min & max zoom limitation.
  • Src convert and loading effect for display original image.

Installation

npm install images-preview -S

Or use standalone file preview.js

Usage

Include style.css to your page.

For webpack user:

import ImagePreview from 'image-preview'
let imgs = document.querySelectorAll('img')
new ImagePreview(imgs)

For standalone file user:

// add standalone file to your html
<script type="text/javascript" src="preview.js"></script>
// create an instance 
var ImagesPreview = window.ImagesPreview.default;
new ImagesPreview(picture, {
    convert: function(src) {
      return src;
    }
  });

Events

  • show emitted on container shown.
  • hide emitted on container hide.
  • active emitted with index on active item change.

API

ImagePreview(imgs, [option])

Constructor for ImagePreview, when tap event is fired on one of imgs, a preview container is shown for user to swipe and/or pinchzoom.

  • imgs is original images collection.
  • option optional options.
  • option.convert a function used to return orignal image url from currentSrc of current image.
  • option.bind not bind tap event when === false

show()

hide()

Show/hide container.

.active(img, [idx], [animate])

Active a specfic image

  • img compressed image element.
  • idx index of img in image list (allows active image from img outside initialized images).
  • animate use animation if true.

.unbind()

Unbind tap event.

LICENSE

Copyright 2016 [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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].