|
1 | 1 | (function (global, factory) {
|
2 | 2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
3 | 3 | typeof define === 'function' && define.amd ? define(factory) :
|
4 |
| - (global.VueGallerySlideshow = factory()); |
5 |
| -}(this, (function () { 'use strict'; |
| 4 | + (global = global || self, global.VueGallerySlideshow = factory()); |
| 5 | +}(this, function () { 'use strict'; |
6 | 6 |
|
7 | 7 | //
|
8 | 8 | //
|
|
34 | 34 | //
|
35 | 35 | //
|
36 | 36 | //
|
37 |
| - |
38 | 37 | var script = {
|
39 | 38 | props: ["images", "index"],
|
40 | 39 | mounted: function mounted() {
|
|
50 | 49 | }
|
51 | 50 | });
|
52 | 51 | },
|
53 |
| - |
54 | 52 | watch: {
|
55 | 53 | index: function index(val) {
|
56 | 54 | this.imgIndex = val;
|
|
63 | 61 | },
|
64 | 62 | onPrev: function onPrev() {
|
65 | 63 | if (this.imgIndex === null) return;
|
| 64 | + |
66 | 65 | if (this.imgIndex > 0) {
|
67 | 66 | this.imgIndex--;
|
68 | 67 | } else {
|
69 | 68 | this.imgIndex = this.images.length - 1;
|
70 | 69 | }
|
| 70 | + |
71 | 71 | this.updateThumbails();
|
72 | 72 | },
|
73 | 73 | onNext: function onNext() {
|
74 | 74 | if (this.imgIndex === null) return;
|
| 75 | + |
75 | 76 | if (this.imgIndex < this.images.length - 1) {
|
76 | 77 | this.imgIndex++;
|
77 | 78 | } else {
|
78 | 79 | this.imgIndex = 0;
|
79 | 80 | }
|
| 81 | + |
80 | 82 | this.updateThumbails();
|
81 | 83 | },
|
82 | 84 | onClickThumb: function onClickThumb(image, index) {
|
|
91 | 93 | var galleryWidth = this.$refs.gallery.clientWidth;
|
92 | 94 | var currThumbsWidth = this.imgIndex * this.thumbnailWidth;
|
93 | 95 | var maxThumbsWidth = this.images.length * this.thumbnailWidth;
|
94 |
| - var centerPos = Math.floor(galleryWidth / (this.thumbnailWidth * 2)) * this.thumbnailWidth; |
| 96 | + var centerPos = Math.floor(galleryWidth / (this.thumbnailWidth * 2)) * this.thumbnailWidth; // Prevent scrolling of images if not needed |
95 | 97 |
|
96 |
| - // Prevent scrolling of images if not needed |
97 | 98 | if (maxThumbsWidth < galleryWidth) {
|
98 | 99 | return;
|
99 | 100 | }
|
|
216 | 217 | return addStyle(id, style);
|
217 | 218 | };
|
218 | 219 | }
|
219 |
| - var HEAD = document.head || document.getElementsByTagName('head')[0]; |
| 220 | + var HEAD; |
220 | 221 | var styles = {};
|
221 | 222 |
|
222 | 223 | function addStyle(id, css) {
|
|
242 | 243 | style.element = document.createElement('style');
|
243 | 244 | style.element.type = 'text/css';
|
244 | 245 | if (css.media) style.element.setAttribute('media', css.media);
|
| 246 | + |
| 247 | + if (HEAD === undefined) { |
| 248 | + HEAD = document.head || document.getElementsByTagName('head')[0]; |
| 249 | + } |
| 250 | + |
245 | 251 | HEAD.appendChild(style.element);
|
246 | 252 | }
|
247 | 253 |
|
|
261 | 267 | var browser = createInjector;
|
262 | 268 |
|
263 | 269 | /* script */
|
264 |
| - var __vue_script__ = script; |
| 270 | + const __vue_script__ = script; |
265 | 271 |
|
266 | 272 | /* template */
|
267 |
| - var __vue_render__ = function __vue_render__() { |
268 |
| - var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('transition', { attrs: { "name": "modal" } }, [_vm.imgIndex !== null ? _c('div', { staticClass: "vgs", on: { "click": _vm.close } }, [_c('button', { staticClass: "vgs__close", attrs: { "type": "button" }, on: { "click": _vm.close } }, [_vm._v("×")]), _vm._v(" "), _vm.isMultiple ? _c('button', { staticClass: "vgs__prev", attrs: { "type": "button" }, on: { "click": function click($event) { |
269 |
| - $event.stopPropagation();return _vm.onPrev($event); |
270 |
| - } } }, [_vm._v("‹")]) : _vm._e(), _vm._v(" "), _vm.images ? _c('div', { staticClass: "vgs__container", on: { "click": function click($event) { |
271 |
| - $event.stopPropagation();return _vm.onNext($event); |
272 |
| - } } }, [_c('img', { staticClass: "vgs__container__img", attrs: { "src": _vm.imageUrl }, on: { "click": function click($event) { |
273 |
| - $event.stopPropagation();return _vm.onNext($event); |
274 |
| - } } })]) : _vm._e(), _vm._v(" "), _vm.isMultiple ? _c('button', { staticClass: "vgs__next", attrs: { "type": "button" }, on: { "click": function click($event) { |
275 |
| - $event.stopPropagation();return _vm.onNext($event); |
276 |
| - } } }, [_vm._v("›")]) : _vm._e(), _vm._v(" "), _vm.isMultiple ? _c('div', { ref: "gallery", staticClass: "vgs__gallery" }, [_vm.images ? _c('div', { staticClass: "vgs__gallery__title" }, [_vm._v(_vm._s(_vm.imgIndex + 1) + " / " + _vm._s(_vm.images.length))]) : _vm._e(), _vm._v(" "), _vm.images ? _c('div', { staticClass: "vgs__gallery__container", style: { transform: 'translate(' + _vm.galleryXPos + 'px, 0)' } }, _vm._l(_vm.images, function (image, i) { |
277 |
| - return _c('img', { key: i, staticClass: "vgs__gallery__container__img", class: { 'vgs__gallery__container__img--active': i === _vm.imgIndex }, attrs: { "src": image }, on: { "click": function click($event) { |
278 |
| - $event.stopPropagation();return _vm.onClickThumb(image, i); |
279 |
| - } } }); |
280 |
| - }), 0) : _vm._e()]) : _vm._e()]) : _vm._e()]); |
281 |
| - }; |
| 273 | + var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('transition',{attrs:{"name":"modal"}},[(_vm.imgIndex !== null)?_c('div',{staticClass:"vgs",on:{"click":_vm.close}},[_c('button',{staticClass:"vgs__close",attrs:{"type":"button"},on:{"click":_vm.close}},[_vm._v("×")]),_vm._v(" "),(_vm.isMultiple)?_c('button',{staticClass:"vgs__prev",attrs:{"type":"button"},on:{"click":function($event){$event.stopPropagation();return _vm.onPrev($event)}}},[_vm._v("‹")]):_vm._e(),_vm._v(" "),(_vm.images)?_c('div',{staticClass:"vgs__container",on:{"click":function($event){$event.stopPropagation();return _vm.onNext($event)}}},[_c('img',{staticClass:"vgs__container__img",attrs:{"src":_vm.imageUrl},on:{"click":function($event){$event.stopPropagation();return _vm.onNext($event)}}})]):_vm._e(),_vm._v(" "),(_vm.isMultiple)?_c('button',{staticClass:"vgs__next",attrs:{"type":"button"},on:{"click":function($event){$event.stopPropagation();return _vm.onNext($event)}}},[_vm._v("›")]):_vm._e(),_vm._v(" "),(_vm.isMultiple)?_c('div',{ref:"gallery",staticClass:"vgs__gallery"},[(_vm.images)?_c('div',{staticClass:"vgs__gallery__title"},[_vm._v(_vm._s(_vm.imgIndex + 1)+" / "+_vm._s(_vm.images.length))]):_vm._e(),_vm._v(" "),(_vm.images)?_c('div',{staticClass:"vgs__gallery__container",style:({ transform: 'translate(' + _vm.galleryXPos + 'px, 0)' })},_vm._l((_vm.images),function(image,i){return _c('img',{key:i,staticClass:"vgs__gallery__container__img",class:{ 'vgs__gallery__container__img--active': i === _vm.imgIndex},attrs:{"src":image},on:{"click":function($event){$event.stopPropagation();return _vm.onClickThumb(image, i)}}})}),0):_vm._e()]):_vm._e()]):_vm._e()])}; |
282 | 274 | var __vue_staticRenderFns__ = [];
|
283 | 275 |
|
284 |
| - /* style */ |
285 |
| - var __vue_inject_styles__ = function __vue_inject_styles__(inject) { |
286 |
| - if (!inject) return; |
287 |
| - inject("data-v-4488c8a8_0", { source: ".vgs{transition:opacity .2s ease;position:fixed;z-index:9998;top:0;left:0;width:100%;min-height:100%;height:100vh;background-color:rgba(0,0,0,.8);display:table}.vgs__close{color:#fff;position:absolute;top:0;right:0;background-color:transparent;border:none;font-size:25px;width:50px;height:50px;cursor:pointer;z-index:999}.vgs__close:focus{outline:0}.vgs__next,.vgs__prev{position:absolute;top:50%;margin-top:-25px;width:50px;height:50px;z-index:999;cursor:pointer;font-size:40px;color:#fff;background-color:transparent;border:none}.vgs__next:focus,.vgs__prev:focus{outline:0}.vgs__prev{left:0}.vgs__next{right:0}.vgs__container{position:absolute;overflow:hidden;cursor:pointer;overflow:hidden;max-width:100vh;margin:.5rem auto 0;left:.5rem;right:.5rem;height:60vh;border-radius:12px;background-color:#000}@media (max-width:767px){.vgs__container{width:100%;max-width:100%;top:50%;margin-top:-140px;left:0;right:0;border-radius:0;height:280px}}.vgs__container__img{width:100%;height:100%;object-fit:contain}.vgs__gallery{overflow-x:hidden;overflow-y:hidden;position:absolute;bottom:10px;margin:auto;max-width:100vh;white-space:nowrap;left:.5rem;right:.5rem}@media (max-width:767px){.vgs__gallery{display:none}}.vgs__gallery__title{color:#fff;margin-bottom:.5rem}.vgs__gallery__container{overflow:visible;display:block;height:100px;white-space:nowrap;transition:all .2s ease-in-out;width:100%}.vgs__gallery__container__img{width:100px;height:100px;object-fit:cover;display:inline-block;float:none;margin-right:20px;cursor:pointer;opacity:.6;border-radius:8px}.vgs__gallery__container__img--active{width:100px;display:inline-block;float:none;opacity:1}.modal-enter{opacity:0}.modal-leave-active{opacity:0}", map: undefined, media: undefined }); |
288 |
| - }; |
289 |
| - /* scoped */ |
290 |
| - var __vue_scope_id__ = undefined; |
291 |
| - /* module identifier */ |
292 |
| - var __vue_module_identifier__ = undefined; |
293 |
| - /* functional template */ |
294 |
| - var __vue_is_functional_template__ = false; |
295 |
| - /* style inject SSR */ |
| 276 | + /* style */ |
| 277 | + const __vue_inject_styles__ = function (inject) { |
| 278 | + if (!inject) return |
| 279 | + inject("data-v-4488c8a8_0", { source: ".vgs{transition:opacity .2s ease;position:fixed;z-index:9998;top:0;left:0;width:100%;min-height:100%;height:100vh;background-color:rgba(0,0,0,.8);display:table}.vgs__close{color:#fff;position:absolute;top:0;right:0;background-color:transparent;border:none;font-size:25px;width:50px;height:50px;cursor:pointer;z-index:999}.vgs__close:focus{outline:0}.vgs__next,.vgs__prev{position:absolute;top:50%;margin-top:-25px;width:50px;height:50px;z-index:999;cursor:pointer;font-size:40px;color:#fff;background-color:transparent;border:none}.vgs__next:focus,.vgs__prev:focus{outline:0}.vgs__prev{left:0}.vgs__next{right:0}.vgs__container{position:absolute;overflow:hidden;cursor:pointer;overflow:hidden;max-width:100vh;margin:.5rem auto 0;left:.5rem;right:.5rem;height:60vh;border-radius:12px;background-color:#000}@media (max-width:767px){.vgs__container{width:100%;max-width:100%;top:50%;margin-top:-140px;left:0;right:0;border-radius:0;height:280px}}.vgs__container__img{width:100%;height:100%;object-fit:contain}.vgs__gallery{overflow-x:hidden;overflow-y:hidden;position:absolute;bottom:10px;margin:auto;max-width:100vh;white-space:nowrap;left:.5rem;right:.5rem}@media (max-width:767px){.vgs__gallery{display:none}}.vgs__gallery__title{color:#fff;margin-bottom:.5rem}.vgs__gallery__container{overflow:visible;display:block;height:100px;white-space:nowrap;transition:all .2s ease-in-out;width:100%}.vgs__gallery__container__img{width:100px;height:100px;object-fit:cover;display:inline-block;float:none;margin-right:20px;cursor:pointer;opacity:.6;border-radius:8px}.vgs__gallery__container__img--active{width:100px;display:inline-block;float:none;opacity:1}.modal-enter{opacity:0}.modal-leave-active{opacity:0}", map: undefined, media: undefined }); |
296 | 280 |
|
297 |
| - var GallerySlideshow = normalizeComponent_1({ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, browser, undefined); |
| 281 | + }; |
| 282 | + /* scoped */ |
| 283 | + const __vue_scope_id__ = undefined; |
| 284 | + /* module identifier */ |
| 285 | + const __vue_module_identifier__ = undefined; |
| 286 | + /* functional template */ |
| 287 | + const __vue_is_functional_template__ = false; |
| 288 | + /* style inject SSR */ |
| 289 | + |
| 290 | + |
| 291 | + |
| 292 | + var GallerySlideshow = normalizeComponent_1( |
| 293 | + { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ }, |
| 294 | + __vue_inject_styles__, |
| 295 | + __vue_script__, |
| 296 | + __vue_scope_id__, |
| 297 | + __vue_is_functional_template__, |
| 298 | + __vue_module_identifier__, |
| 299 | + browser, |
| 300 | + undefined |
| 301 | + ); |
298 | 302 |
|
299 | 303 | return GallerySlideshow;
|
300 | 304 |
|
301 |
| -}))); |
| 305 | +})); |
0 commit comments