vue-photoswipe
Version:
PhotoSwipe plugin for Vue.js 2.0
29 lines (24 loc) • 672 B
JavaScript
import PhotoSwipeComponent from './PhotoSwipe.vue'
let $vm
export default {
install (Vue) {
const PhotoSwipe = Vue.extend(PhotoSwipeComponent)
if (!$vm) {
$vm = new PhotoSwipe({el: document.createElement('div')})
document.body.appendChild($vm.$el)
}
Vue.$photoswipe = {
open (index, items, options) {
$vm.open(index, items, options)
},
close () {
$vm.close()
}
}
Vue.mixin({
created () {
this.$photoswipe = Vue.$photoswipe
}
})
}
}