v-photoswipe

Vue plugin for image preview base on PhotoSwipe
126,862 32
Install
npm install v-photoswipe@1.0.3
Latest Version:1.0.3
Vue:2
License:MIT
Last Updated:Mar 1, 2023
Links: GitHub  ·  npm
Maintainer: leesson

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="https://raw.githubusercontent.com/Leesson/v-photoswipe/HEAD/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...

Related Packages

v-img

Vuejs plugin for image viewing

61,736 406
vue-preview

A Vue integration PhotoSwipe image preview plugin

20,276 637
vue2-preview

A Vue2 image preview plugin

1,792 23
vue-photoswipe-directive

An image previewer for vue, powered by PhotoSwipe.

1,545 18
vue3-picture-swipe

A Vue 3 integration PhotoSwipe image plugin

218,744 39

Version History

Version Released License
1.0.3 MIT
1.0.2 MIT
1.0.1 MIT
1.0.0 MIT
Pre-releases (1)
Version Released License
1.0.3-1 MIT