GithubHelp home page GithubHelp logo

kuiyouli / v-photoswipe Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leesson/v-photoswipe

0.0 1.0 0.0 654 KB

Vue plugin for image preview base on PhotoSwipe

License: MIT License

HTML 2.80% JavaScript 32.00% Vue 65.20%

v-photoswipe's Introduction

Vue PhotoSwipe

npm

PhotoSwipe, PhotoSwipeGallery component for Vuejs base on PhotoSwipe.

Installation

NPM

  npm install --save v-photoswipe  

Usage

Template

<template>
  <div>
    <div class="paragraph">
      <h3>PhotoSwipe</h3>
      <div>
        <img @click="showPhotoSwipe(0)" src="https://farm4.staticflickr.com/3894/15008518202_c265dfa55f_h.jpg" alt="">
        <img @click="showPhotoSwipe(1)" src="https://farm4.staticflickr.com/3902/14985871946_24f47d4b53_h.jpg" alt="">
      </div>
    </div>
    <div class="paragraph">
      <h3>PhotoSwipe Gallery</h3>
      <div>
        <v-photoswipe-gallery :isOpen="isOpenGallery" :options="optionsGallery" :items="items">
          <img slot-scope="props" :src="props.item.src" alt="picture"/>
        </v-photoswipe-gallery>
      </div>
    </div>
    <v-photoswipe :isOpen="isOpen" :items="items" :options="options" @close="hidePhotoSwipe"></v-photoswipe>
  </div>
</template>  

JS

import { PhotoSwipe, PhotoSwipeGallery } from 'v-photoswipe'
export default {
  components: {
    'v-photoswipe': PhotoSwipe,
    'v-photoswipe-gallery': PhotoSwipeGallery
  },
  data () {
    return {
      isOpen: false,
      isOpenGallery: false,
      options: {
        index: 0
      },
      optionsGallery: {},
      items: [
        {
          src: 'https://farm4.staticflickr.com/3894/15008518202_c265dfa55f_h.jpg',
          w: 1600,
          h: 1600,
          title: 'This is dummy caption.'
        }, {
          src: 'https://farm4.staticflickr.com/3902/14985871946_24f47d4b53_h.jpg',
          w: 1600,
          h: 1066,
          title: 'This is dummy caption. It has been placed here solely to demonstrate the look and feel of finished, typeset text.'
        }
      ]
    }
  },
  methods: {
    showPhotoSwipe (index) {
      this.isOpen = true
      this.$set(this.options, 'index', index)
    },
    hidePhotoSwipe () {
      this.isOpen = false
    }
  }
}  

Props

PhotoSwipe & PhotoSwipeGallery

Name Type Default Required Description
isOpen Boolean false true
items Array [] true Document
options Object {} fasle Document
beforeChange Function Photoswipe event listener
afterChange Function Photoswipe event listener
imageLoadComplete Function Photoswipe event listener
resize Function Photoswipe event listener
gettingData Function Photoswipe event listener
mouseUsed Function Photoswipe event listener
initialZoomIn Function Photoswipe event listener
initialZoomInEnd Function Photoswipe event listener
initialZoomOut Function Photoswipe event listener
initialZoomOutEnd Function Photoswipe event listener
parseVerticalMargin Function Photoswipe event listener
close Function Photoswipe event listener
unbindEvents Function Photoswipe event listener
destroy Function Photoswipe event listener
updateScrollOffset Function Photoswipe event listener
preventDragEvent Function Photoswipe event listener
shareLinkClick Function Photoswipe event listener

Slot

PhotoSwipeGallery

Name Type Default Required Description
item Object HTML Img Tag false

Demo

coming soon...

v-photoswipe's People

Contributors

leesson avatar

Watchers

James Cloos 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.