Photoswipe: init method should not open the gallery

Created on 19 Mar 2018  路  1Comment  路  Source: dimsemenov/PhotoSwipe

So we could create a thumbnail mechanism easier if the init method could be call once without opening the gallery modal.

VueJS Template:

  <div v-for="(item, index) in value">
      <a v-on:click="swipe(index)" v-if="item.thumb">
        <img :src="item.thumb" :class="classes"/>
      </a>
   </div>`

Mounted method (called once):

    mounted: function () {
     let pswpElement = document.querySelectorAll('.pswp')[0]
      let options = {
        history: false,
        focus: false,
        showAnimationDuration: 0,
        hideAnimationDuration: 0
      }
      this.gallery = new PhotoSwipe(pswpElement, PhotoSwipeUIDefault, this.value, options)
      this.gallery.init()
    },

Swipe Method:

    swipe: function (index = 0) {
        this.gallery.goTo(index)
    }

Most helpful comment

I am also having the same issue, the init() method should not open the gallary

>All comments

I am also having the same issue, the init() method should not open the gallary

Was this page helpful?
0 / 5 - 0 ratings