PageSourceSearch

https://eloquent-khapse-98a9d2.netlify.app/js/swiper/vue-awesome-swiper.js

js eloquent-khapse-98a9d2.netlify.app collected 2026-10-03 10:41:43 UTC 21,280 bytes, 479 lines download raw bytes

1
2/*!
3 * vue-awesome-swiper v4.1.1
4 * Copyright (c) Surmon. All rights reserved.
5 * Released under the MIT License.
6 * Surmon <https://github.com/surmon-china>
7 */
8
9(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;/**
10 * @file vue-awesome-swiper
11 * @module constants
12 * @author Surmon <https://github.com/surmon-china>
13 */
14var CoreNames;
15(function (CoreNames) {
16    CoreNames["SwiperComponent"] = "Swiper";
17    CoreNames["SwiperSlideComponent"] = "SwiperSlide";
18    CoreNames["SwiperDirective"] = "swiper";
19    CoreNames["SwiperInstance"] = "$swiper";
20})(CoreNames || (CoreNames = {}));
21var DEFAULT_CLASSES = Object.freeze({
22    containerClass: 'swiper-container',
23    wrapperClass: 'swiper-wrapper',
24    slideClass: 'swiper-slide'
25});
26var ComponentEvents;
27(function (ComponentEvents) {
28    ComponentEvents["Ready"] = "ready";
29    ComponentEvents["ClickSlide"] = "clickSlide";
30})(ComponentEvents || (ComponentEvents = {}));
31var ComponentPropNames;
32(function (ComponentPropNames) {
33    ComponentPropNames["AutoUpdate"] = "autoUpdate";
34    ComponentPropNames["AutoDestroy"] = "autoDestroy";
35    ComponentPropNames["DeleteInstanceOnDestroy"] = "deleteInstanceOnDestroy";
36    ComponentPropNames["CleanupStylesOnDestroy"] = "cleanupStylesOnDestroy";
37})(ComponentPropNames || (ComponentPropNames = {}));
38// https://swiperjs.com/api/#events
39var SWIPER_EVENTS = [
40    'init',
41    'beforeDestroy',
42    'slideChange',
43    'slideChangeTransitionStart',
44    'slideChangeTransitionEnd',
45    'slideNextTransitionStart',
46    'slideNextTransitionEnd',
47    'slidePrevTransitionStart',
48    'slidePrevTransitionEnd',
49    'transitionStart',
50    'transitionEnd',
51    'touchStart',
52    'touchMove',
53    'touchMoveOpposite',
54    'sliderMove',
55    'touchEnd',
56    'click',
57    'tap',
58    'doubleTap',
59    'imagesReady',
60    'progress',
61    'reachBeginning',
62    'reachEnd',
63    'fromEdge',
64    'setTranslate',
65    'setTransition',
66    'resize',
67    'observerUpdate',
68    'beforeLoopFix',
69    'loopFix'
70];/*! *****************************************************************************
71Copyright (c) Microsoft Corporation. All rights reserved.
72Licensed under the Apache License, Version 2.0 (the "License"); you may not use
73this file except in compliance with the License. You may obtain a copy of the
74License at http://www.apache.org/licenses/LICENSE-2.0
75
76THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
77KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
78WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
79MERCHANTABLITY OR NON-INFRINGEMENT.
80
81See the Apache Version 2.0 License for specific language governing permissions
82and limitations under the License.
83***************************************************************************** */
84
85function __spreadArrays() {
86    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
87    for (var r = Array(s), k = 0, i = 0; i < il; i++)
88        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
89            r[k] = a[j];
90    return r;
91}/**
92 * @file vue-awesome-swiper
93 * @module utils
94 * @author Surmon <https://github.com/surmon-china>
95 */
96var kebabcase = function (string) {
97    return string
98        .replace(/([a-z])([A-Z])/g, '$1-$2')
99        .replace(/\s+/g, '-')
100        .toLowerCase();
101};/**
102 * @file vue-awesome-swiper
103 * @module event
104 * @author Surmon <https://github.com/surmon-china>
105 */
106var handleClickSlideEvent = function (swiper, event, emit) {
107    var _a, _b, _c;
108    if (swiper && !(swiper.destroyed)) {
109        var eventPath = ((_a = event.composedPath) === null || _a === void 0 ? void 0 : _a.call(event)) || event.path;
110        if ((event === null || event === void 0 ? void 0 : event.target) && eventPath) {
111            var slides_1 = Array.from(swiper.slides);
112            var paths = Array.from(eventPath);
113            // Click slide || slide[children]
114            if (slides_1.includes(event.target) || paths.some(function (item) { return slides_1.includes(item); })) {
115                var clickedIndex = swiper.clickedIndex;
116                var reallyIndex = Number((_c = (_b = swiper.clickedSlide) === null || _b === void 0 ? void 0 : _b.dataset) === null || _c === void 0 ? void 0 : _c.swiperSlideIndex);
117                var reallyIndexValue = Number.isInteger(reallyIndex) ? reallyIndex : null;
118                emit(ComponentEvents.ClickSlide, clickedIndex, reallyIndexValue);
119                emit(kebabcase(ComponentEvents.ClickSlide), clickedIndex, reallyIndexValue);
120            }
121        }
122    }
123};
124var bindSwiperEvents = function (swiper, emit) {
125    SWIPER_EVENTS.forEach(function (eventName) {
126        swiper.on(eventName, function () {
127            var arguments$1 = arguments;
128
129            var args = [];
130            for (var _i = 0; _i < arguments.length; _i++) {
131                args[_i] = arguments$1[_i];
132            }
133            emit.apply(void 0, __spreadArrays([eventName], args));
134            var kebabcaseName = kebabcase(eventName);
135            if (kebabcaseName !== eventName) {
136                emit.apply(void 0, __spreadArrays([kebabcaseName], args));
137            }
138        });
139    });
140};/**
141 * @file vue-awesome-swiper
142 * @module directive
143 * @author Surmon <https://github.com/surmon-china>
144 */
145var INSTANCE_NAME_KEY = 'instanceName';
146function getDirective(SwiperClass, globalOptions) {
147    var getStandardisedOptionByAttrs = function (vnode, key) {
148        var _a, _b, _c, _d;
149        var value = (_b = (_a = vnode.data) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[key];
150        return value !== undefined
151            ? value
152            : (_d = (_c = vnode.data) === null || _c === void 0 ? void 0 : _c.attrs) === null || _d === void 0 ? void 0 : _d[kebabcase(key)];
153    };
154    // Get swiper instace name in directive
155    var getSwiperInstanceName = function (element, binding, vnode) {
156        return (binding.arg ||
157            getStandardisedOptionByAttrs(vnode, INSTANCE_NAME_KEY) ||
158            element.id ||
159            CoreNames.SwiperInstance);
160    };
161    var getSwiperInstance = function (element, binding, vnode) {
162        var instanceName = getSwiperInstanceName(element, binding, vnode);
163        return vnode.context[instanceName] || null;
164    };
165    var getSwipeOptions = function (binding) {
166        return binding.value || globalOptions;
167    };
168    var getBooleanValueByInput = function (input) {
169        return [true, undefined, null, ''].includes(input);
170    };
171    // Emit event in Vue directive
172    var getEventEmiter = function (vnode) {
173        var _a, _b;
174        var handlers = ((_a = vnode.data) === null || _a === void 0 ? void 0 : _a.on) || ((_b = vnode.componentOptions) === null || _b === void 0 ? void 0 : _b.listeners);
175        return function (name) {
176            var arguments$1 = arguments;
177
178            var args = [];
179            for (var _i = 1; _i < arguments.length; _i++) {
180                args[_i - 1] = arguments$1[_i];
181            }
182            var _a;
183            var handle = (_a = handlers) === null || _a === void 0 ? void 0 : _a[name];
184            if (handle) {
185                handle.fns.apply(handle, args);
186            }
187        };
188    };
189    return {
190        // Init
191        bind: function (element, binding, vnode) {
192            // auto class name
193            if (element.className.indexOf(DEFAULT_CLASSES.containerClass) === -1) {
194                element.className += ((element.className ? ' ' : '') + DEFAULT_CLASSES.containerClass);
195            }
196            // bind click event
197            element.addEventListener('click', function (event) {
198                var emitEvent = getEventEmiter(vnode);
199                var swiper = getSwiperInstance(element, binding, vnode);
200                handleClickSlideEvent(swiper, event, emitEvent);
201            });
202        },
203        // DOM inserted
204        inserted: function (element, binding, vnode) {
205            var context = vnode.context;
206            var swiperOptions = getSwipeOptions(binding);
207            var instanceName = getSwiperInstanceName(element, binding, vnode);
208            var emitEvent = getEventEmiter(vnode);
209            var vueContext = context;
210            var swiper = vueContext === null || vueContext === void 0 ? void 0 : vueContext[instanceName];
211            // Swiper will destroy but not delete instance, when used <keep-alive>
212            if (!swiper || swiper.destroyed) {
213                swiper = new SwiperClass(element, swiperOptions);
214                vueContext[instanceName] = swiper;
215                bindSwiperEvents(swiper, emitEvent);
216                emitEvent(ComponentEvents.Ready, swiper);
217                // MARK: Reinstance when the nexttick with <keep-alive>
218                // Vue.nextTick(instancing) | setTimeout(instancing)
219            }
220        },
221        // On options changed or DOM updated
222        componentUpdated: function (element, binding, vnode) {
223            var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
224            var autoUpdate = getStandardisedOptionByAttrs(vnode, ComponentPropNames.AutoUp
224date);
225            if (getBooleanValueByInput(autoUpdate)) {
226                var swiper = getSwiperInstance(element, binding, vnode);
227                if (swiper) {
228                    var swiperOptions = getSwipeOptions(binding);
229                    var isLoop = swiperOptions.loop;
230                    if (isLoop) {
231                        (_b = (_a = swiper) === null || _a === void 0 ? void 0 : _a.loopDestroy) === null || _b === void 0 ? void 0 : _b.call(_a);
232                    }
233                    (_c = swiper === null || swiper === void 0 ? void 0 : swiper.update) === null || _c === void 0 ? void 0 : _c.call(swiper);
234                    (_e = (_d = swiper.navigation) === null || _d === void 0 ? void 0 : _d.update) === null || _e === void 0 ? void 0 : _e.call(_d);
235                    (_g = (_f = swiper.pagination) === null || _f === void 0 ? void 0 : _f.render) === null || _g === void 0 ? void 0 : _g.call(_f);
236                    (_j = (_h = swiper.pagination) === null || _h === void 0 ? void 0 : _h.update) === null || _j === void 0 ? void 0 : _j.call(_h);
237                    if (isLoop) {
238                        (_l = (_k = swiper) === null || _k === void 0 ? void 0 : _k.loopCreate) === null || _l === void 0 ? void 0 : _l.call(_k);
239                        (_m = swiper === null || swiper === void 0 ? void 0 : swiper.update) === null || _m === void 0 ? void 0 : _m.call(swiper);
240                    }
241                }
242            }
243        },
244        // Destroy this directive
245        unbind: function (element, binding, vnode) {
246            var _a;
247            var autoDestroy = getStandardisedOptionByAttrs(vnode, ComponentPropNames.AutoDestroy);
248            if (getBooleanValueByInput(autoDestroy)) {
249                var swiper = getSwiperInstance(element, binding, vnode);
250                if (swiper && swiper.initialized) {
251                    (_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)));
252                }
253            }
254        }
255    };
256}/**
257 * @file vue-awesome-swiper
258 * @module SwiperComponent
259 * @author Surmon <https://github.com/surmon-china>
260 */
261var SlotNames;
262(function (SlotNames) {
263    SlotNames["ParallaxBg"] = "parallax-bg";
264    SlotNames["Pagination"] = "pagination";
265    SlotNames["Scrollbar"] = "scrollbar";
266    SlotNames["PrevButton"] = "button-prev";
267    SlotNames["NextButton"] = "button-next";
268})(SlotNames || (SlotNames = {}));
269function getSwiperComponent(SwiperClass) {
270    var _a;
271    return Vue.extend({
272        name: CoreNames.SwiperComponent,
273        props: (_a = {
274                defaultOptions: {
275                    type: Object,
276                    required: false,
277                    default: function () { return ({}); }
278                },
279                // eslint-disable-next-line vue/require-default-prop
280                options: {
281                    type: Object,
282                    required: false
283                }
284            },
285            _a[ComponentPropNames.AutoUpdate] = {
286                type: Boolean,
287                default: true
288            },
289            // https://github.com/surmon-china/vue-awesome-swiper/pull/550/files
290            _a[ComponentPropNames.AutoDestroy] = {
291                type: Boolean,
292                default: true
293            },
294            // https://github.com/surmon-china/vue-awesome-swiper/pull/388
295            _a[ComponentPropNames.DeleteInstanceOnDestroy] = {
296                type: Boolean,
297                required: false,
298                default: true
299            },
300            _a[ComponentPropNames.CleanupStylesOnDestroy] = {
301                type: Boolean,
302                required: false,
303                default: true
304            },
305            _a),
306        data: function () {
307            var _a;
308            return _a = {},
309                _a[CoreNames.SwiperInstance] = null,
310                _a;
311        },
312        computed: {
313            swiperInstance: {
314                cache: false,
315                set: function (swiper) {
316                    this[CoreNames.SwiperInstance] = swiper;
317                },
318                get: function () {
319                    return this[CoreNames.SwiperInstance];
320                }
321            },
322            swiperOptions: function () {
323                return this.options || this.defaultOptions;
324            },
325            wrapperClass: function () {
326                return this.swiperOptions.wrapperClass || DEFAULT_CLASSES.wrapperClass;
327            }
328        },
329        methods: {
330            // Feature: click event
331            handleSwiperClick: function (event) {
332                handleClickSlideEvent(this.swiperInstance, event, this.$emit.bind(this));
333            },
334            autoReLoopSwiper: function () {
335                var _a, _b;
336                if (this.swiperInstance && this.swiperOptions.loop) {
337                    // https://github.com/surmon-china/vue-awesome-swiper/issues/593
338                    // https://github.com/surmon-china/vue-awesome-swiper/issues/544
339                    // https://github.com/surmon-china/vue-awesome-swiper/pull/545/files
340                    var swiper = this.swiperInstance;
341                    (_a = swiper === null || swiper === void 0 ? void 0 : swiper.loopDestroy) === null || _a === void 0 ? void 0 : _a.call(swi
341per);
342                    (_b = swiper === null || swiper === void 0 ? void 0 : swiper.loopCreate) === null || _b === void 0 ? void 0 : _b.call(swiper);
343                }
344            },
345            updateSwiper: function () {
346                var _a, _b, _c, _d, _e, _f, _g, _h;
347                if (this[ComponentPropNames.AutoUpdate] && this.swiperInstance) {
348                    this.autoReLoopSwiper();
349                    (_b = (_a = this.swiperInstance) === null || _a === void 0 ? void 0 : _a.update) === null || _b === void 0 ? void 0 : _b.call(_a);
350                    (_d = (_c = this.swiperInstance.navigation) === null || _c === void 0 ? void 0 : _c.update) === null || _d === void 0 ? void 0 : _d.call(_c);
351                    (_f = (_e = this.swiperInstance.pagination) === null || _e === void 0 ? void 0 : _e.render) === null || _f === void 0 ? void 0 : _f.call(_e);
352                    (_h = (_g = this.swiperInstance.pagination) === null || _g === void 0 ? void 0 : _g.update) === null || _h === void 0 ? void 0 : _h.call(_g);
353                }
354            },
355            destroySwiper: function () {
356                var _a, _b;
357                if (this[ComponentPropNames.AutoDestroy] && this.swiperInstance) {
358                    // https://github.com/surmon-china/vue-awesome-swiper/pull/341
359                    // https://github.com/surmon-china/vue-awesome-swiper/issues/340
360                    if (this.swiperInstance.initialized) {
361                        (_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]);
362                    }
363                }
364            },
365            initSwiper: function () {
366                this.swiperInstance = new SwiperClass(this.$el, this.swiperOptions);
367                bindSwiperEvents(this.swiperInstance, this.$emit.bind(this));
368                this.$emit(ComponentEvents.Ready, this.swiperInstance);
369            }
370        },
371        mounted: function () {
372            if (!this.swiperInstance) {
373                this.initSwiper();
374            }
375        },
376        // Update swiper when the parent component activated with `keep-alive`.
377        activated: function () {
378            this.updateSwiper();
379        },
380        updated: function () {
381            this.updateSwiper();
382        },
383        beforeDestroy: function () {
384            // https://github.com/surmon-china/vue-awesome-swiper/commit/2924a9d4d3d1cf51c0d46076410b1f804b2b8a43#diff-7f4e0261ac562c0f354cb91a1ca8864f
385            this.$nextTick(this.destroySwiper);
386        },
387        render: function (createElement) {
388            return createElement('div', {
389                staticClass: DEFAULT_CLASSES.containerClass,
390                on: {
391                    click: this.handleSwiperClick
392                }
393            }, [
394                this.$slots[SlotNames.ParallaxBg],
395                createElement('div', {
396                    class: this.wrapperClass
397                }, this.$slots.default),
398                this.$slots[SlotNames.Pagination],
399                this.$slots[SlotNames.PrevButton],
400                this.$slots[SlotNames.NextButton],
401                this.$slots[SlotNames.Scrollbar]
402            ]);
403        }
404    });
405}/**
406 * @file vue-awesome-swiper
407 * @module SwiperSlideComponent
408 * @author Surmon <https://github.com/surmon-china>
409 */
410var SwiperSlideComponent = Vue.extend({
411    name: CoreNames.SwiperSlideComponent,
412    computed: {
413        slideClass: function () {
414            var _a, _b;
415            return ((_b = (_a = this.$parent) === null || _a === void 0 ? void 0 : _a.swiperOptions) === null || _b === void 0 ? void 0 : _b.slideClass) || DEFAULT_CLASSES.slideClass;
416        }
417    },
418    methods: {
419        update: function () {
420            var _a;
421            var parent = this.$parent;
422            // https://github.com/surmon-china/vue-awesome-swiper/issues/632
423            if (parent[ComponentPropNames.AutoUpdate]) {
424                (_a = parent === null || parent === void 0 ? void 0 : parent.swiperInstance) === null || _a === void 0 ? void 0 : _a.update();
425            }
426        }
427    },
428    mounted: function () {
429        this.update();
430    },
431    updated: function () {
432        this.update();
433    },
434    render: function (createElement) {
435        return createElement('div', {
436            class: this.slideClass
437        }, this.$slots.default);
438    }
439});/**
440 * @file vue-awesome-swiper
441 * @module exporter
442 * @author Surmon <https://github.com/surmon-china>
443 */
444var getInstaller = function (SwiperClass) {
445    var install = function (Vue, globalOptions) {
446        if (install.installed)
447            { return; }
448        var SwiperComponent = getSwiperComponent(SwiperClass);
449        if (globalOptions) {
450            SwiperComponent.options.props.defaultOptions.default = function () { return globalOptions; };
451        }
452        Vue.component(CoreNames.SwiperComponent, SwiperComponent);
453        Vue.component(CoreNames.SwiperSlideComponent, SwiperSlideComponent);
454        Vue.directive(CoreNames.SwiperDirective, getDirective(SwiperClass, globalOptions));
455        install.installed = true;
456    };
457    return install;
458};
459function exporter(SwiperClass) {
460    var _a;
461    return _a = {
462            version: '4.1.1',
463            install: getInstaller(SwiperClass),
464            directive: getDirective(SwiperClass)
465        },
466        _a[CoreNames.SwiperComponent] = getSwiperComponent(SwiperClass),
467        _a[CoreNames.SwiperSlideComponent] = SwiperSlideComponent,
468        _a;
469}/**
470 * @file vue-awesome-swiper
471 * @module default-export
472 * @author Surmon <https://github.com/surmon-china>
473 */
474var VueAwesomeSwiper = exporter(SwiperClass);
475var version = VueAwesomeSwiper.version;
476var install = VueAwesomeSwiper.install;
477var directive = VueAwesomeSwiper.directive;
478var Swiper = VueAwesomeSwiper.Swiper;
479var 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});})));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.