1.0.3-1 • Published 5 years ago

v-photoswipe v1.0.3-1

Weekly downloads
705
License
MIT
Repository
github
Last release
5 years ago

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

NameTypeDefaultRequiredDescription
isOpenBooleanfalsetrue
itemsArray[]trueDocument
optionsObject{}fasleDocument
beforeChangeFunctionPhotoswipe event listener
afterChangeFunctionPhotoswipe event listener
imageLoadCompleteFunctionPhotoswipe event listener
resizeFunctionPhotoswipe event listener
gettingDataFunctionPhotoswipe event listener
mouseUsedFunctionPhotoswipe event listener
initialZoomInFunctionPhotoswipe event listener
initialZoomInEndFunctionPhotoswipe event listener
initialZoomOutFunctionPhotoswipe event listener
initialZoomOutEndFunctionPhotoswipe event listener
parseVerticalMarginFunctionPhotoswipe event listener
closeFunctionPhotoswipe event listener
unbindEventsFunctionPhotoswipe event listener
destroyFunctionPhotoswipe event listener
updateScrollOffsetFunctionPhotoswipe event listener
preventDragEventFunctionPhotoswipe event listener
shareLinkClickFunctionPhotoswipe event listener

Slot

PhotoSwipeGallery

NameTypeDefaultRequiredDescription
itemObjectHTML Img Tagfalse

Demo

coming soon...