/*! * vue-awesome-swiper v4.1.1 * copyright (c) surmon. all rights reserved. * released under the mit license. * surmon */ (function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports,require('swiper'),require('vue')):typeof define==='function'&&define.amd?define(['exports','swiper','vue'],f):(g=g||self,f(g.vueawesomeswiper={},g.swiper,g.vue));}(this,(function(exports, swiperclass, vue){'use strict';swiperclass=swiperclass&&object.prototype.hasownproperty.call(swiperclass,'default')?swiperclass['default']:swiperclass;vue=vue&&object.prototype.hasownproperty.call(vue,'default')?vue['default']:vue;/** * @file vue-awesome-swiper * @module constants * @author surmon */ var corenames; (function (corenames) { corenames["swipercomponent"] = "swiper"; corenames["swiperslidecomponent"] = "swiperslide"; corenames["swiperdirective"] = "swiper"; corenames["swiperinstance"] = "$swiper"; })(corenames || (corenames = {})); var default_classes = object.freeze({ containerclass: 'swiper-container', wrapperclass: 'swiper-wrapper', slideclass: 'swiper-slide' }); var componentevents; (function (componentevents) { componentevents["ready"] = "ready"; componentevents["clickslide"] = "clickslide"; })(componentevents || (componentevents = {})); var componentpropnames; (function (componentpropnames) { componentpropnames["autoupdate"] = "autoupdate"; componentpropnames["autodestroy"] = "autodestroy"; componentpropnames["deleteinstanceondestroy"] = "deleteinstanceondestroy"; componentpropnames["cleanupstylesondestroy"] = "cleanupstylesondestroy"; })(componentpropnames || (componentpropnames = {})); // https://swiperjs.com/api/#events var swiper_events = [ 'init', 'beforedestroy', 'slidechange', 'slidechangetransitionstart', 'slidechangetransitionend', 'slidenexttransitionstart', 'slidenexttransitionend', 'slideprevtransitionstart', 'slideprevtransitionend', 'transitionstart', 'transitionend', 'touchstart', 'touchmove', 'touchmoveopposite', 'slidermove', 'touchend', 'click', 'tap', 'doubletap', 'imagesready', 'progress', 'reachbeginning', 'reachend', 'fromedge', 'settranslate', 'settransition', 'resize', 'observerupdate', 'beforeloopfix', 'loopfix' ];/*! ***************************************************************************** copyright (c) microsoft corporation. all rights reserved. licensed under the apache license, version 2.0 (the "license"); you may not use this file except in compliance with the license. you may obtain a copy of the license at http://www.apache.org/licenses/license-2.0 this code is provided on an *as is* basis, without warranties or conditions of any kind, either express or implied, including without limitation any implied warranties or conditions of title, fitness for a particular purpose, merchantablity or non-infringement. see the apache version 2.0 license for specific language governing permissions and limitations under the license. ***************************************************************************** */ function __spreadarrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }/** * @file vue-awesome-swiper * @module utils * @author surmon */ var kebabcase = function (string) { return string .replace(/([a-z])([a-z])/g, '$1-$2') .replace(/\s+/g, '-') .tolowercase(); };/** * @file vue-awesome-swiper * @module event * @author surmon */ var handleclickslideevent = function (swiper, event, emit) { var _a, _b, _c; if (swiper && !(swiper.destroyed)) { var eventpath = ((_a = event.composedpath) === null || _a === void 0 ? void 0 : _a.call(event)) || event.path; if ((event === null || event === void 0 ? void 0 : event.target) && eventpath) { var slides_1 = array.from(swiper.slides); var paths = array.from(eventpath); // click slide || slide[children] if (slides_1.includes(event.target) || paths.some(function (item) { return slides_1.includes(item); })) { var clickedindex = swiper.clickedindex; var reallyindex = number((_c = (_b = swiper.clickedslide) === null || _b === void 0 ? void 0 : _b.dataset) === null || _c === void 0 ? void 0 : _c.swiperslideindex); var reallyindexvalue = number.isinteger(reallyindex) ? reallyindex : null; emit(componentevents.clickslide, clickedindex, reallyindexvalue); emit(kebabcase(componentevents.clickslide), clickedindex, reallyindexvalue); } } } }; var bindswiperevents = function (swiper, emit) { swiper_events.foreach(function (eventname) { swiper.on(eventname, function () { var arguments$1 = arguments; var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments$1[_i]; } emit.apply(void 0, __spreadarrays([eventname], args)); var kebabcasename = kebabcase(eventname); if (kebabcasename !== eventname) { emit.apply(void 0, __spreadarrays([kebabcasename], args)); } }); }); };/** * @file vue-awesome-swiper * @module directive * @author surmon */ var instance_name_key = 'instancename'; function getdirective(swiperclass, globaloptions) { var getstandardisedoptionbyattrs = function (vnode, key) { var _a, _b, _c, _d; var value = (_b = (_a = vnode.data) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[key]; return value !== undefined ? value : (_d = (_c = vnode.data) === null || _c === void 0 ? void 0 : _c.attrs) === null || _d === void 0 ? void 0 : _d[kebabcase(key)]; }; // get swiper instace name in directive var getswiperinstancename = function (element, binding, vnode) { return (binding.arg || getstandardisedoptionbyattrs(vnode, instance_name_key) || element.id || corenames.swiperinstance); }; var getswiperinstance = function (element, binding, vnode) { var instancename = getswiperinstancename(element, binding, vnode); return vnode.context[instancename] || null; }; var getswipeoptions = function (binding) { return binding.value || globaloptions; }; var getbooleanvaluebyinput = function (input) { return [true, undefined, null, ''].includes(input); }; // emit event in vue directive var geteventemiter = function (vnode) { var _a, _b; var handlers = ((_a = vnode.data) === null || _a === void 0 ? void 0 : _a.on) || ((_b = vnode.componentoptions) === null || _b === void 0 ? void 0 : _b.listeners); return function (name) { var arguments$1 = arguments; var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments$1[_i]; } var _a; var handle = (_a = handlers) === null || _a === void 0 ? void 0 : _a[name]; if (handle) { handle.fns.apply(handle, args); } }; }; return { // init bind: function (element, binding, vnode) { // auto class name if (element.classname.indexof(default_classes.containerclass) === -1) { element.classname += ((element.classname ? ' ' : '') + default_classes.containerclass); } // bind click event element.addeventlistener('click', function (event) { var emitevent = geteventemiter(vnode); var swiper = getswiperinstance(element, binding, vnode); handleclickslideevent(swiper, event, emitevent); }); }, // dom inserted inserted: function (element, binding, vnode) { var context = vnode.context; var swiperoptions = getswipeoptions(binding); var instancename = getswiperinstancename(element, binding, vnode); var emitevent = geteventemiter(vnode); var vuecontext = context; var swiper = vuecontext === null || vuecontext === void 0 ? void 0 : vuecontext[instancename]; // swiper will destroy but not delete instance, when used if (!swiper || swiper.destroyed) { swiper = new swiperclass(element, swiperoptions); vuecontext[instancename] = swiper; bindswiperevents(swiper, emitevent); emitevent(componentevents.ready, swiper); // mark: reinstance when the nexttick with // vue.nexttick(instancing) | settimeout(instancing) } }, // on options changed or dom updated componentupdated: function (element, binding, vnode) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; var autoupdate = getstandardisedoptionbyattrs(vnode, componentpropnames.autoupdate); if (getbooleanvaluebyinput(autoupdate)) { var swiper = getswiperinstance(element, binding, vnode); if (swiper) { var swiperoptions = getswipeoptions(binding); var isloop = swiperoptions.loop; if (isloop) { (_b = (_a = swiper) === null || _a === void 0 ? void 0 : _a.loopdestroy) === null || _b === void 0 ? void 0 : _b.call(_a); } (_c = swiper === null || swiper === void 0 ? void 0 : swiper.update) === null || _c === void 0 ? void 0 : _c.call(swiper); (_e = (_d = swiper.navigation) === null || _d === void 0 ? void 0 : _d.update) === null || _e === void 0 ? void 0 : _e.call(_d); (_g = (_f = swiper.pagination) === null || _f === void 0 ? void 0 : _f.render) === null || _g === void 0 ? void 0 : _g.call(_f); (_j = (_h = swiper.pagination) === null || _h === void 0 ? void 0 : _h.update) === null || _j === void 0 ? void 0 : _j.call(_h); if (isloop) { (_l = (_k = swiper) === null || _k === void 0 ? void 0 : _k.loopcreate) === null || _l === void 0 ? void 0 : _l.call(_k); (_m = swiper === null || swiper === void 0 ? void 0 : swiper.update) === null || _m === void 0 ? void 0 : _m.call(swiper); } } } }, // destroy this directive unbind: function (element, binding, vnode) { var _a; var autodestroy = getstandardisedoptionbyattrs(vnode, componentpropnames.autodestroy); if (getbooleanvaluebyinput(autodestroy)) { var swiper = getswiperinstance(element, binding, vnode); if (swiper && swiper.initialized) { (_a = swiper === null || swiper === void 0 ? void 0 : swiper.destroy) === null || _a === void 0 ? void 0 : _a.call(swiper, getbooleanvaluebyinput(getstandardisedoptionbyattrs(vnode, componentpropnames.deleteinstanceondestroy)), getbooleanvaluebyinput(getstandardisedoptionbyattrs(vnode, componentpropnames.cleanupstylesondestroy))); } } } }; }/** * @file vue-awesome-swiper * @module swipercomponent * @author surmon */ var slotnames; (function (slotnames) { slotnames["parallaxbg"] = "parallax-bg"; slotnames["pagination"] = "pagination"; slotnames["scrollbar"] = "scrollbar"; slotnames["prevbutton"] = "button-prev"; slotnames["nextbutton"] = "button-next"; })(slotnames || (slotnames = {})); function getswipercomponent(swiperclass) { var _a; return vue.extend({ name: corenames.swipercomponent, props: (_a = { defaultoptions: { type: object, required: false, default: function () { return ({}); } }, // eslint-disable-next-line vue/require-default-prop options: { type: object, required: false } }, _a[componentpropnames.autoupdate] = { type: boolean, default: true }, // https://github.com/surmon-china/vue-awesome-swiper/pull/550/files _a[componentpropnames.autodestroy] = { type: boolean, default: true }, // https://github.com/surmon-china/vue-awesome-swiper/pull/388 _a[componentpropnames.deleteinstanceondestroy] = { type: boolean, required: false, default: true }, _a[componentpropnames.cleanupstylesondestroy] = { type: boolean, required: false, default: true }, _a), data: function () { var _a; return _a = {}, _a[corenames.swiperinstance] = null, _a; }, computed: { swiperinstance: { cache: false, set: function (swiper) { this[corenames.swiperinstance] = swiper; }, get: function () { return this[corenames.swiperinstance]; } }, swiperoptions: function () { return this.options || this.defaultoptions; }, wrapperclass: function () { return this.swiperoptions.wrapperclass || default_classes.wrapperclass; } }, methods: { // feature: click event handleswiperclick: function (event) { handleclickslideevent(this.swiperinstance, event, this.$emit.bind(this)); }, autoreloopswiper: function () { var _a, _b; if (this.swiperinstance && this.swiperoptions.loop) { // https://github.com/surmon-china/vue-awesome-swiper/issues/593 // https://github.com/surmon-china/vue-awesome-swiper/issues/544 // https://github.com/surmon-china/vue-awesome-swiper/pull/545/files var swiper = this.swiperinstance; (_a = swiper === null || swiper === void 0 ? void 0 : swiper.loopdestroy) === null || _a === void 0 ? void 0 : _a.call(swiper); (_b = swiper === null || swiper === void 0 ? void 0 : swiper.loopcreate) === null || _b === void 0 ? void 0 : _b.call(swiper); } }, updateswiper: function () { var _a, _b, _c, _d, _e, _f, _g, _h; if (this[componentpropnames.autoupdate] && this.swiperinstance) { this.autoreloopswiper(); (_b = (_a = this.swiperinstance) === null || _a === void 0 ? void 0 : _a.update) === null || _b === void 0 ? void 0 : _b.call(_a); (_d = (_c = this.swiperinstance.navigation) === null || _c === void 0 ? void 0 : _c.update) === null || _d === void 0 ? void 0 : _d.call(_c); (_f = (_e = this.swiperinstance.pagination) === null || _e === void 0 ? void 0 : _e.render) === null || _f === void 0 ? void 0 : _f.call(_e); (_h = (_g = this.swiperinstance.pagination) === null || _g === void 0 ? void 0 : _g.update) === null || _h === void 0 ? void 0 : _h.call(_g); } }, destroyswiper: function () { var _a, _b; if (this[componentpropnames.autodestroy] && this.swiperinstance) { // https://github.com/surmon-china/vue-awesome-swiper/pull/341 // https://github.com/surmon-china/vue-awesome-swiper/issues/340 if (this.swiperinstance.initialized) { (_b = (_a = this.swiperinstance) === null || _a === void 0 ? void 0 : _a.destroy) === null || _b === void 0 ? void 0 : _b.call(_a, this[componentpropnames.deleteinstanceondestroy], this[componentpropnames.cleanupstylesondestroy]); } } }, initswiper: function () { this.swiperinstance = new swiperclass(this.$el, this.swiperoptions); bindswiperevents(this.swiperinstance, this.$emit.bind(this)); this.$emit(componentevents.ready, this.swiperinstance); } }, mounted: function () { if (!this.swiperinstance) { this.initswiper(); } }, // update swiper when the parent component activated with `keep-alive`. activated: function () { this.updateswiper(); }, updated: function () { this.updateswiper(); }, beforedestroy: function () { // https://github.com/surmon-china/vue-awesome-swiper/commit/2924a9d4d3d1cf51c0d46076410b1f804b2b8a43#diff-7f4e0261ac562c0f354cb91a1ca8864f this.$nexttick(this.destroyswiper); }, render: function (createelement) { return createelement('div', { staticclass: default_classes.containerclass, on: { click: this.handleswiperclick } }, [ this.$slots[slotnames.parallaxbg], createelement('div', { class: this.wrapperclass }, this.$slots.default), this.$slots[slotnames.pagination], this.$slots[slotnames.prevbutton], this.$slots[slotnames.nextbutton], this.$slots[slotnames.scrollbar] ]); } }); }/** * @file vue-awesome-swiper * @module swiperslidecomponent * @author surmon */ var swiperslidecomponent = vue.extend({ name: corenames.swiperslidecomponent, computed: { slideclass: function () { var _a, _b; return ((_b = (_a = this.$parent) === null || _a === void 0 ? void 0 : _a.swiperoptions) === null || _b === void 0 ? void 0 : _b.slideclass) || default_classes.slideclass; } }, methods: { update: function () { var _a; var parent = this.$parent; // https://github.com/surmon-china/vue-awesome-swiper/issues/632 if (parent[componentpropnames.autoupdate]) { (_a = parent === null || parent === void 0 ? void 0 : parent.swiperinstance) === null || _a === void 0 ? void 0 : _a.update(); } } }, mounted: function () { this.update(); }, updated: function () { this.update(); }, render: function (createelement) { return createelement('div', { class: this.slideclass }, this.$slots.default); } });/** * @file vue-awesome-swiper * @module exporter * @author surmon */ var getinstaller = function (swiperclass) { var install = function (vue, globaloptions) { if (install.installed) { return; } var swipercomponent = getswipercomponent(swiperclass); if (globaloptions) { swipercomponent.options.props.defaultoptions.default = function () { return globaloptions; }; } vue.component(corenames.swipercomponent, swipercomponent); vue.component(corenames.swiperslidecomponent, swiperslidecomponent); vue.directive(corenames.swiperdirective, getdirective(swiperclass, globaloptions)); install.installed = true; }; return install; }; function exporter(swiperclass) { var _a; return _a = { version: '4.1.1', install: getinstaller(swiperclass), directive: getdirective(swiperclass) }, _a[corenames.swipercomponent] = getswipercomponent(swiperclass), _a[corenames.swiperslidecomponent] = swiperslidecomponent, _a; }/** * @file vue-awesome-swiper * @module default-export * @author surmon */ var vueawesomeswiper = exporter(swiperclass); var version = vueawesomeswiper.version; var install = vueawesomeswiper.install; var directive = vueawesomeswiper.directive; var swiper = vueawesomeswiper.swiper; var swiperslide = vueawesomeswiper.swiperslide;exports.swiper=swiper;exports.swiperslide=swiperslide;exports.default=vueawesomeswiper;exports.directive=directive;exports.install=install;exports.version=version;object.defineproperty(exports,'__esmodule',{value:true});})));