Giter Club home page Giter Club logo

vue-previewer's Introduction

vue-previewer

๐Ÿ‘€ A vue component for previewing images

Live Demo

>> Live Demo

Features

  • no other dependencies
  • support zoom-in, zoom-out, rotate, fullscreen operations
  • support image events such as select, close
  • support customer options
  • support key operation
  • support footer slot

Install

// with yarn
yarn add vue-image-previewer
// with npm
npm install vue-image-previewer

Usage

import VuePreviewer from 'vue-image-previewer'

// defalut install
Vue.use(VuePreviewer);

// install with global options
Vue.use(VuePreviewer, {
  defaultWidth: '100px',
  defaultHeight: '75px',
  thumbnailStyle: {
    backgroundSize: 'cover'
  },
  keyMap: {
    zoomin: '+',
    zoomout: '-',
    rotate: 'r',
    prev: 'ArrowLeft',
    next: 'ArrowRight'
  }
})

Example

new Vue({
  el: '#app',
  components: { VuePreviewer },
  data() {
    return {
      imgs: [
        'http://pic.lvmama.com/uploads/pc/place2/2016-09-14/9aab9bb7-2593-4ca6-8c5a-31355443aebc.jpg',
        'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQJQQM7xWSl3uRGecETNjaLl8_2wmAvlGpwyzX_Xs3RyZoTsM_j',
        "http://crawl.nosdn.127.net/d426f0175b974f7cce092a8f16d0ee09.jpg",
        "http://seopic.699pic.com/photo/50093/5337.jpg_wh1200.jpg"
      ]
    }
  },
  template: '<vue-previewer :images="imgs" :options="{}"/>'
})

Props

Property Type Description Default
images Array[String/ImageOptions] Images for previewing required
options PreviewerOptions Extra options for configing component {}
mode "image", "link" show image as link or image "image"
showFooter Boolean Footer slot true

ImageOptions

{
	src: 'xxx.jpg', // origin image source
  thumbnailSrc: 'xxxThumbnail.jpg', // thumbnail source
	width: '100px', // thumbnail width
	height: '75px', // thumbnail height
	name: 'Image Test' // Image name which shows in footer
}

PreviewerOptions

// default options
{
	defaultWidth: '100px', // thumbnail width, '100px' or '20%'
	defaultHeight: '75px', // thumbnailStyle height, '100px' or '20%'
	thumbnailStyle: { backgroundSize: 'cover' },
  keyMap: {
    zoomin: '+',
    zoomout: '-',
    rotate: 'r',
    prev: 'ArrowLeft',
    next: 'ArrowRight'
  }
}

Events

Event Description Parameters
close Trigger when component is closed
select Trigger when select a image from list Selected image(ImageOptions)

slot

Name Parameters
footer Current ImageOptions

๐Ÿค— Please feel free to contribute a PR or make an issue

License

VuePreviewer is MIT Licensed.

Copyright (c) 2019 Geass

vue-previewer's People

Contributors

nullptru avatar dependabot[bot] avatar

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.