/**
* swiper 8.3.0
* most modern mobile touch slider and framework with hardware accelerated transitions
* https://swiperjs.com
*
* copyright 2014-2022 vladimir kharlampidi
*
* released under the mit license
*
* released on: july 6, 2022
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalthis !== 'undefined' ? globalthis : global || self, global.swiper = factory());
})(this, (function () { 'use strict';
/**
* ssr window 4.0.2
* better handling for window object in ssr environment
* https://github.com/nolimits4web/ssr-window
*
* copyright 2021, vladimir kharlampidi
*
* licensed under mit
*
* released on: december 13, 2021
*/
/* eslint-disable no-param-reassign */
function isobject$1(obj) {
return obj !== null && typeof obj === 'object' && 'constructor' in obj && obj.constructor === object;
}
function extend$1(target, src) {
if (target === void 0) {
target = {};
}
if (src === void 0) {
src = {};
}
object.keys(src).foreach(key => {
if (typeof target[key] === 'undefined') target[key] = src[key];else if (isobject$1(src[key]) && isobject$1(target[key]) && object.keys(src[key]).length > 0) {
extend$1(target[key], src[key]);
}
});
}
const ssrdocument = {
body: {},
addeventlistener() {},
removeeventlistener() {},
activeelement: {
blur() {},
nodename: ''
},
queryselector() {
return null;
},
queryselectorall() {
return [];
},
getelementbyid() {
return null;
},
createevent() {
return {
initevent() {}
};
},
createelement() {
return {
children: [],
childnodes: [],
style: {},
setattribute() {},
getelementsbytagname() {
return [];
}
};
},
createelementns() {
return {};
},
importnode() {
return null;
},
location: {
hash: '',
host: '',
hostname: '',
href: '',
origin: '',
pathname: '',
protocol: '',
search: ''
}
};
function getdocument() {
const doc = typeof document !== 'undefined' ? document : {};
extend$1(doc, ssrdocument);
return doc;
}
const ssrwindow = {
document: ssrdocument,
navigator: {
useragent: ''
},
location: {
hash: '',
host: '',
hostname: '',
href: '',
origin: '',
pathname: '',
protocol: '',
search: ''
},
history: {
replacestate() {},
pushstate() {},
go() {},
back() {}
},
customevent: function customevent() {
return this;
},
addeventlistener() {},
removeeventlistener() {},
getcomputedstyle() {
return {
getpropertyvalue() {
return '';
}
};
},
image() {},
date() {},
screen: {},
settimeout() {},
cleartimeout() {},
matchmedia() {
return {};
},
requestanimationframe(callback) {
if (typeof settimeout === 'undefined') {
callback();
return null;
}
return settimeout(callback, 0);
},
cancelanimationframe(id) {
if (typeof settimeout === 'undefined') {
return;
}
cleartimeout(id);
}
};
function getwindow() {
const win = typeof window !== 'undefined' ? window : {};
extend$1(win, ssrwindow);
return win;
}
/**
* dom7 4.0.4
* minimalistic javascript library for dom manipulation, with a jquery-compatible api
* https://framework7.io/docs/dom7.html
*
* copyright 2022, vladimir kharlampidi
*
* licensed under mit
*
* released on: january 11, 2022
*/
/* eslint-disable no-proto */
function makereactive(obj) {
const proto = obj.__proto__;
object.defineproperty(obj, '__proto__', {
get() {
return proto;
},
set(value) {
proto.__proto__ = value;
}
});
}
class dom7 extends array {
constructor(items) {
if (typeof items === 'number') {
super(items);
} else {
super(...(items || []));
makereactive(this);
}
}
}
function arrayflat(arr) {
if (arr === void 0) {
arr = [];
}
const res = [];
arr.foreach(el => {
if (array.isarray(el)) {
res.push(...arrayflat(el));
} else {
res.push(el);
}
});
return res;
}
function arrayfilter(arr, callback) {
return array.prototype.filter.call(arr, callback);
}
function arrayunique(arr) {
const uniquearray = [];
for (let i = 0; i < arr.length; i += 1) {
if (uniquearray.indexof(arr[i]) === -1) uniquearray.push(arr[i]);
}
return uniquearray;
}
function qsa(selector, context) {
if (typeof selector !== 'string') {
return [selector];
}
const a = [];
const res = context.queryselectorall(selector);
for (let i = 0; i < res.length; i += 1) {
a.push(res[i]);
}
return a;
}
function $(selector, context) {
const window = getwindow();
const document = getdocument();
let arr = [];
if (!context && selector instanceof dom7) {
return selector;
}
if (!selector) {
return new dom7(arr);
}
if (typeof selector === 'string') {
const html = selector.trim();
if (html.indexof('<') >= 0 && html.indexof('>') >= 0) {
let tocreate = 'div';
if (html.indexof('
c.split(' ')));
this.foreach(el => {
el.classlist.add(...classnames);
});
return this;
}
function removeclass() {
for (var _len2 = arguments.length, classes = new array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
classes[_key2] = arguments[_key2];
}
const classnames = arrayflat(classes.map(c => c.split(' ')));
this.foreach(el => {
el.classlist.remove(...classnames);
});
return this;
}
function toggleclass() {
for (var _len3 = arguments.length, classes = new array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
classes[_key3] = arguments[_key3];
}
const classnames = arrayflat(classes.map(c => c.split(' ')));
this.foreach(el => {
classnames.foreach(classname => {
el.classlist.toggle(classname);
});
});
}
function hasclass() {
for (var _len4 = arguments.length, classes = new array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
classes[_key4] = arguments[_key4];
}
const classnames = arrayflat(classes.map(c => c.split(' ')));
return arrayfilter(this, el => {
return classnames.filter(classname => el.classlist.contains(classname)).length > 0;
}).length > 0;
}
function attr(attrs, value) {
if (arguments.length === 1 && typeof attrs === 'string') {
// get attr
if (this[0]) return this[0].getattribute(attrs);
return undefined;
} // set attrs
for (let i = 0; i < this.length; i += 1) {
if (arguments.length === 2) {
// string
this[i].setattribute(attrs, value);
} else {
// object
for (const attrname in attrs) {
this[i][attrname] = attrs[attrname];
this[i].setattribute(attrname, attrs[attrname]);
}
}
}
return this;
}
function removeattr(attr) {
for (let i = 0; i < this.length; i += 1) {
this[i].removeattribute(attr);
}
return this;
}
function transform(transform) {
for (let i = 0; i < this.length; i += 1) {
this[i].style.transform = transform;
}
return this;
}
function transition$1(duration) {
for (let i = 0; i < this.length; i += 1) {
this[i].style.transitionduration = typeof duration !== 'string' ? `${duration}ms` : duration;
}
return this;
}
function on() {
for (var _len5 = arguments.length, args = new array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
}
let [eventtype, targetselector, listener, capture] = args;
if (typeof args[1] === 'function') {
[eventtype, listener, capture] = args;
targetselector = undefined;
}
if (!capture) capture = false;
function handleliveevent(e) {
const target = e.target;
if (!target) return;
const eventdata = e.target.dom7eventdata || [];
if (eventdata.indexof(e) < 0) {
eventdata.unshift(e);
}
if ($(target).is(targetselector)) listener.apply(target, eventdata);else {
const parents = $(target).parents(); // eslint-disable-line
for (let k = 0; k < parents.length; k += 1) {
if ($(parents[k]).is(targetselector)) listener.apply(parents[k], eventdata);
}
}
}
function handleevent(e) {
const eventdata = e && e.target ? e.target.dom7eventdata || [] : [];
if (eventdata.indexof(e) < 0) {
eventdata.unshift(e);
}
listener.apply(this, eventdata);
}
const events = eventtype.split(' ');
let j;
for (let i = 0; i < this.length; i += 1) {
const el = this[i];
if (!targetselector) {
for (j = 0; j < events.length; j += 1) {
const event = events[j];
if (!el.dom7listeners) el.dom7listeners = {};
if (!el.dom7listeners[event]) el.dom7listeners[event] = [];
el.dom7listeners[event].push({
listener,
proxylistener: handleevent
});
el.addeventlistener(event, handleevent, {passive:false});
// el.addeventlistener(event, handleevent, capture,);
}
} else {
// live events
for (j = 0; j < events.length; j += 1) {
const event = events[j];
if (!el.dom7livelisteners) el.dom7livelisteners = {};
if (!el.dom7livelisteners[event]) el.dom7livelisteners[event] = [];
el.dom7livelisteners[event].push({
listener,
proxylistener: handleliveevent
});
el.addeventlistener(event, handleliveevent, {passive:false});
}
}
}
return this;
}
function off() {
for (var _len6 = arguments.length, args = new array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
}
let [eventtype, targetselector, listener, capture] = args;
if (typeof args[1] === 'function') {
[eventtype, listener, capture] = args;
targetselector = undefined;
}
if (!capture) capture = false;
const events = eventtype.split(' ');
for (let i = 0; i < events.length; i += 1) {
const event = events[i];
for (let j = 0; j < this.length; j += 1) {
const el = this[j];
let handlers;
if (!targetselector && el.dom7listeners) {
handlers = el.dom7listeners[event];
} else if (targetselector && el.dom7livelisteners) {
handlers = el.dom7livelisteners[event];
}
if (handlers && handlers.length) {
for (let k = handlers.length - 1; k >= 0; k -= 1) {
const handler = handlers[k];
if (listener && handler.listener === listener) {
el.removeeventlistener(event, handler.proxylistener, capture);
handlers.splice(k, 1);
} else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) {
el.removeeventlistener(event, handler.proxylistener, capture);
handlers.splice(k, 1);
} else if (!listener) {
el.removeeventlistener(event, handler.proxylistener, capture);
handlers.splice(k, 1);
}
}
}
}
}
return this;
}
function trigger() {
const window = getwindow();
for (var _len9 = arguments.length, args = new array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
args[_key9] = arguments[_key9];
}
const events = args[0].split(' ');
const eventdata = args[1];
for (let i = 0; i < events.length; i += 1) {
const event = events[i];
for (let j = 0; j < this.length; j += 1) {
const el = this[j];
if (window.customevent) {
const evt = new window.customevent(event, {
detail: eventdata,
bubbles: true,
cancelable: true
});
el.dom7eventdata = args.filter((data, dataindex) => dataindex > 0);
el.dispatchevent(evt);
el.dom7eventdata = [];
delete el.dom7eventdata;
}
}
}
return this;
}
function transitionend$1(callback) {
const dom = this;
function firecallback(e) {
if (e.target !== this) return;
callback.call(this, e);
dom.off('transitionend', firecallback);
}
if (callback) {
dom.on('transitionend', firecallback);
}
return this;
}
function outerwidth(includemargins) {
if (this.length > 0) {
if (includemargins) {
const styles = this.styles();
return this[0].offsetwidth + parsefloat(styles.getpropertyvalue('margin-right')) + parsefloat(styles.getpropertyvalue('margin-left'));
}
return this[0].offsetwidth;
}
return null;
}
function outerheight(includemargins) {
if (this.length > 0) {
if (includemargins) {
const styles = this.styles();
return this[0].offsetheight + parsefloat(styles.getpropertyvalue('margin-top')) + parsefloat(styles.getpropertyvalue('margin-bottom'));
}
return this[0].offsetheight;
}
return null;
}
function offset() {
if (this.length > 0) {
const window = getwindow();
const document = getdocument();
const el = this[0];
const box = el.getboundingclientrect();
const body = document.body;
const clienttop = el.clienttop || body.clienttop || 0;
const clientleft = el.clientleft || body.clientleft || 0;
const scrolltop = el === window ? window.scrolly : el.scrolltop;
const scrollleft = el === window ? window.scrollx : el.scrollleft;
return {
top: box.top + scrolltop - clienttop,
left: box.left + scrollleft - clientleft
};
}
return null;
}
function styles() {
const window = getwindow();
if (this[0]) return window.getcomputedstyle(this[0], null);
return {};
}
function css(props, value) {
const window = getwindow();
let i;
if (arguments.length === 1) {
if (typeof props === 'string') {
// .css('width')
if (this[0]) return window.getcomputedstyle(this[0], null).getpropertyvalue(props);
} else {
// .css({ width: '100px' })
for (i = 0; i < this.length; i += 1) {
for (const prop in props) {
this[i].style[prop] = props[prop];
}
}
return this;
}
}
if (arguments.length === 2 && typeof props === 'string') {
// .css('width', '100px')
for (i = 0; i < this.length; i += 1) {
this[i].style[props] = value;
}
return this;
}
return this;
}
function each(callback) {
if (!callback) return this;
this.foreach((el, index) => {
callback.apply(el, [el, index]);
});
return this;
}
function filter(callback) {
const result = arrayfilter(this, callback);
return $(result);
}
function html(html) {
if (typeof html === 'undefined') {
return this[0] ? this[0].innerhtml : null;
}
for (let i = 0; i < this.length; i += 1) {
this[i].innerhtml = html;
}
return this;
}
function text(text) {
if (typeof text === 'undefined') {
return this[0] ? this[0].textcontent.trim() : null;
}
for (let i = 0; i < this.length; i += 1) {
this[i].textcontent = text;
}
return this;
}
function is(selector) {
const window = getwindow();
const document = getdocument();
const el = this[0];
let comparewith;
let i;
if (!el || typeof selector === 'undefined') return false;
if (typeof selector === 'string') {
if (el.matches) return el.matches(selector);
if (el.webkitmatchesselector) return el.webkitmatchesselector(selector);
if (el.msmatchesselector) return el.msmatchesselector(selector);
comparewith = $(selector);
for (i = 0; i < comparewith.length; i += 1) {
if (comparewith[i] === el) return true;
}
return false;
}
if (selector === document) {
return el === document;
}
if (selector === window) {
return el === window;
}
if (selector.nodetype || selector instanceof dom7) {
comparewith = selector.nodetype ? [selector] : selector;
for (i = 0; i < comparewith.length; i += 1) {
if (comparewith[i] === el) return true;
}
return false;
}
return false;
}
function index() {
let child = this[0];
let i;
if (child) {
i = 0; // eslint-disable-next-line
while ((child = child.previoussibling) !== null) {
if (child.nodetype === 1) i += 1;
}
return i;
}
return undefined;
}
function eq(index) {
if (typeof index === 'undefined') return this;
const length = this.length;
if (index > length - 1) {
return $([]);
}
if (index < 0) {
const returnindex = length + index;
if (returnindex < 0) return $([]);
return $([this[returnindex]]);
}
return $([this[index]]);
}
function append() {
let newchild;
const document = getdocument();
for (let k = 0; k < arguments.length; k += 1) {
newchild = k < 0 || arguments.length <= k ? undefined : arguments[k];
for (let i = 0; i < this.length; i += 1) {
if (typeof newchild === 'string') {
const tempdiv = document.createelement('div');
tempdiv.innerhtml = newchild;
while (tempdiv.firstchild) {
this[i].appendchild(tempdiv.firstchild);
}
} else if (newchild instanceof dom7) {
for (let j = 0; j < newchild.length; j += 1) {
this[i].appendchild(newchild[j]);
}
} else {
this[i].appendchild(newchild);
}
}
}
return this;
}
function prepend(newchild) {
const document = getdocument();
let i;
let j;
for (i = 0; i < this.length; i += 1) {
if (typeof newchild === 'string') {
const tempdiv = document.createelement('div');
tempdiv.innerhtml = newchild;
for (j = tempdiv.childnodes.length - 1; j >= 0; j -= 1) {
this[i].insertbefore(tempdiv.childnodes[j], this[i].childnodes[0]);
}
} else if (newchild instanceof dom7) {
for (j = 0; j < newchild.length; j += 1) {
this[i].insertbefore(newchild[j], this[i].childnodes[0]);
}
} else {
this[i].insertbefore(newchild, this[i].childnodes[0]);
}
}
return this;
}
function next(selector) {
if (this.length > 0) {
if (selector) {
if (this[0].nextelementsibling && $(this[0].nextelementsibling).is(selector)) {
return $([this[0].nextelementsibling]);
}
return $([]);
}
if (this[0].nextelementsibling) return $([this[0].nextelementsibling]);
return $([]);
}
return $([]);
}
function nextall(selector) {
const nextels = [];
let el = this[0];
if (!el) return $([]);
while (el.nextelementsibling) {
const next = el.nextelementsibling; // eslint-disable-line
if (selector) {
if ($(next).is(selector)) nextels.push(next);
} else nextels.push(next);
el = next;
}
return $(nextels);
}
function prev(selector) {
if (this.length > 0) {
const el = this[0];
if (selector) {
if (el.previouselementsibling && $(el.previouselementsibling).is(selector)) {
return $([el.previouselementsibling]);
}
return $([]);
}
if (el.previouselementsibling) return $([el.previouselementsibling]);
return $([]);
}
return $([]);
}
function prevall(selector) {
const prevels = [];
let el = this[0];
if (!el) return $([]);
while (el.previouselementsibling) {
const prev = el.previouselementsibling; // eslint-disable-line
if (selector) {
if ($(prev).is(selector)) prevels.push(prev);
} else prevels.push(prev);
el = prev;
}
return $(prevels);
}
function parent(selector) {
const parents = []; // eslint-disable-line
for (let i = 0; i < this.length; i += 1) {
if (this[i].parentnode !== null) {
if (selector) {
if ($(this[i].parentnode).is(selector)) parents.push(this[i].parentnode);
} else {
parents.push(this[i].parentnode);
}
}
}
return $(parents);
}
function parents(selector) {
const parents = []; // eslint-disable-line
for (let i = 0; i < this.length; i += 1) {
let parent = this[i].parentnode; // eslint-disable-line
while (parent) {
if (selector) {
if ($(parent).is(selector)) parents.push(parent);
} else {
parents.push(parent);
}
parent = parent.parentnode;
}
}
return $(parents);
}
function closest(selector) {
let closest = this; // eslint-disable-line
if (typeof selector === 'undefined') {
return $([]);
}
if (!closest.is(selector)) {
closest = closest.parents(selector).eq(0);
}
return closest;
}
function find(selector) {
const foundelements = [];
for (let i = 0; i < this.length; i += 1) {
const found = this[i].queryselectorall(selector);
for (let j = 0; j < found.length; j += 1) {
foundelements.push(found[j]);
}
}
return $(foundelements);
}
function children(selector) {
const children = []; // eslint-disable-line
for (let i = 0; i < this.length; i += 1) {
const childnodes = this[i].children;
for (let j = 0; j < childnodes.length; j += 1) {
if (!selector || $(childnodes[j]).is(selector)) {
children.push(childnodes[j]);
}
}
}
return $(children);
}
function remove() {
for (let i = 0; i < this.length; i += 1) {
if (this[i].parentnode) this[i].parentnode.removechild(this[i]);
}
return this;
}
const methods = {
addclass,
removeclass,
hasclass,
toggleclass,
attr,
removeattr,
transform,
transition: transition$1,
on,
off,
trigger,
transitionend: transitionend$1,
outerwidth,
outerheight,
styles,
offset,
css,
each,
html,
text,
is,
index,
eq,
append,
prepend,
next,
nextall,
prev,
prevall,
parent,
parents,
closest,
find,
children,
filter,
remove
};
object.keys(methods).foreach(methodname => {
object.defineproperty($.fn, methodname, {
value: methods[methodname],
writable: true
});
});
function deleteprops(obj) {
const object = obj;
object.keys(object).foreach(key => {
try {
object[key] = null;
} catch (e) {// no getter for object
}
try {
delete object[key];
} catch (e) {// something got wrong
}
});
}
function nexttick(callback, delay) {
if (delay === void 0) {
delay = 0;
}
return settimeout(callback, delay);
}
function now() {
return date.now();
}
function getcomputedstyle$1(el) {
const window = getwindow();
let style;
if (window.getcomputedstyle) {
style = window.getcomputedstyle(el, null);
}
if (!style && el.currentstyle) {
style = el.currentstyle;
}
if (!style) {
style = el.style;
}
return style;
}
function gettranslate(el, axis) {
if (axis === void 0) {
axis = 'x';
}
const window = getwindow();
let matrix;
let curtransform;
let transformmatrix;
const curstyle = getcomputedstyle$1(el);
if (window.webkitcssmatrix) {
curtransform = curstyle.transform || curstyle.webkittransform;
if (curtransform.split(',').length > 6) {
curtransform = curtransform.split(', ').map(a => a.replace(',', '.')).join(', ');
} // some old versions of webkit choke when 'none' is passed; pass
// empty string instead in this case
transformmatrix = new window.webkitcssmatrix(curtransform === 'none' ? '' : curtransform);
} else {
transformmatrix = curstyle.moztransform || curstyle.otransform || curstyle.mstransform || curstyle.mstransform || curstyle.transform || curstyle.getpropertyvalue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
matrix = transformmatrix.tostring().split(',');
}
if (axis === 'x') {
// latest chrome and webkits fix
if (window.webkitcssmatrix) curtransform = transformmatrix.m41; // crazy ie10 matrix
else if (matrix.length === 16) curtransform = parsefloat(matrix[12]); // normal browsers
else curtransform = parsefloat(matrix[4]);
}
if (axis === 'y') {
// latest chrome and webkits fix
if (window.webkitcssmatrix) curtransform = transformmatrix.m42; // crazy ie10 matrix
else if (matrix.length === 16) curtransform = parsefloat(matrix[13]); // normal browsers
else curtransform = parsefloat(matrix[5]);
}
return curtransform || 0;
}
function isobject(o) {
return typeof o === 'object' && o !== null && o.constructor && object.prototype.tostring.call(o).slice(8, -1) === 'object';
}
function isnode(node) {
// eslint-disable-next-line
if (typeof window !== 'undefined' && typeof window.htmlelement !== 'undefined') {
return node instanceof htmlelement;
}
return node && (node.nodetype === 1 || node.nodetype === 11);
}
function extend() {
const to = object(arguments.length <= 0 ? undefined : arguments[0]);
const noextend = ['__proto__', 'constructor', 'prototype'];
for (let i = 1; i < arguments.length; i += 1) {
const nextsource = i < 0 || arguments.length <= i ? undefined : arguments[i];
if (nextsource !== undefined && nextsource !== null && !isnode(nextsource)) {
const keysarray = object.keys(object(nextsource)).filter(key => noextend.indexof(key) < 0);
for (let nextindex = 0, len = keysarray.length; nextindex < len; nextindex += 1) {
const nextkey = keysarray[nextindex];
const desc = object.getownpropertydescriptor(nextsource, nextkey);
if (desc !== undefined && desc.enumerable) {
if (isobject(to[nextkey]) && isobject(nextsource[nextkey])) {
if (nextsource[nextkey].__swiper__) {
to[nextkey] = nextsource[nextkey];
} else {
extend(to[nextkey], nextsource[nextkey]);
}
} else if (!isobject(to[nextkey]) && isobject(nextsource[nextkey])) {
to[nextkey] = {};
if (nextsource[nextkey].__swiper__) {
to[nextkey] = nextsource[nextkey];
} else {
extend(to[nextkey], nextsource[nextkey]);
}
} else {
to[nextkey] = nextsource[nextkey];
}
}
}
}
}
return to;
}
function setcssproperty(el, varname, varvalue) {
el.style.setproperty(varname, varvalue);
}
function animatecssmodescroll(_ref) {
let {
swiper,
targetposition,
side
} = _ref;
const window = getwindow();
const startposition = -swiper.translate;
let starttime = null;
let time;
const duration = swiper.params.speed;
swiper.wrapperel.style.scrollsnaptype = 'none';
window.cancelanimationframe(swiper.cssmodeframeid);
const dir = targetposition > startposition ? 'next' : 'prev';
const isoutofbound = (current, target) => {
return dir === 'next' && current >= target || dir === 'prev' && current <= target;
};
const animate = () => {
time = new date().gettime();
if (starttime === null) {
starttime = time;
}
const progress = math.max(math.min((time - starttime) / duration, 1), 0);
const easeprogress = 0.5 - math.cos(progress * math.pi) / 2;
let currentposition = startposition + easeprogress * (targetposition - startposition);
if (isoutofbound(currentposition, targetposition)) {
currentposition = targetposition;
}
swiper.wrapperel.scrollto({
[side]: currentposition
});
if (isoutofbound(currentposition, targetposition)) {
swiper.wrapperel.style.overflow = 'hidden';
swiper.wrapperel.style.scrollsnaptype = '';
settimeout(() => {
swiper.wrapperel.style.overflow = '';
swiper.wrapperel.scrollto({
[side]: currentposition
});
});
window.cancelanimationframe(swiper.cssmodeframeid);
return;
}
swiper.cssmodeframeid = window.requestanimationframe(animate);
};
animate();
}
let support;
function calcsupport() {
const window = getwindow();
const document = getdocument();
return {
smoothscroll: document.documentelement && 'scrollbehavior' in document.documentelement.style,
touch: !!('ontouchstart' in window || window.documenttouch && document instanceof window.documenttouch),
passivelistener: function checkpassivelistener() {
let supportspassive = false;
try {
const opts = object.defineproperty({}, 'passive', {
// eslint-disable-next-line
get() {
supportspassive = true;
}
});
window.addeventlistener('testpassivelistener', null, opts);
} catch (e) {// no support
}
return supportspassive;
}(),
gestures: function checkgestures() {
return 'ongesturestart' in window;
}()
};
}
function getsupport() {
if (!support) {
support = calcsupport();
}
return support;
}
let devicecached;
function calcdevice(_temp) {
let {
useragent
} = _temp === void 0 ? {} : _temp;
const support = getsupport();
const window = getwindow();
const platform = window.navigator.platform;
const ua = useragent || window.navigator.useragent;
const device = {
ios: false,
android: false
};
const screenwidth = window.screen.width;
const screenheight = window.screen.height;
const android = ua.match(/(android);?[\s\/]+([\d.]+)?/); // eslint-disable-line
let ipad = ua.match(/(ipad).*os\s([\d_]+)/);
const ipod = ua.match(/(ipod)(.*os\s([\d_]+))?/);
const iphone = !ipad && ua.match(/(iphone\sos|ios)\s([\d_]+)/);
const windows = platform === 'win32';
let macos = platform === 'macintel'; // ipados 13 fix
const ipadscreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
if (!ipad && macos && support.touch && ipadscreens.indexof(`${screenwidth}x${screenheight}`) >= 0) {
ipad = ua.match(/(version)\/([\d.]+)/);
if (!ipad) ipad = [0, 1, '13_0_0'];
macos = false;
} // android
if (android && !windows) {
device.os = 'android';
device.android = true;
}
if (ipad || iphone || ipod) {
device.os = 'ios';
device.ios = true;
} // export object
return device;
}
function getdevice(overrides) {
if (overrides === void 0) {
overrides = {};
}
if (!devicecached) {
devicecached = calcdevice(overrides);
}
return devicecached;
}
let browser;
function calcbrowser() {
const window = getwindow();
function issafari() {
const ua = window.navigator.useragent.tolowercase();
return ua.indexof('safari') >= 0 && ua.indexof('chrome') < 0 && ua.indexof('android') < 0;
}
return {
issafari: issafari(),
iswebview: /(iphone|ipod|ipad).*applewebkit(?!.*safari)/i.test(window.navigator.useragent)
};
}
function getbrowser() {
if (!browser) {
browser = calcbrowser();
}
return browser;
}
function resize(_ref) {
let {
swiper,
on,
emit
} = _ref;
const window = getwindow();
let observer = null;
let animationframe = null;
const resizehandler = () => {
if (!swiper || swiper.destroyed || !swiper.initialized) return;
emit('beforeresize');
emit('resize');
};
const createobserver = () => {
if (!swiper || swiper.destroyed || !swiper.initialized) return;
observer = new resizeobserver(entries => {
animationframe = window.requestanimationframe(() => {
const {
width,
height
} = swiper;
let newwidth = width;
let newheight = height;
entries.foreach(_ref2 => {
let {
contentboxsize,
contentrect,
target
} = _ref2;
if (target && target !== swiper.el) return;
newwidth = contentrect ? contentrect.width : (contentboxsize[0] || contentboxsize).inlinesize;
newheight = contentrect ? contentrect.height : (contentboxsize[0] || contentboxsize).blocksize;
});
if (newwidth !== width || newheight !== height) {
resizehandler();
}
});
});
observer.observe(swiper.el);
};
const removeobserver = () => {
if (animationframe) {
window.cancelanimationframe(animationframe);
}
if (observer && observer.unobserve && swiper.el) {
observer.unobserve(swiper.el);
observer = null;
}
};
const orientationchangehandler = () => {
if (!swiper || swiper.destroyed || !swiper.initialized) return;
emit('orientationchange');
};
on('init', () => {
if (swiper.params.resizeobserver && typeof window.resizeobserver !== 'undefined') {
createobserver();
return;
}
window.addeventlistener('resize', resizehandler);
window.addeventlistener('orientationchange', orientationchangehandler);
});
on('destroy', () => {
removeobserver();
window.removeeventlistener('resize', resizehandler);
window.removeeventlistener('orientationchange', orientationchangehandler);
});
}
function observer(_ref) {
let {
swiper,
extendparams,
on,
emit
} = _ref;
const observers = [];
const window = getwindow();
const attach = function (target, options) {
if (options === void 0) {
options = {};
}
const observerfunc = window.mutationobserver || window.webkitmutationobserver;
const observer = new observerfunc(mutations => {
// the observerupdate event should only be triggered
// once despite the number of mutations. additional
// triggers are redundant and are very costly
if (mutations.length === 1) {
emit('observerupdate', mutations[0]);
return;
}
const observerupdate = function observerupdate() {
emit('observerupdate', mutations[0]);
};
if (window.requestanimationframe) {
window.requestanimationframe(observerupdate);
} else {
window.settimeout(observerupdate, 0);
}
});
observer.observe(target, {
attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
childlist: typeof options.childlist === 'undefined' ? true : options.childlist,
characterdata: typeof options.characterdata === 'undefined' ? true : options.characterdata
});
observers.push(observer);
};
const init = () => {
if (!swiper.params.observer) return;
if (swiper.params.observeparents) {
const containerparents = swiper.$el.parents();
for (let i = 0; i < containerparents.length; i += 1) {
attach(containerparents[i]);
}
} // observe container
attach(swiper.$el[0], {
childlist: swiper.params.observeslidechildren
}); // observe wrapper
attach(swiper.$wrapperel[0], {
attributes: false
});
};
const destroy = () => {
observers.foreach(observer => {
observer.disconnect();
});
observers.splice(0, observers.length);
};
extendparams({
observer: false,
observeparents: false,
observeslidechildren: false
});
on('init', init);
on('destroy', destroy);
}
/* eslint-disable no-underscore-dangle */
var eventsemitter = {
on(events, handler, priority) {
const self = this;
if (!self.eventslisteners || self.destroyed) return self;
if (typeof handler !== 'function') return self;
const method = priority ? 'unshift' : 'push';
events.split(' ').foreach(event => {
if (!self.eventslisteners[event]) self.eventslisteners[event] = [];
self.eventslisteners[event][method](handler);
});
return self;
},
once(events, handler, priority) {
const self = this;
if (!self.eventslisteners || self.destroyed) return self;
if (typeof handler !== 'function') return self;
function oncehandler() {
self.off(events, oncehandler);
if (oncehandler.__emitterproxy) {
delete oncehandler.__emitterproxy;
}
for (var _len = arguments.length, args = new array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
handler.apply(self, args);
}
oncehandler.__emitterproxy = handler;
return self.on(events, oncehandler, priority);
},
onany(handler, priority) {
const self = this;
if (!self.eventslisteners || self.destroyed) return self;
if (typeof handler !== 'function') return self;
const method = priority ? 'unshift' : 'push';
if (self.eventsanylisteners.indexof(handler) < 0) {
self.eventsanylisteners[method](handler);
}
return self;
},
offany(handler) {
const self = this;
if (!self.eventslisteners || self.destroyed) return self;
if (!self.eventsanylisteners) return self;
const index = self.eventsanylisteners.indexof(handler);
if (index >= 0) {
self.eventsanylisteners.splice(index, 1);
}
return self;
},
off(events, handler) {
const self = this;
if (!self.eventslisteners || self.destroyed) return self;
if (!self.eventslisteners) return self;
events.split(' ').foreach(event => {
if (typeof handler === 'undefined') {
self.eventslisteners[event] = [];
} else if (self.eventslisteners[event]) {
self.eventslisteners[event].foreach((eventhandler, index) => {
if (eventhandler === handler || eventhandler.__emitterproxy && eventhandler.__emitterproxy === handler) {
self.eventslisteners[event].splice(index, 1);
}
});
}
});
return self;
},
emit() {
const self = this;
if (!self.eventslisteners || self.destroyed) return self;
if (!self.eventslisteners) return self;
let events;
let data;
let context;
for (var _len2 = arguments.length, args = new array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
if (typeof args[0] === 'string' || array.isarray(args[0])) {
events = args[0];
data = args.slice(1, args.length);
context = self;
} else {
events = args[0].events;
data = args[0].data;
context = args[0].context || self;
}
data.unshift(context);
const eventsarray = array.isarray(events) ? events : events.split(' ');
eventsarray.foreach(event => {
if (self.eventsanylisteners && self.eventsanylisteners.length) {
self.eventsanylisteners.foreach(eventhandler => {
eventhandler.apply(context, [event, ...data]);
});
}
if (self.eventslisteners && self.eventslisteners[event]) {
self.eventslisteners[event].foreach(eventhandler => {
eventhandler.apply(context, data);
});
}
});
return self;
}
};
function updatesize() {
const swiper = this;
let width;
let height;
const $el = swiper.$el;
if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
width = swiper.params.width;
} else {
width = $el[0].clientwidth;
}
if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
height = swiper.params.height;
} else {
height = $el[0].clientheight;
}
if (width === 0 && swiper.ishorizontal() || height === 0 && swiper.isvertical()) {
return;
} // subtract paddings
width = width - parseint($el.css('padding-left') || 0, 10) - parseint($el.css('padding-right') || 0, 10);
height = height - parseint($el.css('padding-top') || 0, 10) - parseint($el.css('padding-bottom') || 0, 10);
if (number.isnan(width)) width = 0;
if (number.isnan(height)) height = 0;
object.assign(swiper, {
width,
height,
size: swiper.ishorizontal() ? width : height
});
}
function updateslides() {
const swiper = this;
function getdirectionlabel(property) {
if (swiper.ishorizontal()) {
return property;
} // prettier-ignore
return {
'width': 'height',
'margin-top': 'margin-left',
'margin-bottom ': 'margin-right',
'margin-left': 'margin-top',
'margin-right': 'margin-bottom',
'padding-left': 'padding-top',
'padding-right': 'padding-bottom',
'marginright': 'marginbottom'
}[property];
}
function getdirectionpropertyvalue(node, label) {
return parsefloat(node.getpropertyvalue(getdirectionlabel(label)) || 0);
}
const params = swiper.params;
const {
$wrapperel,
size: swipersize,
rtltranslate: rtl,
wrongrtl
} = swiper;
const isvirtual = swiper.virtual && params.virtual.enabled;
const previousslideslength = isvirtual ? swiper.virtual.slides.length : swiper.slides.length;
const slides = $wrapperel.children(`.${swiper.params.slideclass}`);
const slideslength = isvirtual ? swiper.virtual.slides.length : slides.length;
let snapgrid = [];
const slidesgrid = [];
const slidessizesgrid = [];
let offsetbefore = params.slidesoffsetbefore;
if (typeof offsetbefore === 'function') {
offsetbefore = params.slidesoffsetbefore.call(swiper);
}
let offsetafter = params.slidesoffsetafter;
if (typeof offsetafter === 'function') {
offsetafter = params.slidesoffsetafter.call(swiper);
}
const previoussnapgridlength = swiper.snapgrid.length;
const previousslidesgridlength = swiper.slidesgrid.length;
let spacebetween = params.spacebetween;
let slideposition = -offsetbefore;
let prevslidesize = 0;
let index = 0;
if (typeof swipersize === 'undefined') {
return;
}
if (typeof spacebetween === 'string' && spacebetween.indexof('%') >= 0) {
spacebetween = parsefloat(spacebetween.replace('%', '')) / 100 * swipersize;
}
swiper.virtualsize = -spacebetween; // reset margins
if (rtl) slides.css({
marginleft: '',
marginbottom: '',
margintop: ''
});else slides.css({
marginright: '',
marginbottom: '',
margintop: ''
}); // reset cssmode offsets
if (params.centeredslides && params.cssmode) {
setcssproperty(swiper.wrapperel, '--swiper-centered-offset-before', '');
setcssproperty(swiper.wrapperel, '--swiper-centered-offset-after', '');
}
const gridenabled = params.grid && params.grid.rows > 1 && swiper.grid;
if (gridenabled) {
swiper.grid.initslides(slideslength);
} // calc slides
let slidesize;
const shouldresetslidesize = params.slidesperview === 'auto' && params.breakpoints && object.keys(params.breakpoints).filter(key => {
return typeof params.breakpoints[key].slidesperview !== 'undefined';
}).length > 0;
for (let i = 0; i < slideslength; i += 1) {
slidesize = 0;
const slide = slides.eq(i);
if (gridenabled) {
swiper.grid.updateslide(i, slide, slideslength, getdirectionlabel);
}
if (slide.css('display') === 'none') continue; // eslint-disable-line
if (params.slidesperview === 'auto') {
if (shouldresetslidesize) {
slides[i].style[getdirectionlabel('width')] = ``;
}
const slidestyles = getcomputedstyle(slide[0]);
const currenttransform = slide[0].style.transform;
const currentwebkittransform = slide[0].style.webkittransform;
if (currenttransform) {
slide[0].style.transform = 'none';
}
if (currentwebkittransform) {
slide[0].style.webkittransform = 'none';
}
if (params.roundlengths) {
slidesize = swiper.ishorizontal() ? slide.outerwidth(true) : slide.outerheight(true);
} else {
// eslint-disable-next-line
const width = getdirectionpropertyvalue(slidestyles, 'width');
const paddingleft = getdirectionpropertyvalue(slidestyles, 'padding-left');
const paddingright = getdirectionpropertyvalue(slidestyles, 'padding-right');
const marginleft = getdirectionpropertyvalue(slidestyles, 'margin-left');
const marginright = getdirectionpropertyvalue(slidestyles, 'margin-right');
const boxsizing = slidestyles.getpropertyvalue('box-sizing');
if (boxsizing && boxsizing === 'border-box') {
slidesize = width + marginleft + marginright;
} else {
const {
clientwidth,
offsetwidth
} = slide[0];
slidesize = width + paddingleft + paddingright + marginleft + marginright + (offsetwidth - clientwidth);
}
}
if (currenttransform) {
slide[0].style.transform = currenttransform;
}
if (currentwebkittransform) {
slide[0].style.webkittransform = currentwebkittransform;
}
if (params.roundlengths) slidesize = math.floor(slidesize);
} else {
slidesize = (swipersize - (params.slidesperview - 1) * spacebetween) / params.slidesperview;
if (params.roundlengths) slidesize = math.floor(slidesize);
if (slides[i]) {
slides[i].style[getdirectionlabel('width')] = `${slidesize}px`;
}
}
if (slides[i]) {
slides[i].swiperslidesize = slidesize;
}
slidessizesgrid.push(slidesize);
if (params.centeredslides) {
slideposition = slideposition + slidesize / 2 + prevslidesize / 2 + spacebetween;
if (prevslidesize === 0 && i !== 0) slideposition = slideposition - swipersize / 2 - spacebetween;
if (i === 0) slideposition = slideposition - swipersize / 2 - spacebetween;
if (math.abs(slideposition) < 1 / 1000) slideposition = 0;
if (params.roundlengths) slideposition = math.floor(slideposition);
if (index % params.slidespergroup === 0) snapgrid.push(slideposition);
slidesgrid.push(slideposition);
} else {
if (params.roundlengths) slideposition = math.floor(slideposition);
if ((index - math.min(swiper.params.slidespergroupskip, index)) % swiper.params.slidespergroup === 0) snapgrid.push(slideposition);
slidesgrid.push(slideposition);
slideposition = slideposition + slidesize + spacebetween;
}
swiper.virtualsize += slidesize + spacebetween;
prevslidesize = slidesize;
index += 1;
}
swiper.virtualsize = math.max(swiper.virtualsize, swipersize) + offsetafter;
if (rtl && wrongrtl && (params.effect === 'slide' || params.effect === 'coverflow')) {
$wrapperel.css({
width: `${swiper.virtualsize + params.spacebetween}px`
});
}
if (params.setwrappersize) {
$wrapperel.css({
[getdirectionlabel('width')]: `${swiper.virtualsize + params.spacebetween}px`
});
}
if (gridenabled) {
swiper.grid.updatewrappersize(slidesize, snapgrid, getdirectionlabel);
} // remove last grid elements depending on width
if (!params.centeredslides) {
const newslidesgrid = [];
for (let i = 0; i < snapgrid.length; i += 1) {
let slidesgriditem = snapgrid[i];
if (params.roundlengths) slidesgriditem = math.floor(slidesgriditem);
if (snapgrid[i] <= swiper.virtualsize - swipersize) {
newslidesgrid.push(slidesgriditem);
}
}
snapgrid = newslidesgrid;
if (math.floor(swiper.virtualsize - swipersize) - math.floor(snapgrid[snapgrid.length - 1]) > 1) {
snapgrid.push(swiper.virtualsize - swipersize);
}
}
if (snapgrid.length === 0) snapgrid = [0];
if (params.spacebetween !== 0) {
const key = swiper.ishorizontal() && rtl ? 'marginleft' : getdirectionlabel('marginright');
slides.filter((_, slideindex) => {
if (!params.cssmode) return true;
if (slideindex === slides.length - 1) {
return false;
}
return true;
}).css({
[key]: `${spacebetween}px`
});
}
if (params.centeredslides && params.centeredslidesbounds) {
let allslidessize = 0;
slidessizesgrid.foreach(slidesizevalue => {
allslidessize += slidesizevalue + (params.spacebetween ? params.spacebetween : 0);
});
allslidessize -= params.spacebetween;
const maxsnap = allslidessize - swipersize;
snapgrid = snapgrid.map(snap => {
if (snap < 0) return -offsetbefore;
if (snap > maxsnap) return maxsnap + offsetafter;
return snap;
});
}
if (params.centerinsufficientslides) {
let allslidessize = 0;
slidessizesgrid.foreach(slidesizevalue => {
allslidessize += slidesizevalue + (params.spacebetween ? params.spacebetween : 0);
});
allslidessize -= params.spacebetween;
if (allslidessize < swipersize) {
const allslidesoffset = (swipersize - allslidessize) / 2;
snapgrid.foreach((snap, snapindex) => {
snapgrid[snapindex] = snap - allslidesoffset;
});
slidesgrid.foreach((snap, snapindex) => {
slidesgrid[snapindex] = snap + allslidesoffset;
});
}
}
object.assign(swiper, {
slides,
snapgrid,
slidesgrid,
slidessizesgrid
});
if (params.centeredslides && params.cssmode && !params.centeredslidesbounds) {
setcssproperty(swiper.wrapperel, '--swiper-centered-offset-before', `${-snapgrid[0]}px`);
setcssproperty(swiper.wrapperel, '--swiper-centered-offset-after', `${swiper.size / 2 - slidessizesgrid[slidessizesgrid.length - 1] / 2}px`);
const addtosnapgrid = -swiper.snapgrid[0];
const addtoslidesgrid = -swiper.slidesgrid[0];
swiper.snapgrid = swiper.snapgrid.map(v => v + addtosnapgrid);
swiper.slidesgrid = swiper.slidesgrid.map(v => v + addtoslidesgrid);
}
if (slideslength !== previousslideslength) {
swiper.emit('slideslengthchange');
}
if (snapgrid.length !== previoussnapgridlength) {
if (swiper.params.watchoverflow) swiper.checkoverflow();
swiper.emit('snapgridlengthchange');
}
if (slidesgrid.length !== previousslidesgridlength) {
swiper.emit('slidesgridlengthchange');
}
if (params.watchslidesprogress) {
swiper.updateslidesoffset();
}
if (!isvirtual && !params.cssmode && (params.effect === 'slide' || params.effect === 'fade')) {
const backfacehiddenclass = `${params.containermodifierclass}backface-hidden`;
const hasclassbackfaceclassadded = swiper.$el.hasclass(backfacehiddenclass);
if (slideslength <= params.maxbackfacehiddenslides) {
if (!hasclassbackfaceclassadded) swiper.$el.addclass(backfacehiddenclass);
} else if (hasclassbackfaceclassadded) {
swiper.$el.removeclass(backfacehiddenclass);
}
}
}
function updateautoheight(speed) {
const swiper = this;
const activeslides = [];
const isvirtual = swiper.virtual && swiper.params.virtual.enabled;
let newheight = 0;
let i;
if (typeof speed === 'number') {
swiper.settransition(speed);
} else if (speed === true) {
swiper.settransition(swiper.params.speed);
}
const getslidebyindex = index => {
if (isvirtual) {
return swiper.slides.filter(el => parseint(el.getattribute('data-swiper-slide-index'), 10) === index)[0];
}
return swiper.slides.eq(index)[0];
}; // find slides currently in view
if (swiper.params.slidesperview !== 'auto' && swiper.params.slidesperview > 1) {
if (swiper.params.centeredslides) {
(swiper.visibleslides || $([])).each(slide => {
activeslides.push(slide);
});
} else {
for (i = 0; i < math.ceil(swiper.params.slidesperview); i += 1) {
const index = swiper.activeindex + i;
if (index > swiper.slides.length && !isvirtual) break;
activeslides.push(getslidebyindex(index));
}
}
} else {
activeslides.push(getslidebyindex(swiper.activeindex));
} // find new height from highest slide in view
for (i = 0; i < activeslides.length; i += 1) {
if (typeof activeslides[i] !== 'undefined') {
const height = activeslides[i].offsetheight;
newheight = height > newheight ? height : newheight;
}
} // update height
if (newheight || newheight === 0) swiper.$wrapperel.css('height', `${newheight}px`);
}
function updateslidesoffset() {
const swiper = this;
const slides = swiper.slides;
for (let i = 0; i < slides.length; i += 1) {
slides[i].swiperslideoffset = swiper.ishorizontal() ? slides[i].offsetleft : slides[i].offsettop;
}
}
function updateslidesprogress(translate) {
if (translate === void 0) {
translate = this && this.translate || 0;
}
const swiper = this;
const params = swiper.params;
const {
slides,
rtltranslate: rtl,
snapgrid
} = swiper;
if (slides.length === 0) return;
if (typeof slides[0].swiperslideoffset === 'undefined') swiper.updateslidesoffset();
let offsetcenter = -translate;
if (rtl) offsetcenter = translate; // visible slides
slides.removeclass(params.slidevisibleclass);
swiper.visibleslidesindexes = [];
swiper.visibleslides = [];
for (let i = 0; i < slides.length; i += 1) {
const slide = slides[i];
let slideoffset = slide.swiperslideoffset;
if (params.cssmode && params.centeredslides) {
slideoffset -= slides[0].swiperslideoffset;
}
const slideprogress = (offsetcenter + (params.centeredslides ? swiper.mintranslate() : 0) - slideoffset) / (slide.swiperslidesize + params.spacebetween);
const originalslideprogress = (offsetcenter - snapgrid[0] + (params.centeredslides ? swiper.mintranslate() : 0) - slideoffset) / (slide.swiperslidesize + params.spacebetween);
const slidebefore = -(offsetcenter - slideoffset);
const slideafter = slidebefore + swiper.slidessizesgrid[i];
const isvisible = slidebefore >= 0 && slidebefore < swiper.size - 1 || slideafter > 1 && slideafter <= swiper.size || slidebefore <= 0 && slideafter >= swiper.size;
if (isvisible) {
swiper.visibleslides.push(slide);
swiper.visibleslidesindexes.push(i);
slides.eq(i).addclass(params.slidevisibleclass);
}
slide.progress = rtl ? -slideprogress : slideprogress;
slide.originalprogress = rtl ? -originalslideprogress : originalslideprogress;
}
swiper.visibleslides = $(swiper.visibleslides);
}
function updateprogress(translate) {
const swiper = this;
if (typeof translate === 'undefined') {
const multiplier = swiper.rtltranslate ? -1 : 1; // eslint-disable-next-line
translate = swiper && swiper.translate && swiper.translate * multiplier || 0;
}
const params = swiper.params;
const translatesdiff = swiper.maxtranslate() - swiper.mintranslate();
let {
progress,
isbeginning,
isend
} = swiper;
const wasbeginning = isbeginning;
const wasend = isend;
if (translatesdiff === 0) {
progress = 0;
isbeginning = true;
isend = true;
} else {
progress = (translate - swiper.mintranslate()) / translatesdiff;
isbeginning = progress <= 0;
isend = progress >= 1;
}
object.assign(swiper, {
progress,
isbeginning,
isend
});
if (params.watchslidesprogress || params.centeredslides && params.autoheight) swiper.updateslidesprogress(translate);
if (isbeginning && !wasbeginning) {
swiper.emit('reachbeginning toedge');
}
if (isend && !wasend) {
swiper.emit('reachend toedge');
}
if (wasbeginning && !isbeginning || wasend && !isend) {
swiper.emit('fromedge');
}
swiper.emit('progress', progress);
}
function updateslidesclasses() {
const swiper = this;
const {
slides,
params,
$wrapperel,
activeindex,
realindex
} = swiper;
const isvirtual = swiper.virtual && params.virtual.enabled;
slides.removeclass(`${params.slideactiveclass} ${params.slidenextclass} ${params.slideprevclass} ${params.slideduplicateactiveclass} ${params.slideduplicatenextclass} ${params.slideduplicateprevclass}`);
let activeslide;
if (isvirtual) {
activeslide = swiper.$wrapperel.find(`.${params.slideclass}[data-swiper-slide-index="${activeindex}"]`);
} else {
activeslide = slides.eq(activeindex);
} // active classes
activeslide.addclass(params.slideactiveclass);
if (params.loop) {
// duplicate to all looped slides
if (activeslide.hasclass(params.slideduplicateclass)) {
$wrapperel.children(`.${params.slideclass}:not(.${params.slideduplicateclass})[data-swiper-slide-index="${realindex}"]`).addclass(params.slideduplicateactiveclass);
} else {
$wrapperel.children(`.${params.slideclass}.${params.slideduplicateclass}[data-swiper-slide-index="${realindex}"]`).addclass(params.slideduplicateactiveclass);
}
} // next slide
let nextslide = activeslide.nextall(`.${params.slideclass}`).eq(0).addclass(params.slidenextclass);
if (params.loop && nextslide.length === 0) {
nextslide = slides.eq(0);
nextslide.addclass(params.slidenextclass);
} // prev slide
let prevslide = activeslide.prevall(`.${params.slideclass}`).eq(0).addclass(params.slideprevclass);
if (params.loop && prevslide.length === 0) {
prevslide = slides.eq(-1);
prevslide.addclass(params.slideprevclass);
}
if (params.loop) {
// duplicate to all looped slides
if (nextslide.hasclass(params.slideduplicateclass)) {
$wrapperel.children(`.${params.slideclass}:not(.${params.slideduplicateclass})[data-swiper-slide-index="${nextslide.attr('data-swiper-slide-index')}"]`).addclass(params.slideduplicatenextclass);
} else {
$wrapperel.children(`.${params.slideclass}.${params.slideduplicateclass}[data-swiper-slide-index="${nextslide.attr('data-swiper-slide-index')}"]`).addclass(params.slideduplicatenextclass);
}
if (prevslide.hasclass(params.slideduplicateclass)) {
$wrapperel.children(`.${params.slideclass}:not(.${params.slideduplicateclass})[data-swiper-slide-index="${prevslide.attr('data-swiper-slide-index')}"]`).addclass(params.slideduplicateprevclass);
} else {
$wrapperel.children(`.${params.slideclass}.${params.slideduplicateclass}[data-swiper-slide-index="${prevslide.attr('data-swiper-slide-index')}"]`).addclass(params.slideduplicateprevclass);
}
}
swiper.emitslidesclasses();
}
function updateactiveindex(newactiveindex) {
const swiper = this;
const translate = swiper.rtltranslate ? swiper.translate : -swiper.translate;
const {
slidesgrid,
snapgrid,
params,
activeindex: previousindex,
realindex: previousrealindex,
snapindex: previoussnapindex
} = swiper;
let activeindex = newactiveindex;
let snapindex;
if (typeof activeindex === 'undefined') {
for (let i = 0; i < slidesgrid.length; i += 1) {
if (typeof slidesgrid[i + 1] !== 'undefined') {
if (translate >= slidesgrid[i] && translate < slidesgrid[i + 1] - (slidesgrid[i + 1] - slidesgrid[i]) / 2) {
activeindex = i;
} else if (translate >= slidesgrid[i] && translate < slidesgrid[i + 1]) {
activeindex = i + 1;
}
} else if (translate >= slidesgrid[i]) {
activeindex = i;
}
} // normalize slideindex
if (params.normalizeslideindex) {
if (activeindex < 0 || typeof activeindex === 'undefined') activeindex = 0;
}
}
if (snapgrid.indexof(translate) >= 0) {
snapindex = snapgrid.indexof(translate);
} else {
const skip = math.min(params.slidespergroupskip, activeindex);
snapindex = skip + math.floor((activeindex - skip) / params.slidespergroup);
}
if (snapindex >= snapgrid.length) snapindex = snapgrid.length - 1;
if (activeindex === previousindex) {
if (snapindex !== previoussnapindex) {
swiper.snapindex = snapindex;
swiper.emit('snapindexchange');
}
return;
} // get real index
const realindex = parseint(swiper.slides.eq(activeindex).attr('data-swiper-slide-index') || activeindex, 10);
object.assign(swiper, {
snapindex,
realindex,
previousindex,
activeindex
});
swiper.emit('activeindexchange');
swiper.emit('snapindexchange');
if (previousrealindex !== realindex) {
swiper.emit('realindexchange');
}
if (swiper.initialized || swiper.params.runcallbacksoninit) {
swiper.emit('slidechange');
}
}
function updateclickedslide(e) {
const swiper = this;
const params = swiper.params;
const slide = $(e).closest(`.${params.slideclass}`)[0];
let slidefound = false;
let slideindex;
if (slide) {
for (let i = 0; i < swiper.slides.length; i += 1) {
if (swiper.slides[i] === slide) {
slidefound = true;
slideindex = i;
break;
}
}
}
if (slide && slidefound) {
swiper.clickedslide = slide;
if (swiper.virtual && swiper.params.virtual.enabled) {
swiper.clickedindex = parseint($(slide).attr('data-swiper-slide-index'), 10);
} else {
swiper.clickedindex = slideindex;
}
} else {
swiper.clickedslide = undefined;
swiper.clickedindex = undefined;
return;
}
if (params.slidetoclickedslide && swiper.clickedindex !== undefined && swiper.clickedindex !== swiper.activeindex) {
swiper.slidetoclickedslide();
}
}
var update = {
updatesize,
updateslides,
updateautoheight,
updateslidesoffset,
updateslidesprogress,
updateprogress,
updateslidesclasses,
updateactiveindex,
updateclickedslide
};
function getswipertranslate(axis) {
if (axis === void 0) {
axis = this.ishorizontal() ? 'x' : 'y';
}
const swiper = this;
const {
params,
rtltranslate: rtl,
translate,
$wrapperel
} = swiper;
if (params.virtualtranslate) {
return rtl ? -translate : translate;
}
if (params.cssmode) {
return translate;
}
let currenttranslate = gettranslate($wrapperel[0], axis);
if (rtl) currenttranslate = -currenttranslate;
return currenttranslate || 0;
}
function settranslate(translate, bycontroller) {
const swiper = this;
const {
rtltranslate: rtl,
params,
$wrapperel,
wrapperel,
progress
} = swiper;
let x = 0;
let y = 0;
const z = 0;
if (swiper.ishorizontal()) {
x = rtl ? -translate : translate;
} else {
y = translate;
}
if (params.roundlengths) {
x = math.floor(x);
y = math.floor(y);
}
if (params.cssmode) {
wrapperel[swiper.ishorizontal() ? 'scrollleft' : 'scrolltop'] = swiper.ishorizontal() ? -x : -y;
} else if (!params.virtualtranslate) {
$wrapperel.transform(`translate3d(${x}px, ${y}px, ${z}px)`);
}
swiper.previoustranslate = swiper.translate;
swiper.translate = swiper.ishorizontal() ? x : y; // check if we need to update progress
let newprogress;
const translatesdiff = swiper.maxtranslate() - swiper.mintranslate();
if (translatesdiff === 0) {
newprogress = 0;
} else {
newprogress = (translate - swiper.mintranslate()) / translatesdiff;
}
if (newprogress !== progress) {
swiper.updateprogress(translate);
}
swiper.emit('settranslate', swiper.translate, bycontroller);
}
function mintranslate() {
return -this.snapgrid[0];
}
function maxtranslate() {
return -this.snapgrid[this.snapgrid.length - 1];
}
function translateto(translate, speed, runcallbacks, translatebounds, internal) {
if (translate === void 0) {
translate = 0;
}
if (speed === void 0) {
speed = this.params.speed;
}
if (runcallbacks === void 0) {
runcallbacks = true;
}
if (translatebounds === void 0) {
translatebounds = true;
}
const swiper = this;
const {
params,
wrapperel
} = swiper;
if (swiper.animating && params.preventinteractionontransition) {
return false;
}
const mintranslate = swiper.mintranslate();
const maxtranslate = swiper.maxtranslate();
let newtranslate;
if (translatebounds && translate > mintranslate) newtranslate = mintranslate;else if (translatebounds && translate < maxtranslate) newtranslate = maxtranslate;else newtranslate = translate; // update progress
swiper.updateprogress(newtranslate);
if (params.cssmode) {
const ish = swiper.ishorizontal();
if (speed === 0) {
wrapperel[ish ? 'scrollleft' : 'scrolltop'] = -newtranslate;
} else {
if (!swiper.support.smoothscroll) {
animatecssmodescroll({
swiper,
targetposition: -newtranslate,
side: ish ? 'left' : 'top'
});
return true;
}
wrapperel.scrollto({
[ish ? 'left' : 'top']: -newtranslate,
behavior: 'smooth'
});
}
return true;
}
if (speed === 0) {
swiper.settransition(0);
swiper.settranslate(newtranslate);
if (runcallbacks) {
swiper.emit('beforetransitionstart', speed, internal);
swiper.emit('transitionend');
}
} else {
swiper.settransition(speed);
swiper.settranslate(newtranslate);
if (runcallbacks) {
swiper.emit('beforetransitionstart', speed, internal);
swiper.emit('transitionstart');
}
if (!swiper.animating) {
swiper.animating = true;
if (!swiper.ontranslatetowrappertransitionend) {
swiper.ontranslatetowrappertransitionend = function transitionend(e) {
if (!swiper || swiper.destroyed) return;
if (e.target !== this) return;
swiper.$wrapperel[0].removeeventlistener('transitionend', swiper.ontranslatetowrappertransitionend);
swiper.$wrapperel[0].removeeventlistener('webkittransitionend', swiper.ontranslatetowrappertransitionend);
swiper.ontranslatetowrappertransitionend = null;
delete swiper.ontranslatetowrappertransitionend;
if (runcallbacks) {
swiper.emit('transitionend');
}
};
}
swiper.$wrapperel[0].addeventlistener('transitionend', swiper.ontranslatetowrappertransitionend);
swiper.$wrapperel[0].addeventlistener('webkittransitionend', swiper.ontranslatetowrappertransitionend);
}
}
return true;
}
var translate = {
gettranslate: getswipertranslate,
settranslate,
mintranslate,
maxtranslate,
translateto
};
function settransition(duration, bycontroller) {
const swiper = this;
if (!swiper.params.cssmode) {
swiper.$wrapperel.transition(duration);
}
swiper.emit('settransition', duration, bycontroller);
}
function transitionemit(_ref) {
let {
swiper,
runcallbacks,
direction,
step
} = _ref;
const {
activeindex,
previousindex
} = swiper;
let dir = direction;
if (!dir) {
if (activeindex > previousindex) dir = 'next';else if (activeindex < previousindex) dir = 'prev';else dir = 'reset';
}
swiper.emit(`transition${step}`);
if (runcallbacks && activeindex !== previousindex) {
if (dir === 'reset') {
swiper.emit(`slideresettransition${step}`);
return;
}
swiper.emit(`slidechangetransition${step}`);
if (dir === 'next') {
swiper.emit(`slidenexttransition${step}`);
} else {
swiper.emit(`slideprevtransition${step}`);
}
}
}
function transitionstart(runcallbacks, direction) {
if (runcallbacks === void 0) {
runcallbacks = true;
}
const swiper = this;
const {
params
} = swiper;
if (params.cssmode) return;
if (params.autoheight) {
swiper.updateautoheight();
}
transitionemit({
swiper,
runcallbacks,
direction,
step: 'start'
});
}
function transitionend(runcallbacks, direction) {
if (runcallbacks === void 0) {
runcallbacks = true;
}
const swiper = this;
const {
params
} = swiper;
swiper.animating = false;
if (params.cssmode) return;
swiper.settransition(0);
transitionemit({
swiper,
runcallbacks,
direction,
step: 'end'
});
}
var transition = {
settransition,
transitionstart,
transitionend
};
function slideto(index, speed, runcallbacks, internal, initial) {
if (index === void 0) {
index = 0;
}
if (speed === void 0) {
speed = this.params.speed;
}
if (runcallbacks === void 0) {
runcallbacks = true;
}
if (typeof index !== 'number' && typeof index !== 'string') {
throw new error(`the 'index' argument cannot have type other than 'number' or 'string'. [${typeof index}] given.`);
}
if (typeof index === 'string') {
/**
* the `index` argument converted from `string` to `number`.
* @type {number}
*/
const indexasnumber = parseint(index, 10);
/**
* determines whether the `index` argument is a valid `number`
* after being converted from the `string` type.
* @type {boolean}
*/
const isvalidnumber = isfinite(indexasnumber);
if (!isvalidnumber) {
throw new error(`the passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`);
} // knowing that the converted `index` is a valid number,
// we can update the original argument's value.
index = indexasnumber;
}
const swiper = this;
let slideindex = index;
if (slideindex < 0) slideindex = 0;
const {
params,
snapgrid,
slidesgrid,
previousindex,
activeindex,
rtltranslate: rtl,
wrapperel,
enabled
} = swiper;
if (swiper.animating && params.preventinteractionontransition || !enabled && !internal && !initial) {
return false;
}
const skip = math.min(swiper.params.slidespergroupskip, slideindex);
let snapindex = skip + math.floor((slideindex - skip) / swiper.params.slidespergroup);
if (snapindex >= snapgrid.length) snapindex = snapgrid.length - 1;
if ((activeindex || params.initialslide || 0) === (previousindex || 0) && runcallbacks) {
swiper.emit('beforeslidechangestart');
}
const translate = -snapgrid[snapindex]; // update progress
swiper.updateprogress(translate); // normalize slideindex
if (params.normalizeslideindex) {
for (let i = 0; i < slidesgrid.length; i += 1) {
const normalizedtranslate = -math.floor(translate * 100);
const normalizedgrid = math.floor(slidesgrid[i] * 100);
const normalizedgridnext = math.floor(slidesgrid[i + 1] * 100);
if (typeof slidesgrid[i + 1] !== 'undefined') {
if (normalizedtranslate >= normalizedgrid && normalizedtranslate < normalizedgridnext - (normalizedgridnext - normalizedgrid) / 2) {
slideindex = i;
} else if (normalizedtranslate >= normalizedgrid && normalizedtranslate < normalizedgridnext) {
slideindex = i + 1;
}
} else if (normalizedtranslate >= normalizedgrid) {
slideindex = i;
}
}
} // directions locks
if (swiper.initialized && slideindex !== activeindex) {
if (!swiper.allowslidenext && translate < swiper.translate && translate < swiper.mintranslate()) {
return false;
}
if (!swiper.allowslideprev && translate > swiper.translate && translate > swiper.maxtranslate()) {
if ((activeindex || 0) !== slideindex) return false;
}
}
let direction;
if (slideindex > activeindex) direction = 'next';else if (slideindex < activeindex) direction = 'prev';else direction = 'reset'; // update index
if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
swiper.updateactiveindex(slideindex); // update height
if (params.autoheight) {
swiper.updateautoheight();
}
swiper.updateslidesclasses();
if (params.effect !== 'slide') {
swiper.settranslate(translate);
}
if (direction !== 'reset') {
swiper.transitionstart(runcallbacks, direction);
swiper.transitionend(runcallbacks, direction);
}
return false;
}
if (params.cssmode) {
const ish = swiper.ishorizontal();
const t = rtl ? translate : -translate;
if (speed === 0) {
const isvirtual = swiper.virtual && swiper.params.virtual.enabled;
if (isvirtual) {
swiper.wrapperel.style.scrollsnaptype = 'none';
swiper._immediatevirtual = true;
}
wrapperel[ish ? 'scrollleft' : 'scrolltop'] = t;
if (isvirtual) {
requestanimationframe(() => {
swiper.wrapperel.style.scrollsnaptype = '';
swiper._swiperimmediatevirtual = false;
});
}
} else {
if (!swiper.support.smoothscroll) {
animatecssmodescroll({
swiper,
targetposition: t,
side: ish ? 'left' : 'top'
});
return true;
}
wrapperel.scrollto({
[ish ? 'left' : 'top']: t,
behavior: 'smooth'
});
}
return true;
}
swiper.settransition(speed);
swiper.settranslate(translate);
swiper.updateactiveindex(slideindex);
swiper.updateslidesclasses();
swiper.emit('beforetransitionstart', speed, internal);
swiper.transitionstart(runcallbacks, direction);
if (speed === 0) {
swiper.transitionend(runcallbacks, direction);
} else if (!swiper.animating) {
swiper.animating = true;
if (!swiper.onslidetowrappertransitionend) {
swiper.onslidetowrappertransitionend = function transitionend(e) {
if (!swiper || swiper.destroyed) return;
if (e.target !== this) return;
swiper.$wrapperel[0].removeeventlistener('transitionend', swiper.onslidetowrappertransitionend);
swiper.$wrapperel[0].removeeventlistener('webkittransitionend', swiper.onslidetowrappertransitionend);
swiper.onslidetowrappertransitionend = null;
delete swiper.onslidetowrappertransitionend;
swiper.transitionend(runcallbacks, direction);
};
}
swiper.$wrapperel[0].addeventlistener('transitionend', swiper.onslidetowrappertransitionend);
swiper.$wrapperel[0].addeventlistener('webkittransitionend', swiper.onslidetowrappertransitionend);
}
return true;
}
function slidetoloop(index, speed, runcallbacks, internal) {
if (index === void 0) {
index = 0;
}
if (speed === void 0) {
speed = this.params.speed;
}
if (runcallbacks === void 0) {
runcallbacks = true;
}
if (typeof index === 'string') {
/**
* the `index` argument converted from `string` to `number`.
* @type {number}
*/
const indexasnumber = parseint(index, 10);
/**
* determines whether the `index` argument is a valid `number`
* after being converted from the `string` type.
* @type {boolean}
*/
const isvalidnumber = isfinite(indexasnumber);
if (!isvalidnumber) {
throw new error(`the passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`);
} // knowing that the converted `index` is a valid number,
// we can update the original argument's value.
index = indexasnumber;
}
const swiper = this;
let newindex = index;
if (swiper.params.loop) {
newindex += swiper.loopedslides;
}
return swiper.slideto(newindex, speed, runcallbacks, internal);
}
/* eslint no-unused-vars: "off" */
function slidenext(speed, runcallbacks, internal) {
if (speed === void 0) {
speed = this.params.speed;
}
if (runcallbacks === void 0) {
runcallbacks = true;
}
const swiper = this;
const {
animating,
enabled,
params
} = swiper;
if (!enabled) return swiper;
let pergroup = params.slidespergroup;
if (params.slidesperview === 'auto' && params.slidespergroup === 1 && params.slidespergroupauto) {
pergroup = math.max(swiper.slidesperviewdynamic('current', true), 1);
}
const increment = swiper.activeindex < params.slidespergroupskip ? 1 : pergroup;
if (params.loop) {
if (animating && params.looppreventsslide) return false;
swiper.loopfix(); // eslint-disable-next-line
swiper._clientleft = swiper.$wrapperel[0].clientleft;
}
if (params.rewind && swiper.isend) {
return swiper.slideto(0, speed, runcallbacks, internal);
}
return swiper.slideto(swiper.activeindex + increment, speed, runcallbacks, internal);
}
/* eslint no-unused-vars: "off" */
function slideprev(speed, runcallbacks, internal) {
if (speed === void 0) {
speed = this.params.speed;
}
if (runcallbacks === void 0) {
runcallbacks = true;
}
const swiper = this;
const {
params,
animating,
snapgrid,
slidesgrid,
rtltranslate,
enabled
} = swiper;
if (!enabled) return swiper;
if (params.loop) {
if (animating && params.looppreventsslide) return false;
swiper.loopfix(); // eslint-disable-next-line
swiper._clientleft = swiper.$wrapperel[0].clientleft;
}
const translate = rtltranslate ? swiper.translate : -swiper.translate;
function normalize(val) {
if (val < 0) return -math.floor(math.abs(val));
return math.floor(val);
}
const normalizedtranslate = normalize(translate);
const normalizedsnapgrid = snapgrid.map(val => normalize(val));
let prevsnap = snapgrid[normalizedsnapgrid.indexof(normalizedtranslate) - 1];
if (typeof prevsnap === 'undefined' && params.cssmode) {
let prevsnapindex;
snapgrid.foreach((snap, snapindex) => {
if (normalizedtranslate >= snap) {
// prevsnap = snap;
prevsnapindex = snapindex;
}
});
if (typeof prevsnapindex !== 'undefined') {
prevsnap = snapgrid[prevsnapindex > 0 ? prevsnapindex - 1 : prevsnapindex];
}
}
let previndex = 0;
if (typeof prevsnap !== 'undefined') {
previndex = slidesgrid.indexof(prevsnap);
if (previndex < 0) previndex = swiper.activeindex - 1;
if (params.slidesperview === 'auto' && params.slidespergroup === 1 && params.slidespergroupauto) {
previndex = previndex - swiper.slidesperviewdynamic('previous', true) + 1;
previndex = math.max(previndex, 0);
}
}
if (params.rewind && swiper.isbeginning) {
const lastindex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
return swiper.slideto(lastindex, speed, runcallbacks, internal);
}
return swiper.slideto(previndex, speed, runcallbacks, internal);
}
/* eslint no-unused-vars: "off" */
function slidereset(speed, runcallbacks, internal) {
if (speed === void 0) {
speed = this.params.speed;
}
if (runcallbacks === void 0) {
runcallbacks = true;
}
const swiper = this;
return swiper.slideto(swiper.activeindex, speed, runcallbacks, internal);
}
/* eslint no-unused-vars: "off" */
function slidetoclosest(speed, runcallbacks, internal, threshold) {
if (speed === void 0) {
speed = this.params.speed;
}
if (runcallbacks === void 0) {
runcallbacks = true;
}
if (threshold === void 0) {
threshold = 0.5;
}
const swiper = this;
let index = swiper.activeindex;
const skip = math.min(swiper.params.slidespergroupskip, index);
const snapindex = skip + math.floor((index - skip) / swiper.params.slidespergroup);
const translate = swiper.rtltranslate ? swiper.translate : -swiper.translate;
if (translate >= swiper.snapgrid[snapindex]) {
// the current translate is on or after the current snap index, so the choice
// is between the current index and the one after it.
const currentsnap = swiper.snapgrid[snapindex];
const nextsnap = swiper.snapgrid[snapindex + 1];
if (translate - currentsnap > (nextsnap - currentsnap) * threshold) {
index += swiper.params.slidespergroup;
}
} else {
// the current translate is before the current snap index, so the choice
// is between the current index and the one before it.
const prevsnap = swiper.snapgrid[snapindex - 1];
const currentsnap = swiper.snapgrid[snapindex];
if (translate - prevsnap <= (currentsnap - prevsnap) * threshold) {
index -= swiper.params.slidespergroup;
}
}
index = math.max(index, 0);
index = math.min(index, swiper.slidesgrid.length - 1);
return swiper.slideto(index, speed, runcallbacks, internal);
}
function slidetoclickedslide() {
const swiper = this;
const {
params,
$wrapperel
} = swiper;
const slidesperview = params.slidesperview === 'auto' ? swiper.slidesperviewdynamic() : params.slidesperview;
let slidetoindex = swiper.clickedindex;
let realindex;
if (params.loop) {
if (swiper.animating) return;
realindex = parseint($(swiper.clickedslide).attr('data-swiper-slide-index'), 10);
if (params.centeredslides) {
if (slidetoindex < swiper.loopedslides - slidesperview / 2 || slidetoindex > swiper.slides.length - swiper.loopedslides + slidesperview / 2) {
swiper.loopfix();
slidetoindex = $wrapperel.children(`.${params.slideclass}[data-swiper-slide-index="${realindex}"]:not(.${params.slideduplicateclass})`).eq(0).index();
nexttick(() => {
swiper.slideto(slidetoindex);
});
} else {
swiper.slideto(slidetoindex);
}
} else if (slidetoindex > swiper.slides.length - slidesperview) {
swiper.loopfix();
slidetoindex = $wrapperel.children(`.${params.slideclass}[data-swiper-slide-index="${realindex}"]:not(.${params.slideduplicateclass})`).eq(0).index();
nexttick(() => {
swiper.slideto(slidetoindex);
});
} else {
swiper.slideto(slidetoindex);
}
} else {
swiper.slideto(slidetoindex);
}
}
var slide = {
slideto,
slidetoloop,
slidenext,
slideprev,
slidereset,
slidetoclosest,
slidetoclickedslide
};
function loopcreate() {
const swiper = this;
const document = getdocument();
const {
params,
$wrapperel
} = swiper; // remove duplicated slides
const $selector = $wrapperel.children().length > 0 ? $($wrapperel.children()[0].parentnode) : $wrapperel;
$selector.children(`.${params.slideclass}.${params.slideduplicateclass}`).remove();
let slides = $selector.children(`.${params.slideclass}`);
if (params.loopfillgroupwithblank) {
const blankslidesnum = params.slidespergroup - slides.length % params.slidespergroup;
if (blankslidesnum !== params.slidespergroup) {
for (let i = 0; i < blankslidesnum; i += 1) {
const blanknode = $(document.createelement('div')).addclass(`${params.slideclass} ${params.slideblankclass}`);
$selector.append(blanknode);
}
slides = $selector.children(`.${params.slideclass}`);
}
}
if (params.slidesperview === 'auto' && !params.loopedslides) params.loopedslides = slides.length;
swiper.loopedslides = math.ceil(parsefloat(params.loopedslides || params.slidesperview, 10));
swiper.loopedslides += params.loopadditionalslides;
if (swiper.loopedslides > slides.length) {
swiper.loopedslides = slides.length;
}
const prependslides = [];
const appendslides = [];
slides.each((el, index) => {
const slide = $(el);
if (index < swiper.loopedslides) {
appendslides.push(el);
}
if (index < slides.length && index >= slides.length - swiper.loopedslides) {
prependslides.push(el);
}
slide.attr('data-swiper-slide-index', index);
});
for (let i = 0; i < appendslides.length; i += 1) {
$selector.append($(appendslides[i].clonenode(true)).addclass(params.slideduplicateclass));
}
for (let i = prependslides.length - 1; i >= 0; i -= 1) {
$selector.prepend($(prependslides[i].clonenode(true)).addclass(params.slideduplicateclass));
}
}
function loopfix() {
const swiper = this;
swiper.emit('beforeloopfix');
const {
activeindex,
slides,
loopedslides,
allowslideprev,
allowslidenext,
snapgrid,
rtltranslate: rtl
} = swiper;
let newindex;
swiper.allowslideprev = true;
swiper.allowslidenext = true;
const snaptranslate = -snapgrid[activeindex];
const diff = snaptranslate - swiper.gettranslate(); // fix for negative oversliding
if (activeindex < loopedslides) {
newindex = slides.length - loopedslides * 3 + activeindex;
newindex += loopedslides;
const slidechanged = swiper.slideto(newindex, 0, false, true);
if (slidechanged && diff !== 0) {
swiper.settranslate((rtl ? -swiper.translate : swiper.translate) - diff);
}
} else if (activeindex >= slides.length - loopedslides) {
// fix for positive oversliding
newindex = -slides.length + activeindex + loopedslides;
newindex += loopedslides;
const slidechanged = swiper.slideto(newindex, 0, false, true);
if (slidechanged && diff !== 0) {
swiper.settranslate((rtl ? -swiper.translate : swiper.translate) - diff);
}
}
swiper.allowslideprev = allowslideprev;
swiper.allowslidenext = allowslidenext;
swiper.emit('loopfix');
}
function loopdestroy() {
const swiper = this;
const {
$wrapperel,
params,
slides
} = swiper;
$wrapperel.children(`.${params.slideclass}.${params.slideduplicateclass},.${params.slideclass}.${params.slideblankclass}`).remove();
slides.removeattr('data-swiper-slide-index');
}
var loop = {
loopcreate,
loopfix,
loopdestroy
};
function setgrabcursor(moving) {
const swiper = this;
if (swiper.support.touch || !swiper.params.simulatetouch || swiper.params.watchoverflow && swiper.islocked || swiper.params.cssmode) return;
const el = swiper.params.toucheventstarget === 'container' ? swiper.el : swiper.wrapperel;
el.style.cursor = 'move';
el.style.cursor = moving ? 'grabbing' : 'grab';
}
function unsetgrabcursor() {
const swiper = this;
if (swiper.support.touch || swiper.params.watchoverflow && swiper.islocked || swiper.params.cssmode) {
return;
}
swiper[swiper.params.toucheventstarget === 'container' ? 'el' : 'wrapperel'].style.cursor = '';
}
var grabcursor = {
setgrabcursor,
unsetgrabcursor
};
function closestelement(selector, base) {
if (base === void 0) {
base = this;
}
function __closestfrom(el) {
if (!el || el === getdocument() || el === getwindow()) return null;
if (el.assignedslot) el = el.assignedslot;
const found = el.closest(selector);
if (!found && !el.getrootnode) {
return null;
}
return found || __closestfrom(el.getrootnode().host);
}
return __closestfrom(base);
}
function ontouchstart(event) {
const swiper = this;
const document = getdocument();
const window = getwindow();
const data = swiper.toucheventsdata;
const {
params,
touches,
enabled
} = swiper;
if (!enabled) return;
if (swiper.animating && params.preventinteractionontransition) {
return;
}
if (!swiper.animating && params.cssmode && params.loop) {
swiper.loopfix();
}
let e = event;
if (e.originalevent) e = e.originalevent;
let $targetel = $(e.target);
if (params.toucheventstarget === 'wrapper') {
if (!$targetel.closest(swiper.wrapperel).length) return;
}
data.istouchevent = e.type === 'touchstart';
if (!data.istouchevent && 'which' in e && e.which === 3) return;
if (!data.istouchevent && 'button' in e && e.button > 0) return;
if (data.istouched && data.ismoved) return; // change target el for shadow root component
const swipingclasshasvalue = !!params.noswipingclass && params.noswipingclass !== '';
if (swipingclasshasvalue && e.target && e.target.shadowroot && event.path && event.path[0]) {
$targetel = $(event.path[0]);
}
const noswipingselector = params.noswipingselector ? params.noswipingselector : `.${params.noswipingclass}`;
const istargetshadow = !!(e.target && e.target.shadowroot); // use closestelement for shadow root element to get the actual closest for nested shadow root element
if (params.noswiping && (istargetshadow ? closestelement(noswipingselector, $targetel[0]) : $targetel.closest(noswipingselector)[0])) {
swiper.allowclick = true;
return;
}
if (params.swipehandler) {
if (!$targetel.closest(params.swipehandler)[0]) return;
}
touches.currentx = e.type === 'touchstart' ? e.targettouches[0].pagex : e.pagex;
touches.currenty = e.type === 'touchstart' ? e.targettouches[0].pagey : e.pagey;
const startx = touches.currentx;
const starty = touches.currenty; // do not start if ios edge swipe is detected. otherwise ios app cannot swipe-to-go-back anymore
const edgeswipedetection = params.edgeswipedetection || params.iosedgeswipedetection;
const edgeswipethreshold = params.edgeswipethreshold || params.iosedgeswipethreshold;
if (edgeswipedetection && (startx <= edgeswipethreshold || startx >= window.innerwidth - edgeswipethreshold)) {
if (edgeswipedetection === 'prevent') {
event.preventdefault();
} else {
return;
}
}
object.assign(data, {
istouched: true,
ismoved: false,
allowtouchcallbacks: true,
isscrolling: undefined,
startmoving: undefined
});
touches.startx = startx;
touches.starty = starty;
data.touchstarttime = now();
swiper.allowclick = true;
swiper.updatesize();
swiper.swipedirection = undefined;
if (params.threshold > 0) data.allowthresholdmove = false;
if (e.type !== 'touchstart') {
let preventdefault = true;
if ($targetel.is(data.focusableelements)) {
preventdefault = false;
if ($targetel[0].nodename === 'select') {
data.istouched = false;
}
}
if (document.activeelement && $(document.activeelement).is(data.focusableelements) && document.activeelement !== $targetel[0]) {
document.activeelement.blur();
}
const shouldpreventdefault = preventdefault && swiper.allowtouchmove && params.touchstartpreventdefault;
if ((params.touchstartforcepreventdefault || shouldpreventdefault) && !$targetel[0].iscontenteditable) {
e.preventdefault();
}
}
if (swiper.params.freemode && swiper.params.freemode.enabled && swiper.freemode && swiper.animating && !params.cssmode) {
swiper.freemode.ontouchstart();
}
swiper.emit('touchstart', e);
}
function ontouchmove(event) {
const document = getdocument();
const swiper = this;
const data = swiper.toucheventsdata;
const {
params,
touches,
rtltranslate: rtl,
enabled
} = swiper;
if (!enabled) return;
let e = event;
if (e.originalevent) e = e.originalevent;
if (!data.istouched) {
if (data.startmoving && data.isscrolling) {
swiper.emit('touchmoveopposite', e);
}
return;
}
if (data.istouchevent && e.type !== 'touchmove') return;
const targettouch = e.type === 'touchmove' && e.targettouches && (e.targettouches[0] || e.changedtouches[0]);
const pagex = e.type === 'touchmove' ? targettouch.pagex : e.pagex;
const pagey = e.type === 'touchmove' ? targettouch.pagey : e.pagey;
if (e.preventedbynestedswiper) {
touches.startx = pagex;
touches.starty = pagey;
return;
}
if (!swiper.allowtouchmove) {
if (!$(e.target).is(data.focusableelements)) {
swiper.allowclick = false;
}
if (data.istouched) {
object.assign(touches, {
startx: pagex,
starty: pagey,
currentx: pagex,
currenty: pagey
});
data.touchstarttime = now();
}
return;
}
if (data.istouchevent && params.touchreleaseonedges && !params.loop) {
if (swiper.isvertical()) {
// vertical
if (pagey < touches.starty && swiper.translate <= swiper.maxtranslate() || pagey > touches.starty && swiper.translate >= swiper.mintranslate()) {
data.istouched = false;
data.ismoved = false;
return;
}
} else if (pagex < touches.startx && swiper.translate <= swiper.maxtranslate() || pagex > touches.startx && swiper.translate >= swiper.mintranslate()) {
return;
}
}
if (data.istouchevent && document.activeelement) {
if (e.target === document.activeelement && $(e.target).is(data.focusableelements)) {
data.ismoved = true;
swiper.allowclick = false;
return;
}
}
if (data.allowtouchcallbacks) {
swiper.emit('touchmove', e);
}
if (e.targettouches && e.targettouches.length > 1) return;
touches.currentx = pagex;
touches.currenty = pagey;
const diffx = touches.currentx - touches.startx;
const diffy = touches.currenty - touches.starty;
if (swiper.params.threshold && math.sqrt(diffx ** 2 + diffy ** 2) < swiper.params.threshold) return;
if (typeof data.isscrolling === 'undefined') {
let touchangle;
if (swiper.ishorizontal() && touches.currenty === touches.starty || swiper.isvertical() && touches.currentx === touches.startx) {
data.isscrolling = false;
} else {
// eslint-disable-next-line
if (diffx * diffx + diffy * diffy >= 25) {
touchangle = math.atan2(math.abs(diffy), math.abs(diffx)) * 180 / math.pi;
data.isscrolling = swiper.ishorizontal() ? touchangle > params.touchangle : 90 - touchangle > params.touchangle;
}
}
}
if (data.isscrolling) {
swiper.emit('touchmoveopposite', e);
}
if (typeof data.startmoving === 'undefined') {
if (touches.currentx !== touches.startx || touches.currenty !== touches.starty) {
data.startmoving = true;
}
}
if (data.isscrolling) {
data.istouched = false;
return;
}
if (!data.startmoving) {
return;
}
swiper.allowclick = false;
if (!params.cssmode && e.cancelable) {
e.preventdefault();
}
if (params.touchmovestoppropagation && !params.nested) {
e.stoppropagation();
}
if (!data.ismoved) {
if (params.loop && !params.cssmode) {
swiper.loopfix();
}
data.starttranslate = swiper.gettranslate();
swiper.settransition(0);
if (swiper.animating) {
swiper.$wrapperel.trigger('webkittransitionend transitionend');
}
data.allowmomentumbounce = false; // grab cursor
if (params.grabcursor && (swiper.allowslidenext === true || swiper.allowslideprev === true)) {
swiper.setgrabcursor(true);
}
swiper.emit('sliderfirstmove', e);
}
swiper.emit('slidermove', e);
data.ismoved = true;
let diff = swiper.ishorizontal() ? diffx : diffy;
touches.diff = diff;
diff *= params.touchratio;
if (rtl) diff = -diff;
swiper.swipedirection = diff > 0 ? 'prev' : 'next';
data.currenttranslate = diff + data.starttranslate;
let disableparentswiper = true;
let resistanceratio = params.resistanceratio;
if (params.touchreleaseonedges) {
resistanceratio = 0;
}
if (diff > 0 && data.currenttranslate > swiper.mintranslate()) {
disableparentswiper = false;
if (params.resistance) data.currenttranslate = swiper.mintranslate() - 1 + (-swiper.mintranslate() + data.starttranslate + diff) ** resistanceratio;
} else if (diff < 0 && data.currenttranslate < swiper.maxtranslate()) {
disableparentswiper = false;
if (params.resistance) data.currenttranslate = swiper.maxtranslate() + 1 - (swiper.maxtranslate() - data.starttranslate - diff) ** resistanceratio;
}
if (disableparentswiper) {
e.preventedbynestedswiper = true;
} // directions locks
if (!swiper.allowslidenext && swiper.swipedirection === 'next' && data.currenttranslate < data.starttranslate) {
data.currenttranslate = data.starttranslate;
}
if (!swiper.allowslideprev && swiper.swipedirection === 'prev' && data.currenttranslate > data.starttranslate) {
data.currenttranslate = data.starttranslate;
}
if (!swiper.allowslideprev && !swiper.allowslidenext) {
data.currenttranslate = data.starttranslate;
} // threshold
if (params.threshold > 0) {
if (math.abs(diff) > params.threshold || data.allowthresholdmove) {
if (!data.allowthresholdmove) {
data.allowthresholdmove = true;
touches.startx = touches.currentx;
touches.starty = touches.currenty;
data.currenttranslate = data.starttranslate;
touches.diff = swiper.ishorizontal() ? touches.currentx - touches.startx : touches.currenty - touches.starty;
return;
}
} else {
data.currenttranslate = data.starttranslate;
return;
}
}
if (!params.followfinger || params.cssmode) return; // update active index in free mode
if (params.freemode && params.freemode.enabled && swiper.freemode || params.watchslidesprogress) {
swiper.updateactiveindex();
swiper.updateslidesclasses();
}
if (swiper.params.freemode && params.freemode.enabled && swiper.freemode) {
swiper.freemode.ontouchmove();
} // update progress
swiper.updateprogress(data.currenttranslate); // update translate
swiper.settranslate(data.currenttranslate);
}
function ontouchend(event) {
const swiper = this;
const data = swiper.toucheventsdata;
const {
params,
touches,
rtltranslate: rtl,
slidesgrid,
enabled
} = swiper;
if (!enabled) return;
let e = event;
if (e.originalevent) e = e.originalevent;
if (data.allowtouchcallbacks) {
swiper.emit('touchend', e);
}
data.allowtouchcallbacks = false;
if (!data.istouched) {
if (data.ismoved && params.grabcursor) {
swiper.setgrabcursor(false);
}
data.ismoved = false;
data.startmoving = false;
return;
} // return grab cursor
if (params.grabcursor && data.ismoved && data.istouched && (swiper.allowslidenext === true || swiper.allowslideprev === true)) {
swiper.setgrabcursor(false);
} // time diff
const touchendtime = now();
const timediff = touchendtime - data.touchstarttime; // tap, doubletap, click
if (swiper.allowclick) {
const pathtree = e.path || e.composedpath && e.composedpath();
swiper.updateclickedslide(pathtree && pathtree[0] || e.target);
swiper.emit('tap click', e);
if (timediff < 300 && touchendtime - data.lastclicktime < 300) {
swiper.emit('doubletap doubleclick', e);
}
}
data.lastclicktime = now();
nexttick(() => {
if (!swiper.destroyed) swiper.allowclick = true;
});
if (!data.istouched || !data.ismoved || !swiper.swipedirection || touches.diff === 0 || data.currenttranslate === data.starttranslate) {
data.istouched = false;
data.ismoved = false;
data.startmoving = false;
return;
}
data.istouched = false;
data.ismoved = false;
data.startmoving = false;
let currentpos;
if (params.followfinger) {
currentpos = rtl ? swiper.translate : -swiper.translate;
} else {
currentpos = -data.currenttranslate;
}
if (params.cssmode) {
return;
}
if (swiper.params.freemode && params.freemode.enabled) {
swiper.freemode.ontouchend({
currentpos
});
return;
} // find current slide
let stopindex = 0;
let groupsize = swiper.slidessizesgrid[0];
for (let i = 0; i < slidesgrid.length; i += i < params.slidespergroupskip ? 1 : params.slidespergroup) {
const increment = i < params.slidespergroupskip - 1 ? 1 : params.slidespergroup;
if (typeof slidesgrid[i + increment] !== 'undefined') {
if (currentpos >= slidesgrid[i] && currentpos < slidesgrid[i + increment]) {
stopindex = i;
groupsize = slidesgrid[i + increment] - slidesgrid[i];
}
} else if (currentpos >= slidesgrid[i]) {
stopindex = i;
groupsize = slidesgrid[slidesgrid.length - 1] - slidesgrid[slidesgrid.length - 2];
}
}
let rewindfirstindex = null;
let rewindlastindex = null;
if (params.rewind) {
if (swiper.isbeginning) {
rewindlastindex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
} else if (swiper.isend) {
rewindfirstindex = 0;
}
} // find current slide size
const ratio = (currentpos - slidesgrid[stopindex]) / groupsize;
const increment = stopindex < params.slidespergroupskip - 1 ? 1 : params.slidespergroup;
if (timediff > params.longswipesms) {
// long touches
if (!params.longswipes) {
swiper.slideto(swiper.activeindex);
return;
}
if (swiper.swipedirection === 'next') {
if (ratio >= params.longswipesratio) swiper.slideto(params.rewind && swiper.isend ? rewindfirstindex : stopindex + increment);else swiper.slideto(stopindex);
}
if (swiper.swipedirection === 'prev') {
if (ratio > 1 - params.longswipesratio) {
swiper.slideto(stopindex + increment);
} else if (rewindlastindex !== null && ratio < 0 && math.abs(ratio) > params.longswipesratio) {
swiper.slideto(rewindlastindex);
} else {
swiper.slideto(stopindex);
}
}
} else {
// short swipes
if (!params.shortswipes) {
swiper.slideto(swiper.activeindex);
return;
}
const isnavbuttontarget = swiper.navigation && (e.target === swiper.navigation.nextel || e.target === swiper.navigation.prevel);
if (!isnavbuttontarget) {
if (swiper.swipedirection === 'next') {
swiper.slideto(rewindfirstindex !== null ? rewindfirstindex : stopindex + increment);
}
if (swiper.swipedirection === 'prev') {
swiper.slideto(rewindlastindex !== null ? rewindlastindex : stopindex);
}
} else if (e.target === swiper.navigation.nextel) {
swiper.slideto(stopindex + increment);
} else {
swiper.slideto(stopindex);
}
}
}
function onresize() {
const swiper = this;
const {
params,
el
} = swiper;
if (el && el.offsetwidth === 0) return; // breakpoints
if (params.breakpoints) {
swiper.setbreakpoint();
} // save locks
const {
allowslidenext,
allowslideprev,
snapgrid
} = swiper; // disable locks on resize
swiper.allowslidenext = true;
swiper.allowslideprev = true;
swiper.updatesize();
swiper.updateslides();
swiper.updateslidesclasses();
if ((params.slidesperview === 'auto' || params.slidesperview > 1) && swiper.isend && !swiper.isbeginning && !swiper.params.centeredslides) {
swiper.slideto(swiper.slides.length - 1, 0, false, true);
} else {
swiper.slideto(swiper.activeindex, 0, false, true);
}
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
swiper.autoplay.run();
} // return locks after resize
swiper.allowslideprev = allowslideprev;
swiper.allowslidenext = allowslidenext;
if (swiper.params.watchoverflow && snapgrid !== swiper.snapgrid) {
swiper.checkoverflow();
}
}
function onclick(e) {
const swiper = this;
if (!swiper.enabled) return;
if (!swiper.allowclick) {
if (swiper.params.preventclicks) e.preventdefault();
if (swiper.params.preventclickspropagation && swiper.animating) {
e.stoppropagation();
e.stopimmediatepropagation();
}
}
}
function onscroll() {
const swiper = this;
const {
wrapperel,
rtltranslate,
enabled
} = swiper;
if (!enabled) return;
swiper.previoustranslate = swiper.translate;
if (swiper.ishorizontal()) {
swiper.translate = -wrapperel.scrollleft;
} else {
swiper.translate = -wrapperel.scrolltop;
} // eslint-disable-next-line
if (swiper.translate === 0) swiper.translate = 0;
swiper.updateactiveindex();
swiper.updateslidesclasses();
let newprogress;
const translatesdiff = swiper.maxtranslate() - swiper.mintranslate();
if (translatesdiff === 0) {
newprogress = 0;
} else {
newprogress = (swiper.translate - swiper.mintranslate()) / translatesdiff;
}
if (newprogress !== swiper.progress) {
swiper.updateprogress(rtltranslate ? -swiper.translate : swiper.translate);
}
swiper.emit('settranslate', swiper.translate, false);
}
let dummyeventattached = false;
function dummyeventlistener() {}
const events = (swiper, method) => {
const document = getdocument();
const {
params,
touchevents,
el,
wrapperel,
device,
support
} = swiper;
const capture = !!params.nested;
const dommethod = method === 'on' ? 'addeventlistener' : 'removeeventlistener';
const swipermethod = method; // touch events
if (!support.touch) {
el[dommethod](touchevents.start, swiper.ontouchstart, false);
document[dommethod](touchevents.move, swiper.ontouchmove, capture);
document[dommethod](touchevents.end, swiper.ontouchend, false);
} else {
const passivelistener = touchevents.start === 'touchstart' && support.passivelistener && params.passivelisteners ? {
passive: true,
capture: false
} : false;
el[dommethod](touchevents.start, swiper.ontouchstart, passivelistener);
el[dommethod](touchevents.move, swiper.ontouchmove, support.passivelistener ? {
passive: false,
capture
} : capture);
el[dommethod](touchevents.end, swiper.ontouchend, passivelistener);
if (touchevents.cancel) {
el[dommethod](touchevents.cancel, swiper.ontouchend, passivelistener);
}
} // prevent links clicks
if (params.preventclicks || params.preventclickspropagation) {
el[dommethod]('click', swiper.onclick, true);
}
if (params.cssmode) {
wrapperel[dommethod]('scroll', swiper.onscroll);
} // resize handler
if (params.updateonwindowresize) {
swiper[swipermethod](device.ios || device.android ? 'resize orientationchange observerupdate' : 'resize observerupdate', onresize, true);
} else {
swiper[swipermethod]('observerupdate', onresize, true);
}
};
function attachevents() {
const swiper = this;
const document = getdocument();
const {
params,
support
} = swiper;
swiper.ontouchstart = ontouchstart.bind(swiper);
swiper.ontouchmove = ontouchmove.bind(swiper);
swiper.ontouchend = ontouchend.bind(swiper);
if (params.cssmode) {
swiper.onscroll = onscroll.bind(swiper);
}
swiper.onclick = onclick.bind(swiper);
if (support.touch && !dummyeventattached) {
document.addeventlistener('touchstart', dummyeventlistener);
dummyeventattached = true;
}
events(swiper, 'on');
}
function detachevents() {
const swiper = this;
events(swiper, 'off');
}
var events$1 = {
attachevents,
detachevents
};
const isgridenabled = (swiper, params) => {
return swiper.grid && params.grid && params.grid.rows > 1;
};
function setbreakpoint() {
const swiper = this;
const {
activeindex,
initialized,
loopedslides = 0,
params,
$el
} = swiper;
const breakpoints = params.breakpoints;
if (!breakpoints || breakpoints && object.keys(breakpoints).length === 0) return; // get breakpoint for window width and update parameters
const breakpoint = swiper.getbreakpoint(breakpoints, swiper.params.breakpointsbase, swiper.el);
if (!breakpoint || swiper.currentbreakpoint === breakpoint) return;
const breakpointonlyparams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
const breakpointparams = breakpointonlyparams || swiper.originalparams;
const wasmultirow = isgridenabled(swiper, params);
const ismultirow = isgridenabled(swiper, breakpointparams);
const wasenabled = params.enabled;
if (wasmultirow && !ismultirow) {
$el.removeclass(`${params.containermodifierclass}grid ${params.containermodifierclass}grid-column`);
swiper.emitcontainerclasses();
} else if (!wasmultirow && ismultirow) {
$el.addclass(`${params.containermodifierclass}grid`);
if (breakpointparams.grid.fill && breakpointparams.grid.fill === 'column' || !breakpointparams.grid.fill && params.grid.fill === 'column') {
$el.addclass(`${params.containermodifierclass}grid-column`);
}
swiper.emitcontainerclasses();
} // toggle navigation, pagination, scrollbar
['navigation', 'pagination', 'scrollbar'].foreach(prop => {
const wasmoduleenabled = params[prop] && params[prop].enabled;
const ismoduleenabled = breakpointparams[prop] && breakpointparams[prop].enabled;
if (wasmoduleenabled && !ismoduleenabled) {
swiper[prop].disable();
}
if (!wasmoduleenabled && ismoduleenabled) {
swiper[prop].enable();
}
});
const directionchanged = breakpointparams.direction && breakpointparams.direction !== params.direction;
const needsreloop = params.loop && (breakpointparams.slidesperview !== params.slidesperview || directionchanged);
if (directionchanged && initialized) {
swiper.changedirection();
}
extend(swiper.params, breakpointparams);
const isenabled = swiper.params.enabled;
object.assign(swiper, {
allowtouchmove: swiper.params.allowtouchmove,
allowslidenext: swiper.params.allowslidenext,
allowslideprev: swiper.params.allowslideprev
});
if (wasenabled && !isenabled) {
swiper.disable();
} else if (!wasenabled && isenabled) {
swiper.enable();
}
swiper.currentbreakpoint = breakpoint;
swiper.emit('_beforebreakpoint', breakpointparams);
if (needsreloop && initialized) {
swiper.loopdestroy();
swiper.loopcreate();
swiper.updateslides();
swiper.slideto(activeindex - loopedslides + swiper.loopedslides, 0, false);
}
swiper.emit('breakpoint', breakpointparams);
}
function getbreakpoint(breakpoints, base, containerel) {
if (base === void 0) {
base = 'window';
}
if (!breakpoints || base === 'container' && !containerel) return undefined;
let breakpoint = false;
const window = getwindow();
const currentheight = base === 'window' ? window.innerheight : containerel.clientheight;
const points = object.keys(breakpoints).map(point => {
if (typeof point === 'string' && point.indexof('@') === 0) {
const minratio = parsefloat(point.substr(1));
const value = currentheight * minratio;
return {
value,
point
};
}
return {
value: point,
point
};
});
points.sort((a, b) => parseint(a.value, 10) - parseint(b.value, 10));
for (let i = 0; i < points.length; i += 1) {
const {
point,
value
} = points[i];
if (base === 'window') {
if (window.matchmedia(`(min-width: ${value}px)`).matches) {
breakpoint = point;
}
} else if (value <= containerel.clientwidth) {
breakpoint = point;
}
}
return breakpoint || 'max';
}
var breakpoints = {
setbreakpoint,
getbreakpoint
};
function prepareclasses(entries, prefix) {
const resultclasses = [];
entries.foreach(item => {
if (typeof item === 'object') {
object.keys(item).foreach(classnames => {
if (item[classnames]) {
resultclasses.push(prefix + classnames);
}
});
} else if (typeof item === 'string') {
resultclasses.push(prefix + item);
}
});
return resultclasses;
}
function addclasses() {
const swiper = this;
const {
classnames,
params,
rtl,
$el,
device,
support
} = swiper; // prettier-ignore
const suffixes = prepareclasses(['initialized', params.direction, {
'pointer-events': !support.touch
}, {
'free-mode': swiper.params.freemode && params.freemode.enabled
}, {
'autoheight': params.autoheight
}, {
'rtl': rtl
}, {
'grid': params.grid && params.grid.rows > 1
}, {
'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
}, {
'android': device.android
}, {
'ios': device.ios
}, {
'css-mode': params.cssmode
}, {
'centered': params.cssmode && params.centeredslides
}, {
'watch-progress': params.watchslidesprogress
}], params.containermodifierclass);
classnames.push(...suffixes);
$el.addclass([...classnames].join(' '));
swiper.emitcontainerclasses();
}
function removeclasses() {
const swiper = this;
const {
$el,
classnames
} = swiper;
$el.removeclass(classnames.join(' '));
swiper.emitcontainerclasses();
}
var classes = {
addclasses,
removeclasses
};
function loadimage(imageel, src, srcset, sizes, checkforcomplete, callback) {
const window = getwindow();
let image;
function onready() {
if (callback) callback();
}
const ispicture = $(imageel).parent('picture')[0];
if (!ispicture && (!imageel.complete || !checkforcomplete)) {
if (src) {
image = new window.image();
image.onload = onready;
image.onerror = onready;
if (sizes) {
image.sizes = sizes;
}
if (srcset) {
image.srcset = srcset;
}
if (src) {
image.src = src;
}
} else {
onready();
}
} else {
// image already loaded...
onready();
}
}
function preloadimages() {
const swiper = this;
swiper.imagestoload = swiper.$el.find('img');
function onready() {
if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper.destroyed) return;
if (swiper.imagesloaded !== undefined) swiper.imagesloaded += 1;
if (swiper.imagesloaded === swiper.imagestoload.length) {
if (swiper.params.updateonimagesready) swiper.update();
swiper.emit('imagesready');
}
}
for (let i = 0; i < swiper.imagestoload.length; i += 1) {
const imageel = swiper.imagestoload[i];
swiper.loadimage(imageel, imageel.currentsrc || imageel.getattribute('src'), imageel.srcset || imageel.getattribute('srcset'), imageel.sizes || imageel.getattribute('sizes'), true, onready);
}
}
var images = {
loadimage,
preloadimages
};
function checkoverflow() {
const swiper = this;
const {
islocked: waslocked,
params
} = swiper;
const {
slidesoffsetbefore
} = params;
if (slidesoffsetbefore) {
const lastslideindex = swiper.slides.length - 1;
const lastsliderightedge = swiper.slidesgrid[lastslideindex] + swiper.slidessizesgrid[lastslideindex] + slidesoffsetbefore * 2;
swiper.islocked = swiper.size > lastsliderightedge;
} else {
swiper.islocked = swiper.snapgrid.length === 1;
}
if (params.allowslidenext === true) {
swiper.allowslidenext = !swiper.islocked;
}
if (params.allowslideprev === true) {
swiper.allowslideprev = !swiper.islocked;
}
if (waslocked && waslocked !== swiper.islocked) {
swiper.isend = false;
}
if (waslocked !== swiper.islocked) {
swiper.emit(swiper.islocked ? 'lock' : 'unlock');
}
}
var checkoverflow$1 = {
checkoverflow
};
var defaults = {
init: true,
direction: 'horizontal',
toucheventstarget: 'wrapper',
initialslide: 0,
speed: 300,
cssmode: false,
updateonwindowresize: true,
resizeobserver: true,
nested: false,
createelements: false,
enabled: true,
focusableelements: 'input, select, option, textarea, button, video, label',
// overrides
width: null,
height: null,
//
preventinteractionontransition: false,
// ssr
useragent: null,
url: null,
// to support ios's swipe-to-go-back gesture (when being used in-app).
edgeswipedetection: false,
edgeswipethreshold: 20,
// autoheight
autoheight: false,
// set wrapper width
setwrappersize: false,
// virtual translate
virtualtranslate: false,
// effects
effect: 'slide',
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
// breakpoints
breakpoints: undefined,
breakpointsbase: 'window',
// slides grid
spacebetween: 0,
slidesperview: 1,
slidespergroup: 1,
slidespergroupskip: 0,
slidespergroupauto: false,
centeredslides: false,
centeredslidesbounds: false,
slidesoffsetbefore: 0,
// in px
slidesoffsetafter: 0,
// in px
normalizeslideindex: true,
centerinsufficientslides: false,
// disable swiper and hide navigation when container not overflow
watchoverflow: true,
// round length
roundlengths: false,
// touches
touchratio: 1,
touchangle: 45,
simulatetouch: true,
shortswipes: true,
longswipes: true,
longswipesratio: 0.5,
longswipesms: 300,
followfinger: true,
allowtouchmove: true,
threshold: 0,
touchmovestoppropagation: false,
touchstartpreventdefault: true,
touchstartforcepreventdefault: false,
touchreleaseonedges: false,
// unique navigation elements
uniquenavelements: true,
// resistance
resistance: true,
resistanceratio: 0.85,
// progress
watchslidesprogress: false,
// cursor
grabcursor: false,
// clicks
preventclicks: true,
preventclickspropagation: true,
slidetoclickedslide: false,
// images
preloadimages: true,
updateonimagesready: true,
// loop
loop: false,
loopadditionalslides: 0,
loopedslides: null,
loopfillgroupwithblank: false,
looppreventsslide: true,
// rewind
rewind: false,
// swiping/no swiping
allowslideprev: true,
allowslidenext: true,
swipehandler: null,
// '.swipe-handler',
noswiping: true,
noswipingclass: 'swiper-no-swiping',
noswipingselector: null,
// passive listeners
passivelisteners: true,
maxbackfacehiddenslides: 10,
// ns
containermodifierclass: 'swiper-',
// new
slideclass: 'swiper-slide',
slideblankclass: 'swiper-slide-invisible-blank',
slideactiveclass: 'swiper-slide-active',
slideduplicateactiveclass: 'swiper-slide-duplicate-active',
slidevisibleclass: 'swiper-slide-visible',
slideduplicateclass: 'swiper-slide-duplicate',
slidenextclass: 'swiper-slide-next',
slideduplicatenextclass: 'swiper-slide-duplicate-next',
slideprevclass: 'swiper-slide-prev',
slideduplicateprevclass: 'swiper-slide-duplicate-prev',
wrapperclass: 'swiper-wrapper',
// callbacks
runcallbacksoninit: true,
// internals
_emitclasses: false
};
function moduleextendparams(params, allmodulesparams) {
return function extendparams(obj) {
if (obj === void 0) {
obj = {};
}
const moduleparamname = object.keys(obj)[0];
const moduleparams = obj[moduleparamname];
if (typeof moduleparams !== 'object' || moduleparams === null) {
extend(allmodulesparams, obj);
return;
}
if (['navigation', 'pagination', 'scrollbar'].indexof(moduleparamname) >= 0 && params[moduleparamname] === true) {
params[moduleparamname] = {
auto: true
};
}
if (!(moduleparamname in params && 'enabled' in moduleparams)) {
extend(allmodulesparams, obj);
return;
}
if (params[moduleparamname] === true) {
params[moduleparamname] = {
enabled: true
};
}
if (typeof params[moduleparamname] === 'object' && !('enabled' in params[moduleparamname])) {
params[moduleparamname].enabled = true;
}
if (!params[moduleparamname]) params[moduleparamname] = {
enabled: false
};
extend(allmodulesparams, obj);
};
}
/* eslint no-param-reassign: "off" */
const prototypes = {
eventsemitter,
update,
translate,
transition,
slide,
loop,
grabcursor,
events: events$1,
breakpoints,
checkoverflow: checkoverflow$1,
classes,
images
};
const extendeddefaults = {};
class swiper {
constructor() {
let el;
let params;
for (var _len = arguments.length, args = new array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (args.length === 1 && args[0].constructor && object.prototype.tostring.call(args[0]).slice(8, -1) === 'object') {
params = args[0];
} else {
[el, params] = args;
}
if (!params) params = {};
params = extend({}, params);
if (el && !params.el) params.el = el;
if (params.el && $(params.el).length > 1) {
const swipers = [];
$(params.el).each(containerel => {
const newparams = extend({}, params, {
el: containerel
});
swipers.push(new swiper(newparams));
});
return swipers;
} // swiper instance
const swiper = this;
swiper.__swiper__ = true;
swiper.support = getsupport();
swiper.device = getdevice({
useragent: params.useragent
});
swiper.browser = getbrowser();
swiper.eventslisteners = {};
swiper.eventsanylisteners = [];
swiper.modules = [...swiper.__modules__];
if (params.modules && array.isarray(params.modules)) {
swiper.modules.push(...params.modules);
}
const allmodulesparams = {};
swiper.modules.foreach(mod => {
mod({
swiper,
extendparams: moduleextendparams(params, allmodulesparams),
on: swiper.on.bind(swiper),
once: swiper.once.bind(swiper),
off: swiper.off.bind(swiper),
emit: swiper.emit.bind(swiper)
});
}); // extend defaults with modules params
const swiperparams = extend({}, defaults, allmodulesparams); // extend defaults with passed params
swiper.params = extend({}, swiperparams, extendeddefaults, params);
swiper.originalparams = extend({}, swiper.params);
swiper.passedparams = extend({}, params); // add event listeners
if (swiper.params && swiper.params.on) {
object.keys(swiper.params.on).foreach(eventname => {
swiper.on(eventname, swiper.params.on[eventname]);
});
}
if (swiper.params && swiper.params.onany) {
swiper.onany(swiper.params.onany);
} // save dom lib
swiper.$ = $; // extend swiper
object.assign(swiper, {
enabled: swiper.params.enabled,
el,
// classes
classnames: [],
// slides
slides: $(),
slidesgrid: [],
snapgrid: [],
slidessizesgrid: [],
// isdirection
ishorizontal() {
return swiper.params.direction === 'horizontal';
},
isvertical() {
return swiper.params.direction === 'vertical';
},
// indexes
activeindex: 0,
realindex: 0,
//
isbeginning: true,
isend: false,
// props
translate: 0,
previoustranslate: 0,
progress: 0,
velocity: 0,
animating: false,
// locks
allowslidenext: swiper.params.allowslidenext,
allowslideprev: swiper.params.allowslideprev,
// touch events
touchevents: function touchevents() {
const touch = ['touchstart', 'touchmove', 'touchend', 'touchcancel'];
const desktop = ['pointerdown', 'pointermove', 'pointerup'];
swiper.toucheventstouch = {
start: touch[0],
move: touch[1],
end: touch[2],
cancel: touch[3]
};
swiper.toucheventsdesktop = {
start: desktop[0],
move: desktop[1],
end: desktop[2]
};
return swiper.support.touch || !swiper.params.simulatetouch ? swiper.toucheventstouch : swiper.toucheventsdesktop;
}(),
toucheventsdata: {
istouched: undefined,
ismoved: undefined,
allowtouchcallbacks: undefined,
touchstarttime: undefined,
isscrolling: undefined,
currenttranslate: undefined,
starttranslate: undefined,
allowthresholdmove: undefined,
// form elements to match
focusableelements: swiper.params.focusableelements,
// last click time
lastclicktime: now(),
clicktimeout: undefined,
// velocities
velocities: [],
allowmomentumbounce: undefined,
istouchevent: undefined,
startmoving: undefined
},
// clicks
allowclick: true,
// touches
allowtouchmove: swiper.params.allowtouchmove,
touches: {
startx: 0,
starty: 0,
currentx: 0,
currenty: 0,
diff: 0
},
// images
imagestoload: [],
imagesloaded: 0
});
swiper.emit('_swiper'); // init
if (swiper.params.init) {
swiper.init();
} // return app instance
return swiper;
}
enable() {
const swiper = this;
if (swiper.enabled) return;
swiper.enabled = true;
if (swiper.params.grabcursor) {
swiper.setgrabcursor();
}
swiper.emit('enable');
}
disable() {
const swiper = this;
if (!swiper.enabled) return;
swiper.enabled = false;
if (swiper.params.grabcursor) {
swiper.unsetgrabcursor();
}
swiper.emit('disable');
}
setprogress(progress, speed) {
const swiper = this;
progress = math.min(math.max(progress, 0), 1);
const min = swiper.mintranslate();
const max = swiper.maxtranslate();
const current = (max - min) * progress + min;
swiper.translateto(current, typeof speed === 'undefined' ? 0 : speed);
swiper.updateactiveindex();
swiper.updateslidesclasses();
}
emitcontainerclasses() {
const swiper = this;
if (!swiper.params._emitclasses || !swiper.el) return;
const cls = swiper.el.classname.split(' ').filter(classname => {
return classname.indexof('swiper') === 0 || classname.indexof(swiper.params.containermodifierclass) === 0;
});
swiper.emit('_containerclasses', cls.join(' '));
}
getslideclasses(slideel) {
const swiper = this;
if (swiper.destroyed) return '';
return slideel.classname.split(' ').filter(classname => {
return classname.indexof('swiper-slide') === 0 || classname.indexof(swiper.params.slideclass) === 0;
}).join(' ');
}
emitslidesclasses() {
const swiper = this;
if (!swiper.params._emitclasses || !swiper.el) return;
const updates = [];
swiper.slides.each(slideel => {
const classnames = swiper.getslideclasses(slideel);
updates.push({
slideel,
classnames
});
swiper.emit('_slideclass', slideel, classnames);
});
swiper.emit('_slideclasses', updates);
}
slidesperviewdynamic(view, exact) {
if (view === void 0) {
view = 'current';
}
if (exact === void 0) {
exact = false;
}
const swiper = this;
const {
params,
slides,
slidesgrid,
slidessizesgrid,
size: swipersize,
activeindex
} = swiper;
let spv = 1;
if (params.centeredslides) {
let slidesize = slides[activeindex].swiperslidesize;
let breakloop;
for (let i = activeindex + 1; i < slides.length; i += 1) {
if (slides[i] && !breakloop) {
slidesize += slides[i].swiperslidesize;
spv += 1;
if (slidesize > swipersize) breakloop = true;
}
}
for (let i = activeindex - 1; i >= 0; i -= 1) {
if (slides[i] && !breakloop) {
slidesize += slides[i].swiperslidesize;
spv += 1;
if (slidesize > swipersize) breakloop = true;
}
}
} else {
// eslint-disable-next-line
if (view === 'current') {
for (let i = activeindex + 1; i < slides.length; i += 1) {
const slideinview = exact ? slidesgrid[i] + slidessizesgrid[i] - slidesgrid[activeindex] < swipersize : slidesgrid[i] - slidesgrid[activeindex] < swipersize;
if (slideinview) {
spv += 1;
}
}
} else {
// previous
for (let i = activeindex - 1; i >= 0; i -= 1) {
const slideinview = slidesgrid[activeindex] - slidesgrid[i] < swipersize;
if (slideinview) {
spv += 1;
}
}
}
}
return spv;
}
update() {
const swiper = this;
if (!swiper || swiper.destroyed) return;
const {
snapgrid,
params
} = swiper; // breakpoints
if (params.breakpoints) {
swiper.setbreakpoint();
}
swiper.updatesize();
swiper.updateslides();
swiper.updateprogress();
swiper.updateslidesclasses();
function settranslate() {
const translatevalue = swiper.rtltranslate ? swiper.translate * -1 : swiper.translate;
const newtranslate = math.min(math.max(translatevalue, swiper.maxtranslate()), swiper.mintranslate());
swiper.settranslate(newtranslate);
swiper.updateactiveindex();
swiper.updateslidesclasses();
}
let translated;
if (swiper.params.freemode && swiper.params.freemode.enabled) {
settranslate();
if (swiper.params.autoheight) {
swiper.updateautoheight();
}
} else {
if ((swiper.params.slidesperview === 'auto' || swiper.params.slidesperview > 1) && swiper.isend && !swiper.params.centeredslides) {
translated = swiper.slideto(swiper.slides.length - 1, 0, false, true);
} else {
translated = swiper.slideto(swiper.activeindex, 0, false, true);
}
if (!translated) {
settranslate();
}
}
if (params.watchoverflow && snapgrid !== swiper.snapgrid) {
swiper.checkoverflow();
}
swiper.emit('update');
}
changedirection(newdirection, needupdate) {
if (needupdate === void 0) {
needupdate = true;
}
const swiper = this;
const currentdirection = swiper.params.direction;
if (!newdirection) {
// eslint-disable-next-line
newdirection = currentdirection === 'horizontal' ? 'vertical' : 'horizontal';
}
if (newdirection === currentdirection || newdirection !== 'horizontal' && newdirection !== 'vertical') {
return swiper;
}
swiper.$el.removeclass(`${swiper.params.containermodifierclass}${currentdirection}`).addclass(`${swiper.params.containermodifierclass}${newdirection}`);
swiper.emitcontainerclasses();
swiper.params.direction = newdirection;
swiper.slides.each(slideel => {
if (newdirection === 'vertical') {
slideel.style.width = '';
} else {
slideel.style.height = '';
}
});
swiper.emit('changedirection');
if (needupdate) swiper.update();
return swiper;
}
changelanguagedirection(direction) {
const swiper = this;
if (swiper.rtl && direction === 'rtl' || !swiper.rtl && direction === 'ltr') return;
swiper.rtl = direction === 'rtl';
swiper.rtltranslate = swiper.params.direction === 'horizontal' && swiper.rtl;
if (swiper.rtl) {
swiper.$el.addclass(`${swiper.params.containermodifierclass}rtl`);
swiper.el.dir = 'rtl';
} else {
swiper.$el.removeclass(`${swiper.params.containermodifierclass}rtl`);
swiper.el.dir = 'ltr';
}
swiper.update();
}
mount(el) {
const swiper = this;
if (swiper.mounted) return true; // find el
const $el = $(el || swiper.params.el);
el = $el[0];
if (!el) {
return false;
}
el.swiper = swiper;
const getwrapperselector = () => {
return `.${(swiper.params.wrapperclass || '').trim().split(' ').join('.')}`;
};
const getwrapper = () => {
if (el && el.shadowroot && el.shadowroot.queryselector) {
const res = $(el.shadowroot.queryselector(getwrapperselector())); // children needs to return slot items
res.children = options => $el.children(options);
return res;
}
if (!$el.children) {
return $($el).children(getwrapperselector());
}
return $el.children(getwrapperselector());
}; // find wrapper
let $wrapperel = getwrapper();
if ($wrapperel.length === 0 && swiper.params.createelements) {
const document = getdocument();
const wrapper = document.createelement('div');
$wrapperel = $(wrapper);
wrapper.classname = swiper.params.wrapperclass;
$el.append(wrapper);
$el.children(`.${swiper.params.slideclass}`).each(slideel => {
$wrapperel.append(slideel);
});
}
object.assign(swiper, {
$el,
el,
$wrapperel,
wrapperel: $wrapperel[0],
mounted: true,
// rtl
rtl: el.dir.tolowercase() === 'rtl' || $el.css('direction') === 'rtl',
rtltranslate: swiper.params.direction === 'horizontal' && (el.dir.tolowercase() === 'rtl' || $el.css('direction') === 'rtl'),
wrongrtl: $wrapperel.css('display') === '-webkit-box'
});
return true;
}
init(el) {
const swiper = this;
if (swiper.initialized) return swiper;
const mounted = swiper.mount(el);
if (mounted === false) return swiper;
swiper.emit('beforeinit'); // set breakpoint
if (swiper.params.breakpoints) {
swiper.setbreakpoint();
} // add classes
swiper.addclasses(); // create loop
if (swiper.params.loop) {
swiper.loopcreate();
} // update size
swiper.updatesize(); // update slides
swiper.updateslides();
if (swiper.params.watchoverflow) {
swiper.checkoverflow();
} // set grab cursor
if (swiper.params.grabcursor && swiper.enabled) {
swiper.setgrabcursor();
}
if (swiper.params.preloadimages) {
swiper.preloadimages();
} // slide to initial slide
if (swiper.params.loop) {
swiper.slideto(swiper.params.initialslide + swiper.loopedslides, 0, swiper.params.runcallbacksoninit, false, true);
} else {
swiper.slideto(swiper.params.initialslide, 0, swiper.params.runcallbacksoninit, false, true);
} // attach events
swiper.attachevents(); // init flag
swiper.initialized = true; // emit
swiper.emit('init');
swiper.emit('afterinit');
return swiper;
}
destroy(deleteinstance, cleanstyles) {
if (deleteinstance === void 0) {
deleteinstance = true;
}
if (cleanstyles === void 0) {
cleanstyles = true;
}
const swiper = this;
const {
params,
$el,
$wrapperel,
slides
} = swiper;
if (typeof swiper.params === 'undefined' || swiper.destroyed) {
return null;
}
swiper.emit('beforedestroy'); // init flag
swiper.initialized = false; // detach events
swiper.detachevents(); // destroy loop
if (params.loop) {
swiper.loopdestroy();
} // cleanup styles
if (cleanstyles) {
swiper.removeclasses();
$el.removeattr('style');
$wrapperel.removeattr('style');
if (slides && slides.length) {
slides.removeclass([params.slidevisibleclass, params.slideactiveclass, params.slidenextclass, params.slideprevclass].join(' ')).removeattr('style').removeattr('data-swiper-slide-index');
}
}
swiper.emit('destroy'); // detach emitter events
object.keys(swiper.eventslisteners).foreach(eventname => {
swiper.off(eventname);
});
if (deleteinstance !== false) {
swiper.$el[0].swiper = null;
deleteprops(swiper);
}
swiper.destroyed = true;
return null;
}
static extenddefaults(newdefaults) {
extend(extendeddefaults, newdefaults);
}
static get extendeddefaults() {
return extendeddefaults;
}
static get defaults() {
return defaults;
}
static installmodule(mod) {
if (!swiper.prototype.__modules__) swiper.prototype.__modules__ = [];
const modules = swiper.prototype.__modules__;
if (typeof mod === 'function' && modules.indexof(mod) < 0) {
modules.push(mod);
}
}
static use(module) {
if (array.isarray(module)) {
module.foreach(m => swiper.installmodule(m));
return swiper;
}
swiper.installmodule(module);
return swiper;
}
}
object.keys(prototypes).foreach(prototypegroup => {
object.keys(prototypes[prototypegroup]).foreach(protomethod => {
swiper.prototype[protomethod] = prototypes[prototypegroup][protomethod];
});
});
swiper.use([resize, observer]);
function virtual(_ref) {
let {
swiper,
extendparams,
on,
emit
} = _ref;
extendparams({
virtual: {
enabled: false,
slides: [],
cache: true,
renderslide: null,
renderexternal: null,
renderexternalupdate: true,
addslidesbefore: 0,
addslidesafter: 0
}
});
let cssmodetimeout;
swiper.virtual = {
cache: {},
from: undefined,
to: undefined,
slides: [],
offset: 0,
slidesgrid: []
};
function renderslide(slide, index) {
const params = swiper.params.virtual;
if (params.cache && swiper.virtual.cache[index]) {
return swiper.virtual.cache[index];
}
const $slideel = params.renderslide ? $(params.renderslide.call(swiper, slide, index)) : $(`${slide}
`);
if (!$slideel.attr('data-swiper-slide-index')) $slideel.attr('data-swiper-slide-index', index);
if (params.cache) swiper.virtual.cache[index] = $slideel;
return $slideel;
}
function update(force) {
const {
slidesperview,
slidespergroup,
centeredslides
} = swiper.params;
const {
addslidesbefore,
addslidesafter
} = swiper.params.virtual;
const {
from: previousfrom,
to: previousto,
slides,
slidesgrid: previousslidesgrid,
offset: previousoffset
} = swiper.virtual;
if (!swiper.params.cssmode) {
swiper.updateactiveindex();
}
const activeindex = swiper.activeindex || 0;
let offsetprop;
if (swiper.rtltranslate) offsetprop = 'right';else offsetprop = swiper.ishorizontal() ? 'left' : 'top';
let slidesafter;
let slidesbefore;
if (centeredslides) {
slidesafter = math.floor(slidesperview / 2) + slidespergroup + addslidesafter;
slidesbefore = math.floor(slidesperview / 2) + slidespergroup + addslidesbefore;
} else {
slidesafter = slidesperview + (slidespergroup - 1) + addslidesafter;
slidesbefore = slidespergroup + addslidesbefore;
}
const from = math.max((activeindex || 0) - slidesbefore, 0);
const to = math.min((activeindex || 0) + slidesafter, slides.length - 1);
const offset = (swiper.slidesgrid[from] || 0) - (swiper.slidesgrid[0] || 0);
object.assign(swiper.virtual, {
from,
to,
offset,
slidesgrid: swiper.slidesgrid
});
function onrendered() {
swiper.updateslides();
swiper.updateprogress();
swiper.updateslidesclasses();
if (swiper.lazy && swiper.params.lazy.enabled) {
swiper.lazy.load();
}
emit('virtualupdate');
}
if (previousfrom === from && previousto === to && !force) {
if (swiper.slidesgrid !== previousslidesgrid && offset !== previousoffset) {
swiper.slides.css(offsetprop, `${offset}px`);
}
swiper.updateprogress();
emit('virtualupdate');
return;
}
if (swiper.params.virtual.renderexternal) {
swiper.params.virtual.renderexternal.call(swiper, {
offset,
from,
to,
slides: function getslides() {
const slidestorender = [];
for (let i = from; i <= to; i += 1) {
slidestorender.push(slides[i]);
}
return slidestorender;
}()
});
if (swiper.params.virtual.renderexternalupdate) {
onrendered();
} else {
emit('virtualupdate');
}
return;
}
const prependindexes = [];
const appendindexes = [];
if (force) {
swiper.$wrapperel.find(`.${swiper.params.slideclass}`).remove();
} else {
for (let i = previousfrom; i <= previousto; i += 1) {
if (i < from || i > to) {
swiper.$wrapperel.find(`.${swiper.params.slideclass}[data-swiper-slide-index="${i}"]`).remove();
}
}
}
for (let i = 0; i < slides.length; i += 1) {
if (i >= from && i <= to) {
if (typeof previousto === 'undefined' || force) {
appendindexes.push(i);
} else {
if (i > previousto) appendindexes.push(i);
if (i < previousfrom) prependindexes.push(i);
}
}
}
appendindexes.foreach(index => {
swiper.$wrapperel.append(renderslide(slides[index], index));
});
prependindexes.sort((a, b) => b - a).foreach(index => {
swiper.$wrapperel.prepend(renderslide(slides[index], index));
});
swiper.$wrapperel.children('.swiper-slide').css(offsetprop, `${offset}px`);
onrendered();
}
function appendslide(slides) {
if (typeof slides === 'object' && 'length' in slides) {
for (let i = 0; i < slides.length; i += 1) {
if (slides[i]) swiper.virtual.slides.push(slides[i]);
}
} else {
swiper.virtual.slides.push(slides);
}
update(true);
}
function prependslide(slides) {
const activeindex = swiper.activeindex;
let newactiveindex = activeindex + 1;
let numberofnewslides = 1;
if (array.isarray(slides)) {
for (let i = 0; i < slides.length; i += 1) {
if (slides[i]) swiper.virtual.slides.unshift(slides[i]);
}
newactiveindex = activeindex + slides.length;
numberofnewslides = slides.length;
} else {
swiper.virtual.slides.unshift(slides);
}
if (swiper.params.virtual.cache) {
const cache = swiper.virtual.cache;
const newcache = {};
object.keys(cache).foreach(cachedindex => {
const $cachedel = cache[cachedindex];
const cachedelindex = $cachedel.attr('data-swiper-slide-index');
if (cachedelindex) {
$cachedel.attr('data-swiper-slide-index', parseint(cachedelindex, 10) + numberofnewslides);
}
newcache[parseint(cachedindex, 10) + numberofnewslides] = $cachedel;
});
swiper.virtual.cache = newcache;
}
update(true);
swiper.slideto(newactiveindex, 0);
}
function removeslide(slidesindexes) {
if (typeof slidesindexes === 'undefined' || slidesindexes === null) return;
let activeindex = swiper.activeindex;
if (array.isarray(slidesindexes)) {
for (let i = slidesindexes.length - 1; i >= 0; i -= 1) {
swiper.virtual.slides.splice(slidesindexes[i], 1);
if (swiper.params.virtual.cache) {
delete swiper.virtual.cache[slidesindexes[i]];
}
if (slidesindexes[i] < activeindex) activeindex -= 1;
activeindex = math.max(activeindex, 0);
}
} else {
swiper.virtual.slides.splice(slidesindexes, 1);
if (swiper.params.virtual.cache) {
delete swiper.virtual.cache[slidesindexes];
}
if (slidesindexes < activeindex) activeindex -= 1;
activeindex = math.max(activeindex, 0);
}
update(true);
swiper.slideto(activeindex, 0);
}
function removeallslides() {
swiper.virtual.slides = [];
if (swiper.params.virtual.cache) {
swiper.virtual.cache = {};
}
update(true);
swiper.slideto(0, 0);
}
on('beforeinit', () => {
if (!swiper.params.virtual.enabled) return;
swiper.virtual.slides = swiper.params.virtual.slides;
swiper.classnames.push(`${swiper.params.containermodifierclass}virtual`);
swiper.params.watchslidesprogress = true;
swiper.originalparams.watchslidesprogress = true;
if (!swiper.params.initialslide) {
update();
}
});
on('settranslate', () => {
if (!swiper.params.virtual.enabled) return;
if (swiper.params.cssmode && !swiper._immediatevirtual) {
cleartimeout(cssmodetimeout);
cssmodetimeout = settimeout(() => {
update();
}, 100);
} else {
update();
}
});
on('init update resize', () => {
if (!swiper.params.virtual.enabled) return;
if (swiper.params.cssmode) {
setcssproperty(swiper.wrapperel, '--swiper-virtual-size', `${swiper.virtualsize}px`);
}
});
object.assign(swiper.virtual, {
appendslide,
prependslide,
removeslide,
removeallslides,
update
});
}
/* eslint-disable consistent-return */
function keyboard(_ref) {
let {
swiper,
extendparams,
on,
emit
} = _ref;
const document = getdocument();
const window = getwindow();
swiper.keyboard = {
enabled: false
};
extendparams({
keyboard: {
enabled: false,
onlyinviewport: true,
pageupdown: true
}
});
function handle(event) {
if (!swiper.enabled) return;
const {
rtltranslate: rtl
} = swiper;
let e = event;
if (e.originalevent) e = e.originalevent; // jquery fix
const kc = e.keycode || e.charcode;
const pageupdown = swiper.params.keyboard.pageupdown;
const ispageup = pageupdown && kc === 33;
const ispagedown = pageupdown && kc === 34;
const isarrowleft = kc === 37;
const isarrowright = kc === 39;
const isarrowup = kc === 38;
const isarrowdown = kc === 40; // directions locks
if (!swiper.allowslidenext && (swiper.ishorizontal() && isarrowright || swiper.isvertical() && isarrowdown || ispagedown)) {
return false;
}
if (!swiper.allowslideprev && (swiper.ishorizontal() && isarrowleft || swiper.isvertical() && isarrowup || ispageup)) {
return false;
}
if (e.shiftkey || e.altkey || e.ctrlkey || e.metakey) {
return undefined;
}
if (document.activeelement && document.activeelement.nodename && (document.activeelement.nodename.tolowercase() === 'input' || document.activeelement.nodename.tolowercase() === 'textarea')) {
return undefined;
}
if (swiper.params.keyboard.onlyinviewport && (ispageup || ispagedown || isarrowleft || isarrowright || isarrowup || isarrowdown)) {
let inview = false; // check that swiper should be inside of visible area of window
if (swiper.$el.parents(`.${swiper.params.slideclass}`).length > 0 && swiper.$el.parents(`.${swiper.params.slideactiveclass}`).length === 0) {
return undefined;
}
const $el = swiper.$el;
const swiperwidth = $el[0].clientwidth;
const swiperheight = $el[0].clientheight;
const windowwidth = window.innerwidth;
const windowheight = window.innerheight;
const swiperoffset = swiper.$el.offset();
if (rtl) swiperoffset.left -= swiper.$el[0].scrollleft;
const swipercoord = [[swiperoffset.left, swiperoffset.top], [swiperoffset.left + swiperwidth, swiperoffset.top], [swiperoffset.left, swiperoffset.top + swiperheight], [swiperoffset.left + swiperwidth, swiperoffset.top + swiperheight]];
for (let i = 0; i < swipercoord.length; i += 1) {
const point = swipercoord[i];
if (point[0] >= 0 && point[0] <= windowwidth && point[1] >= 0 && point[1] <= windowheight) {
if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line
inview = true;
}
}
if (!inview) return undefined;
}
if (swiper.ishorizontal()) {
if (ispageup || ispagedown || isarrowleft || isarrowright) {
if (e.preventdefault) e.preventdefault();else e.returnvalue = false;
}
if ((ispagedown || isarrowright) && !rtl || (ispageup || isarrowleft) && rtl) swiper.slidenext();
if ((ispageup || isarrowleft) && !rtl || (ispagedown || isarrowright) && rtl) swiper.slideprev();
} else {
if (ispageup || ispagedown || isarrowup || isarrowdown) {
if (e.preventdefault) e.preventdefault();else e.returnvalue = false;
}
if (ispagedown || isarrowdown) swiper.slidenext();
if (ispageup || isarrowup) swiper.slideprev();
}
emit('keypress', kc);
return undefined;
}
function enable() {
if (swiper.keyboard.enabled) return;
$(document).on('keydown', handle);
swiper.keyboard.enabled = true;
}
function disable() {
if (!swiper.keyboard.enabled) return;
$(document).off('keydown', handle);
swiper.keyboard.enabled = false;
}
on('init', () => {
if (swiper.params.keyboard.enabled) {
enable();
}
});
on('destroy', () => {
if (swiper.keyboard.enabled) {
disable();
}
});
object.assign(swiper.keyboard, {
enable,
disable
});
}
/* eslint-disable consistent-return */
function mousewheel(_ref) {
let {
swiper,
extendparams,
on,
emit
} = _ref;
const window = getwindow();
extendparams({
mousewheel: {
enabled: false,
releaseonedges: false,
invert: false,
forcetoaxis: false,
sensitivity: 1,
eventstarget: 'container',
thresholddelta: null,
thresholdtime: null
}
});
swiper.mousewheel = {
enabled: false
};
let timeout;
let lastscrolltime = now();
let lasteventbeforesnap;
const recentwheelevents = [];
function normalize(e) {
// reasonable defaults
const pixel_step = 10;
const line_height = 40;
const page_height = 800;
let sx = 0;
let sy = 0; // spinx, spiny
let px = 0;
let py = 0; // pixelx, pixely
// legacy
if ('detail' in e) {
sy = e.detail;
}
if ('wheeldelta' in e) {
sy = -e.wheeldelta / 120;
}
if ('wheeldeltay' in e) {
sy = -e.wheeldeltay / 120;
}
if ('wheeldeltax' in e) {
sx = -e.wheeldeltax / 120;
} // side scrolling on ff with dommousescroll
if ('axis' in e && e.axis === e.horizontal_axis) {
sx = sy;
sy = 0;
}
px = sx * pixel_step;
py = sy * pixel_step;
if ('deltay' in e) {
py = e.deltay;
}
if ('deltax' in e) {
px = e.deltax;
}
if (e.shiftkey && !px) {
// if user scrolls with shift he wants horizontal scroll
px = py;
py = 0;
}
if ((px || py) && e.deltamode) {
if (e.deltamode === 1) {
// delta in line units
px *= line_height;
py *= line_height;
} else {
// delta in page units
px *= page_height;
py *= page_height;
}
} // fall-back if spin cannot be determined
if (px && !sx) {
sx = px < 1 ? -1 : 1;
}
if (py && !sy) {
sy = py < 1 ? -1 : 1;
}
return {
spinx: sx,
spiny: sy,
pixelx: px,
pixely: py
};
}
function handlemouseenter() {
if (!swiper.enabled) return;
swiper.mouseentered = true;
}
function handlemouseleave() {
if (!swiper.enabled) return;
swiper.mouseentered = false;
}
function animateslider(newevent) {
if (swiper.params.mousewheel.thresholddelta && newevent.delta < swiper.params.mousewheel.thresholddelta) {
// prevent if delta of wheel scroll delta is below configured threshold
return false;
}
if (swiper.params.mousewheel.thresholdtime && now() - lastscrolltime < swiper.params.mousewheel.thresholdtime) {
// prevent if time between scrolls is below configured threshold
return false;
} // if the movement is not big enough and
// if the last time the user scrolled was too close to the current one (avoid continuously triggering the slider):
// don't go any further (avoid insignificant scroll movement).
if (newevent.delta >= 6 && now() - lastscrolltime < 60) {
// return false as a default
return true;
} // if user is scrolling towards the end:
// if the slider hasn't hit the latest slide or
// if the slider is a loop and
// if the slider isn't moving right now:
// go to next slide and
// emit a scroll event.
// else (the user is scrolling towards the beginning) and
// if the slider hasn't hit the first slide or
// if the slider is a loop and
// if the slider isn't moving right now:
// go to prev slide and
// emit a scroll event.
if (newevent.direction < 0) {
if ((!swiper.isend || swiper.params.loop) && !swiper.animating) {
swiper.slidenext();
emit('scroll', newevent.raw);
}
} else if ((!swiper.isbeginning || swiper.params.loop) && !swiper.animating) {
swiper.slideprev();
emit('scroll', newevent.raw);
} // if you got here is because an animation has been triggered so store the current time
lastscrolltime = new window.date().gettime(); // return false as a default
return false;
}
function releasescroll(newevent) {
const params = swiper.params.mousewheel;
if (newevent.direction < 0) {
if (swiper.isend && !swiper.params.loop && params.releaseonedges) {
// return true to animate scroll on edges
return true;
}
} else if (swiper.isbeginning && !swiper.params.loop && params.releaseonedges) {
// return true to animate scroll on edges
return true;
}
return false;
}
function handle(event) {
let e = event;
let disableparentswiper = true;
if (!swiper.enabled) return;
const params = swiper.params.mousewheel;
if (swiper.params.cssmode) {
e.preventdefault();
}
let target = swiper.$el;
if (swiper.params.mousewheel.eventstarget !== 'container') {
target = $(swiper.params.mousewheel.eventstarget);
}
if (!swiper.mouseentered && !target[0].contains(e.target) && !params.releaseonedges) return true;
if (e.originalevent) e = e.originalevent; // jquery fix
let delta = 0;
const rtlfactor = swiper.rtltranslate ? -1 : 1;
const data = normalize(e);
if (params.forcetoaxis) {
if (swiper.ishorizontal()) {
if (math.abs(data.pixelx) > math.abs(data.pixely)) delta = -data.pixelx * rtlfactor;else return true;
} else if (math.abs(data.pixely) > math.abs(data.pixelx)) delta = -data.pixely;else return true;
} else {
delta = math.abs(data.pixelx) > math.abs(data.pixely) ? -data.pixelx * rtlfactor : -data.pixely;
}
if (delta === 0) return true;
if (params.invert) delta = -delta; // get the scroll positions
let positions = swiper.gettranslate() + delta * params.sensitivity;
if (positions >= swiper.mintranslate()) positions = swiper.mintranslate();
if (positions <= swiper.maxtranslate()) positions = swiper.maxtranslate(); // when loop is true:
// the disableparentswiper will be true.
// when loop is false:
// if the scroll positions is not on edge,
// then the disableparentswiper will be true.
// if the scroll on edge positions,
// then the disableparentswiper will be false.
disableparentswiper = swiper.params.loop ? true : !(positions === swiper.mintranslate() || positions === swiper.maxtranslate());
if (disableparentswiper && swiper.params.nested) e.stoppropagation();
if (!swiper.params.freemode || !swiper.params.freemode.enabled) {
// register the new event in a variable which stores the relevant data
const newevent = {
time: now(),
delta: math.abs(delta),
direction: math.sign(delta),
raw: event
}; // keep the most recent events
if (recentwheelevents.length >= 2) {
recentwheelevents.shift(); // only store the last n events
}
const prevevent = recentwheelevents.length ? recentwheelevents[recentwheelevents.length - 1] : undefined;
recentwheelevents.push(newevent); // if there is at least one previous recorded event:
// if direction has changed or
// if the scroll is quicker than the previous one:
// animate the slider.
// else (this is the first time the wheel is moved):
// animate the slider.
if (prevevent) {
if (newevent.direction !== prevevent.direction || newevent.delta > prevevent.delta || newevent.time > prevevent.time + 150) {
animateslider(newevent);
}
} else {
animateslider(newevent);
} // if it's time to release the scroll:
// return now so you don't hit the preventdefault.
if (releasescroll(newevent)) {
return true;
}
} else {
// freemode or scrollcontainer:
// if we recently snapped after a momentum scroll, then ignore wheel events
// to give time for the deceleration to finish. stop ignoring after 500 msecs
// or if it's a new scroll (larger delta or inverse sign as last event before
// an end-of-momentum snap).
const newevent = {
time: now(),
delta: math.abs(delta),
direction: math.sign(delta)
};
const ignorewheelevents = lasteventbeforesnap && newevent.time < lasteventbeforesnap.time + 500 && newevent.delta <= lasteventbeforesnap.delta && newevent.direction === lasteventbeforesnap.direction;
if (!ignorewheelevents) {
lasteventbeforesnap = undefined;
if (swiper.params.loop) {
swiper.loopfix();
}
let position = swiper.gettranslate() + delta * params.sensitivity;
const wasbeginning = swiper.isbeginning;
const wasend = swiper.isend;
if (position >= swiper.mintranslate()) position = swiper.mintranslate();
if (position <= swiper.maxtranslate()) position = swiper.maxtranslate();
swiper.settransition(0);
swiper.settranslate(position);
swiper.updateprogress();
swiper.updateactiveindex();
swiper.updateslidesclasses();
if (!wasbeginning && swiper.isbeginning || !wasend && swiper.isend) {
swiper.updateslidesclasses();
}
if (swiper.params.freemode.sticky) {
// when wheel scrolling starts with sticky (aka snap) enabled, then detect
// the end of a momentum scroll by storing recent (n=15?) wheel events.
// 1. do all n events have decreasing or same (absolute value) delta?
// 2. did all n events arrive in the last m (m=500?) msecs?
// 3. does the earliest event have an (absolute value) delta that's
// at least p (p=1?) larger than the most recent event's delta?
// 4. does the latest event have a delta that's smaller than q (q=6?) pixels?
// if 1-4 are "yes" then we're near the end of a momentum scroll deceleration.
// snap immediately and ignore remaining wheel events in this scroll.
// see comment above for "remaining wheel events in this scroll" determination.
// if 1-4 aren't satisfied, then wait to snap until 500ms after the last event.
cleartimeout(timeout);
timeout = undefined;
if (recentwheelevents.length >= 15) {
recentwheelevents.shift(); // only store the last n events
}
const prevevent = recentwheelevents.length ? recentwheelevents[recentwheelevents.length - 1] : undefined;
const firstevent = recentwheelevents[0];
recentwheelevents.push(newevent);
if (prevevent && (newevent.delta > prevevent.delta || newevent.direction !== prevevent.direction)) {
// increasing or reverse-sign delta means the user started scrolling again. clear the wheel event log.
recentwheelevents.splice(0);
} else if (recentwheelevents.length >= 15 && newevent.time - firstevent.time < 500 && firstevent.delta - newevent.delta >= 1 && newevent.delta <= 6) {
// we're at the end of the deceleration of a momentum scroll, so there's no need
// to wait for more events. snap asap on the next tick.
// also, because there's some remaining momentum we'll bias the snap in the
// direction of the ongoing scroll because it's better ux for the scroll to snap
// in the same direction as the scroll instead of reversing to snap. therefore,
// if it's already scrolled more than 20% in the current direction, keep going.
const snaptothreshold = delta > 0 ? 0.8 : 0.2;
lasteventbeforesnap = newevent;
recentwheelevents.splice(0);
timeout = nexttick(() => {
swiper.slidetoclosest(swiper.params.speed, true, undefined, snaptothreshold);
}, 0); // no delay; move on next tick
}
if (!timeout) {
// if we get here, then we haven't detected the end of a momentum scroll, so
// we'll consider a scroll "complete" when there haven't been any wheel events
// for 500ms.
timeout = nexttick(() => {
const snaptothreshold = 0.5;
lasteventbeforesnap = newevent;
recentwheelevents.splice(0);
swiper.slidetoclosest(swiper.params.speed, true, undefined, snaptothreshold);
}, 500);
}
} // emit event
if (!ignorewheelevents) emit('scroll', e); // stop autoplay
if (swiper.params.autoplay && swiper.params.autoplaydisableoninteraction) swiper.autoplay.stop(); // return page scroll on edge positions
if (position === swiper.mintranslate() || position === swiper.maxtranslate()) return true;
}
}
if (e.preventdefault) e.preventdefault();else e.returnvalue = false;
return false;
}
function events(method) {
let target = swiper.$el;
if (swiper.params.mousewheel.eventstarget !== 'container') {
target = $(swiper.params.mousewheel.eventstarget);
}
target[method]('mouseenter', handlemouseenter);
target[method]('mouseleave', handlemouseleave);
target[method]('wheel', handle);
}
function enable() {
if (swiper.params.cssmode) {
swiper.wrapperel.removeeventlistener('wheel', handle);
return true;
}
if (swiper.mousewheel.enabled) return false;
events('on');
swiper.mousewheel.enabled = true;
return true;
}
function disable() {
if (swiper.params.cssmode) {
swiper.wrapperel.addeventlistener(event, handle);
return true;
}
if (!swiper.mousewheel.enabled) return false;
events('off');
swiper.mousewheel.enabled = false;
return true;
}
on('init', () => {
if (!swiper.params.mousewheel.enabled && swiper.params.cssmode) {
disable();
}
if (swiper.params.mousewheel.enabled) enable();
});
on('destroy', () => {
if (swiper.params.cssmode) {
enable();
}
if (swiper.mousewheel.enabled) disable();
});
object.assign(swiper.mousewheel, {
enable,
disable
});
}
function createelementifnotdefined(swiper, originalparams, params, checkprops) {
const document = getdocument();
if (swiper.params.createelements) {
object.keys(checkprops).foreach(key => {
if (!params[key] && params.auto === true) {
let element = swiper.$el.children(`.${checkprops[key]}`)[0];
if (!element) {
element = document.createelement('div');
element.classname = checkprops[key];
swiper.$el.append(element);
}
params[key] = element;
originalparams[key] = element;
}
});
}
return params;
}
function navigation(_ref) {
let {
swiper,
extendparams,
on,
emit
} = _ref;
extendparams({
navigation: {
nextel: null,
prevel: null,
hideonclick: false,
disabledclass: 'swiper-button-disabled',
hiddenclass: 'swiper-button-hidden',
lockclass: 'swiper-button-lock',
navigationdisabledclass: 'swiper-navigation-disabled'
}
});
swiper.navigation = {
nextel: null,
$nextel: null,
prevel: null,
$prevel: null
};
function getel(el) {
let $el;
if (el) {
$el = $(el);
if (swiper.params.uniquenavelements && typeof el === 'string' && $el.length > 1 && swiper.$el.find(el).length === 1) {
$el = swiper.$el.find(el);
}
}
return $el;
}
function toggleel($el, disabled) {
const params = swiper.params.navigation;
if ($el && $el.length > 0) {
$el[disabled ? 'addclass' : 'removeclass'](params.disabledclass);
if ($el[0] && $el[0].tagname === 'button') $el[0].disabled = disabled;
if (swiper.params.watchoverflow && swiper.enabled) {
$el[swiper.islocked ? 'addclass' : 'removeclass'](params.lockclass);
}
}
}
function update() {
// update navigation buttons
if (swiper.params.loop) return;
const {
$nextel,
$prevel
} = swiper.navigation;
toggleel($prevel, swiper.isbeginning && !swiper.params.rewind);
toggleel($nextel, swiper.isend && !swiper.params.rewind);
}
function onprevclick(e) {
e.preventdefault();
if (swiper.isbeginning && !swiper.params.loop && !swiper.params.rewind) return;
swiper.slideprev();
emit('navigationprev');
}
function onnextclick(e) {
e.preventdefault();
if (swiper.isend && !swiper.params.loop && !swiper.params.rewind) return;
swiper.slidenext();
emit('navigationnext');
}
function init() {
const params = swiper.params.navigation;
swiper.params.navigation = createelementifnotdefined(swiper, swiper.originalparams.navigation, swiper.params.navigation, {
nextel: 'swiper-button-next',
prevel: 'swiper-button-prev'
});
if (!(params.nextel || params.prevel)) return;
const $nextel = getel(params.nextel);
const $prevel = getel(params.prevel);
if ($nextel && $nextel.length > 0) {
$nextel.on('click', onnextclick);
}
if ($prevel && $prevel.length > 0) {
$prevel.on('click', onprevclick);
}
object.assign(swiper.navigation, {
$nextel,
nextel: $nextel && $nextel[0],
$prevel,
prevel: $prevel && $prevel[0]
});
if (!swiper.enabled) {
if ($nextel) $nextel.addclass(params.lockclass);
if ($prevel) $prevel.addclass(params.lockclass);
}
}
function destroy() {
const {
$nextel,
$prevel
} = swiper.navigation;
if ($nextel && $nextel.length) {
$nextel.off('click', onnextclick);
$nextel.removeclass(swiper.params.navigation.disabledclass);
}
if ($prevel && $prevel.length) {
$prevel.off('click', onprevclick);
$prevel.removeclass(swiper.params.navigation.disabledclass);
}
}
on('init', () => {
if (swiper.params.navigation.enabled === false) {
// eslint-disable-next-line
disable();
} else {
init();
update();
}
});
on('toedge fromedge lock unlock', () => {
update();
});
on('destroy', () => {
destroy();
});
on('enable disable', () => {
const {
$nextel,
$prevel
} = swiper.navigation;
if ($nextel) {
$nextel[swiper.enabled ? 'removeclass' : 'addclass'](swiper.params.navigation.lockclass);
}
if ($prevel) {
$prevel[swiper.enabled ? 'removeclass' : 'addclass'](swiper.params.navigation.lockclass);
}
});
on('click', (_s, e) => {
const {
$nextel,
$prevel
} = swiper.navigation;
const targetel = e.target;
if (swiper.params.navigation.hideonclick && !$(targetel).is($prevel) && !$(targetel).is($nextel)) {
if (swiper.pagination && swiper.params.pagination && swiper.params.pagination.clickable && (swiper.pagination.el === targetel || swiper.pagination.el.contains(targetel))) return;
let ishidden;
if ($nextel) {
ishidden = $nextel.hasclass(swiper.params.navigation.hiddenclass);
} else if ($prevel) {
ishidden = $prevel.hasclass(swiper.params.navigation.hiddenclass);
}
if (ishidden === true) {
emit('navigationshow');
} else {
emit('navigationhide');
}
if ($nextel) {
$nextel.toggleclass(swiper.params.navigation.hiddenclass);
}
if ($prevel) {
$prevel.toggleclass(swiper.params.navigation.hiddenclass);
}
}
});
const enable = () => {
swiper.$el.removeclass(swiper.params.navigation.navigationdisabledclass);
init();
update();
};
const disable = () => {
swiper.$el.addclass(swiper.params.navigation.navigationdisabledclass);
destroy();
};
object.assign(swiper.navigation, {
enable,
disable,
update,
init,
destroy
});
}
function classestoselector(classes) {
if (classes === void 0) {
classes = '';
}
return `.${classes.trim().replace(/([\.:!\/])/g, '\\$1') // eslint-disable-line
.replace(/ /g, '.')}`;
}
function pagination(_ref) {
let {
swiper,
extendparams,
on,
emit
} = _ref;
const pfx = 'swiper-pagination';
extendparams({
pagination: {
el: null,
bulletelement: 'span',
clickable: false,
hideonclick: false,
renderbullet: null,
renderprogressbar: null,
renderfraction: null,
rendercustom: null,
progressbaropposite: false,
type: 'bullets',
// 'bullets' or 'progressbar' or 'fraction' or 'custom'
dynamicbullets: false,
dynamicmainbullets: 1,
formatfractioncurrent: number => number,
formatfractiontotal: number => number,
bulletclass: `${pfx}-bullet`,
bulletactiveclass: `${pfx}-bullet-active`,
modifierclass: `${pfx}-`,
currentclass: `${pfx}-current`,
totalclass: `${pfx}-total`,
hiddenclass: `${pfx}-hidden`,
progressbarfillclass: `${pfx}-progressbar-fill`,
progressbaroppositeclass: `${pfx}-progressbar-opposite`,
clickableclass: `${pfx}-clickable`,
lockclass: `${pfx}-lock`,
horizontalclass: `${pfx}-horizontal`,
verticalclass: `${pfx}-vertical`,
paginationdisabledclass: `${pfx}-disabled`
}
});
swiper.pagination = {
el: null,
$el: null,
bullets: []
};
let bulletsize;
let dynamicbulletindex = 0;
function ispaginationdisabled() {
return !swiper.params.pagination.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0;
}
function setsidebullets($bulletel, position) {
const {
bulletactiveclass
} = swiper.params.pagination;
$bulletel[position]().addclass(`${bulletactiveclass}-${position}`)[position]().addclass(`${bulletactiveclass}-${position}-${position}`);
}
function update() {
// render || update pagination bullets/items
const rtl = swiper.rtl;
const params = swiper.params.pagination;
if (ispaginationdisabled()) return;
const slideslength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length;
const $el = swiper.pagination.$el; // current/total
let current;
const total = swiper.params.loop ? math.ceil((slideslength - swiper.loopedslides * 2) / swiper.params.slidespergroup) : swiper.snapgrid.length;
if (swiper.params.loop) {
current = math.ceil((swiper.activeindex - swiper.loopedslides) / swiper.params.slidespergroup);
if (current > slideslength - 1 - swiper.loopedslides * 2) {
current -= slideslength - swiper.loopedslides * 2;
}
if (current > total - 1) current -= total;
if (current < 0 && swiper.params.paginationtype !== 'bullets') current = total + current;
} else if (typeof swiper.snapindex !== 'undefined') {
current = swiper.snapindex;
} else {
current = swiper.activeindex || 0;
} // types
if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) {
const bullets = swiper.pagination.bullets;
let firstindex;
let lastindex;
let midindex;
if (params.dynamicbullets) {
bulletsize = bullets.eq(0)[swiper.ishorizontal() ? 'outerwidth' : 'outerheight'](true);
$el.css(swiper.ishorizontal() ? 'width' : 'height', `${bulletsize * (params.dynamicmainbullets + 4)}px`);
if (params.dynamicmainbullets > 1 && swiper.previousindex !== undefined) {
dynamicbulletindex += current - (swiper.previousindex - swiper.loopedslides || 0);
if (dynamicbulletindex > params.dynamicmainbullets - 1) {
dynamicbulletindex = params.dynamicmainbullets - 1;
} else if (dynamicbulletindex < 0) {
dynamicbulletindex = 0;
}
}
firstindex = math.max(current - dynamicbulletindex, 0);
lastindex = firstindex + (math.min(bullets.length, params.dynamicmainbullets) - 1);
midindex = (lastindex + firstindex) / 2;
}
bullets.removeclass(['', '-next', '-next-next', '-prev', '-prev-prev', '-main'].map(suffix => `${params.bulletactiveclass}${suffix}`).join(' '));
if ($el.length > 1) {
bullets.each(bullet => {
const $bullet = $(bullet);
const bulletindex = $bullet.index();
if (bulletindex === current) {
$bullet.addclass(params.bulletactiveclass);
}
if (params.dynamicbullets) {
if (bulletindex >= firstindex && bulletindex <= lastindex) {
$bullet.addclass(`${params.bulletactiveclass}-main`);
}
if (bulletindex === firstindex) {
setsidebullets($bullet, 'prev');
}
if (bulletindex === lastindex) {
setsidebullets($bullet, 'next');
}
}
});
} else {
const $bullet = bullets.eq(current);
const bulletindex = $bullet.index();
$bullet.addclass(params.bulletactiveclass);
if (params.dynamicbullets) {
const $firstdisplayedbullet = bullets.eq(firstindex);
const $lastdisplayedbullet = bullets.eq(lastindex);
for (let i = firstindex; i <= lastindex; i += 1) {
bullets.eq(i).addclass(`${params.bulletactiveclass}-main`);
}
if (swiper.params.loop) {
if (bulletindex >= bullets.length) {
for (let i = params.dynamicmainbullets; i >= 0; i -= 1) {
bullets.eq(bullets.length - i).addclass(`${params.bulletactiveclass}-main`);
}
bullets.eq(bullets.length - params.dynamicmainbullets - 1).addclass(`${params.bulletactiveclass}-prev`);
} else {
setsidebullets($firstdisplayedbullet, 'prev');
setsidebullets($lastdisplayedbullet, 'next');
}
} else {
setsidebullets($firstdisplayedbullet, 'prev');
setsidebullets($lastdisplayedbullet, 'next');
}
}
}
if (params.dynamicbullets) {
const dynamicbulletslength = math.min(bullets.length, params.dynamicmainbullets + 4);
const bulletsoffset = (bulletsize * dynamicbulletslength - bulletsize) / 2 - midindex * bulletsize;
const offsetprop = rtl ? 'right' : 'left';
bullets.css(swiper.ishorizontal() ? offsetprop : 'top', `${bulletsoffset}px`);
}
}
if (params.type === 'fraction') {
$el.find(classestoselector(params.currentclass)).text(params.formatfractioncurrent(current + 1));
$el.find(classestoselector(params.totalclass)).text(params.formatfractiontotal(total));
}
if (params.type === 'progressbar') {
let progressbardirection;
if (params.progressbaropposite) {
progressbardirection = swiper.ishorizontal() ? 'vertical' : 'horizontal';
} else {
progressbardirection = swiper.ishorizontal() ? 'horizontal' : 'vertical';
}
const scale = (current + 1) / total;
let scalex = 1;
let scaley = 1;
if (progressbardirection === 'horizontal') {
scalex = scale;
} else {
scaley = scale;
}
$el.find(classestoselector(params.progressbarfillclass)).transform(`translate3d(0,0,0) scalex(${scalex}) scaley(${scaley})`).transition(swiper.params.speed);
}
if (params.type === 'custom' && params.rendercustom) {
$el.html(params.rendercustom(swiper, current + 1, total));
emit('paginationrender', $el[0]);
} else {
emit('paginationupdate', $el[0]);
}
if (swiper.params.watchoverflow && swiper.enabled) {
$el[swiper.islocked ? 'addclass' : 'removeclass'](params.lockclass);
}
}
function render() {
// render container
const params = swiper.params.pagination;
if (ispaginationdisabled()) return;
const slideslength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length;
const $el = swiper.pagination.$el;
let paginationhtml = '';
if (params.type === 'bullets') {
let numberofbullets = swiper.params.loop ? math.ceil((slideslength - swiper.loopedslides * 2) / swiper.params.slidespergroup) : swiper.snapgrid.length;
if (swiper.params.freemode && swiper.params.freemode.enabled && !swiper.params.loop && numberofbullets > slideslength) {
numberofbullets = slideslength;
}
for (let i = 0; i < numberofbullets; i += 1) {
if (params.renderbullet) {
paginationhtml += params.renderbullet.call(swiper, i, params.bulletclass);
} else {
paginationhtml += `<${params.bulletelement} class="${params.bulletclass}">${params.bulletelement}>`;
}
}
$el.html(paginationhtml);
swiper.pagination.bullets = $el.find(classestoselector(params.bulletclass));
}
if (params.type === 'fraction') {
if (params.renderfraction) {
paginationhtml = params.renderfraction.call(swiper, params.currentclass, params.totalclass);
} else {
paginationhtml = `` + ' / ' + ``;
}
$el.html(paginationhtml);
}
if (params.type === 'progressbar') {
if (params.renderprogressbar) {
paginationhtml = params.renderprogressbar.call(swiper, params.progressbarfillclass);
} else {
paginationhtml = ``;
}
$el.html(paginationhtml);
}
if (params.type !== 'custom') {
emit('paginationrender', swiper.pagination.$el[0]);
}
}
function init() {
swiper.params.pagination = createelementifnotdefined(swiper, swiper.originalparams.pagination, swiper.params.pagination, {
el: 'swiper-pagination'
});
const params = swiper.params.pagination;
if (!params.el) return;
let $el = $(params.el);
if ($el.length === 0) return;
if (swiper.params.uniquenavelements && typeof params.el === 'string' && $el.length > 1) {
$el = swiper.$el.find(params.el); // check if it belongs to another nested swiper
if ($el.length > 1) {
$el = $el.filter(el => {
if ($(el).parents('.swiper')[0] !== swiper.el) return false;
return true;
});
}
}
if (params.type === 'bullets' && params.clickable) {
$el.addclass(params.clickableclass);
}
$el.addclass(params.modifierclass + params.type);
$el.addclass(swiper.ishorizontal() ? params.horizontalclass : params.verticalclass);
if (params.type === 'bullets' && params.dynamicbullets) {
$el.addclass(`${params.modifierclass}${params.type}-dynamic`);
dynamicbulletindex = 0;
if (params.dynamicmainbullets < 1) {
params.dynamicmainbullets = 1;
}
}
if (params.type === 'progressbar' && params.progressbaropposite) {
$el.addclass(params.progressbaroppositeclass);
}
if (params.clickable) {
$el.on('click', classestoselector(params.bulletclass), function onclick(e) {
e.preventdefault();
let index = $(this).index() * swiper.params.slidespergroup;
if (swiper.params.loop) index += swiper.loopedslides;
swiper.slideto(index);
});
}
object.assign(swiper.pagination, {
$el,
el: $el[0]
});
if (!swiper.enabled) {
$el.addclass(params.lockclass);
}
}
function destroy() {
const params = swiper.params.pagination;
if (ispaginationdisabled()) return;
const $el = swiper.pagination.$el;
$el.removeclass(params.hiddenclass);
$el.removeclass(params.modifierclass + params.type);
$el.removeclass(swiper.ishorizontal() ? params.horizontalclass : params.verticalclass);
if (swiper.pagination.bullets && swiper.pagination.bullets.removeclass) swiper.pagination.bullets.removeclass(params.bulletactiveclass);
if (params.clickable) {
$el.off('click', classestoselector(params.bulletclass));
}
}
on('init', () => {
if (swiper.params.pagination.enabled === false) {
// eslint-disable-next-line
disable();
} else {
init();
render();
update();
}
});
on('activeindexchange', () => {
if (swiper.params.loop) {
update();
} else if (typeof swiper.snapindex === 'undefined') {
update();
}
});
on('snapindexchange', () => {
if (!swiper.params.loop) {
update();
}
});
on('slideslengthchange', () => {
if (swiper.params.loop) {
render();
update();
}
});
on('snapgridlengthchange', () => {
if (!swiper.params.loop) {
render();
update();
}
});
on('destroy', () => {
destroy();
});
on('enable disable', () => {
const {
$el
} = swiper.pagination;
if ($el) {
$el[swiper.enabled ? 'removeclass' : 'addclass'](swiper.params.pagination.lockclass);
}
});
on('lock unlock', () => {
update();
});
on('click', (_s, e) => {
const targetel = e.target;
const {
$el
} = swiper.pagination;
if (swiper.params.pagination.el && swiper.params.pagination.hideonclick && $el && $el.length > 0 && !$(targetel).hasclass(swiper.params.pagination.bulletclass)) {
if (swiper.navigation && (swiper.navigation.nextel && targetel === swiper.navigation.nextel || swiper.navigation.prevel && targetel === swiper.navigation.prevel)) return;
const ishidden = $el.hasclass(swiper.params.pagination.hiddenclass);
if (ishidden === true) {
emit('paginationshow');
} else {
emit('paginationhide');
}
$el.toggleclass(swiper.params.pagination.hiddenclass);
}
});
const enable = () => {
swiper.$el.removeclass(swiper.params.pagination.paginationdisabledclass);
if (swiper.pagination.$el) {
swiper.pagination.$el.removeclass(swiper.params.pagination.paginationdisabledclass);
}
init();
render();
update();
};
const disable = () => {
swiper.$el.addclass(swiper.params.pagination.paginationdisabledclass);
if (swiper.pagination.$el) {
swiper.pagination.$el.addclass(swiper.params.pagination.paginationdisabledclass);
}
destroy();
};
object.assign(swiper.pagination, {
enable,
disable,
render,
update,
init,
destroy
});
}
function scrollbar(_ref) {
let {
swiper,
extendparams,
on,
emit
} = _ref;
const document = getdocument();
let istouched = false;
let timeout = null;
let dragtimeout = null;
let dragstartpos;
let dragsize;
let tracksize;
let divider;
extendparams({
scrollbar: {
el: null,
dragsize: 'auto',
hide: false,
draggable: false,
snaponrelease: true,
lockclass: 'swiper-scrollbar-lock',
dragclass: 'swiper-scrollbar-drag',
scrollbardisabledclass: 'swiper-scrollbar-disabled',
horizontalclass: `swiper-scrollbar-horizontal`,
verticalclass: `swiper-scrollbar-vertical`
}
});
swiper.scrollbar = {
el: null,
dragel: null,
$el: null,
$dragel: null
};
function settranslate() {
if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
const {
scrollbar,
rtltranslate: rtl,
progress
} = swiper;
const {
$dragel,
$el
} = scrollbar;
const params = swiper.params.scrollbar;
let newsize = dragsize;
let newpos = (tracksize - dragsize) * progress;
if (rtl) {
newpos = -newpos;
if (newpos > 0) {
newsize = dragsize - newpos;
newpos = 0;
} else if (-newpos + dragsize > tracksize) {
newsize = tracksize + newpos;
}
} else if (newpos < 0) {
newsize = dragsize + newpos;
newpos = 0;
} else if (newpos + dragsize > tracksize) {
newsize = tracksize - newpos;
}
if (swiper.ishorizontal()) {
$dragel.transform(`translate3d(${newpos}px, 0, 0)`);
$dragel[0].style.width = `${newsize}px`;
} else {
$dragel.transform(`translate3d(0px, ${newpos}px, 0)`);
$dragel[0].style.height = `${newsize}px`;
}
if (params.hide) {
cleartimeout(timeout);
$el[0].style.opacity = 1;
timeout = settimeout(() => {
$el[0].style.opacity = 0;
$el.transition(400);
}, 1000);
}
}
function settransition(duration) {
if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
swiper.scrollbar.$dragel.transition(duration);
}
function updatesize() {
if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
const {
scrollbar
} = swiper;
const {
$dragel,
$el
} = scrollbar;
$dragel[0].style.width = '';
$dragel[0].style.height = '';
tracksize = swiper.ishorizontal() ? $el[0].offsetwidth : $el[0].offsetheight;
divider = swiper.size / (swiper.virtualsize + swiper.params.slidesoffsetbefore - (swiper.params.centeredslides ? swiper.snapgrid[0] : 0));
if (swiper.params.scrollbar.dragsize === 'auto') {
dragsize = tracksize * divider;
} else {
dragsize = parseint(swiper.params.scrollbar.dragsize, 10);
}
if (swiper.ishorizontal()) {
$dragel[0].style.width = `${dragsize}px`;
} else {
$dragel[0].style.height = `${dragsize}px`;
}
if (divider >= 1) {
$el[0].style.display = 'none';
} else {
$el[0].style.display = '';
}
if (swiper.params.scrollbar.hide) {
$el[0].style.opacity = 0;
}
if (swiper.params.watchoverflow && swiper.enabled) {
scrollbar.$el[swiper.islocked ? 'addclass' : 'removeclass'](swiper.params.scrollbar.lockclass);
}
}
function getpointerposition(e) {
if (swiper.ishorizontal()) {
return e.type === 'touchstart' || e.type === 'touchmove' ? e.targettouches[0].clientx : e.clientx;
}
return e.type === 'touchstart' || e.type === 'touchmove' ? e.targettouches[0].clienty : e.clienty;
}
function setdragposition(e) {
const {
scrollbar,
rtltranslate: rtl
} = swiper;
const {
$el
} = scrollbar;
let positionratio;
positionratio = (getpointerposition(e) - $el.offset()[swiper.ishorizontal() ? 'left' : 'top'] - (dragstartpos !== null ? dragstartpos : dragsize / 2)) / (tracksize - dragsize);
positionratio = math.max(math.min(positionratio, 1), 0);
if (rtl) {
positionratio = 1 - positionratio;
}
const position = swiper.mintranslate() + (swiper.maxtranslate() - swiper.mintranslate()) * positionratio;
swiper.updateprogress(position);
swiper.settranslate(position);
swiper.updateactiveindex();
swiper.updateslidesclasses();
}
function ondragstart(e) {
const params = swiper.params.scrollbar;
const {
scrollbar,
$wrapperel
} = swiper;
const {
$el,
$dragel
} = scrollbar;
istouched = true;
dragstartpos = e.target === $dragel[0] || e.target === $dragel ? getpointerposition(e) - e.target.getboundingclientrect()[swiper.ishorizontal() ? 'left' : 'top'] : null;
e.preventdefault();
e.stoppropagation();
$wrapperel.transition(100);
$dragel.transition(100);
setdragposition(e);
cleartimeout(dragtimeout);
$el.transition(0);
if (params.hide) {
$el.css('opacity', 1);
}
if (swiper.params.cssmode) {
swiper.$wrapperel.css('scroll-snap-type', 'none');
}
emit('scrollbardragstart', e);
}
function ondragmove(e) {
const {
scrollbar,
$wrapperel
} = swiper;
const {
$el,
$dragel
} = scrollbar;
if (!istouched) return;
if (e.preventdefault) e.preventdefault();else e.returnvalue = false;
setdragposition(e);
$wrapperel.transition(0);
$el.transition(0);
$dragel.transition(0);
emit('scrollbardragmove', e);
}
function ondragend(e) {
const params = swiper.params.scrollbar;
const {
scrollbar,
$wrapperel
} = swiper;
const {
$el
} = scrollbar;
if (!istouched) return;
istouched = false;
if (swiper.params.cssmode) {
swiper.$wrapperel.css('scroll-snap-type', '');
$wrapperel.transition('');
}
if (params.hide) {
cleartimeout(dragtimeout);
dragtimeout = nexttick(() => {
$el.css('opacity', 0);
$el.transition(400);
}, 1000);
}
emit('scrollbardragend', e);
if (params.snaponrelease) {
swiper.slidetoclosest();
}
}
function events(method) {
const {
scrollbar,
toucheventstouch,
toucheventsdesktop,
params,
support
} = swiper;
const $el = scrollbar.$el;
if (!$el) return;
const target = $el[0];
const activelistener = support.passivelistener && params.passivelisteners ? {
passive: false,
capture: false
} : false;
const passivelistener = support.passivelistener && params.passivelisteners ? {
passive: true,
capture: false
} : false;
if (!target) return;
const eventmethod = method === 'on' ? 'addeventlistener' : 'removeeventlistener';
if (!support.touch) {
target[eventmethod](toucheventsdesktop.start, ondragstart, activelistener);
document[eventmethod](toucheventsdesktop.move, ondragmove, activelistener);
document[eventmethod](toucheventsdesktop.end, ondragend, passivelistener);
} else {
target[eventmethod](toucheventstouch.start, ondragstart, activelistener);
target[eventmethod](toucheventstouch.move, ondragmove, activelistener);
target[eventmethod](toucheventstouch.end, ondragend, passivelistener);
}
}
function enabledraggable() {
if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
events('on');
}
function disabledraggable() {
if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
events('off');
}
function init() {
const {
scrollbar,
$el: $swiperel
} = swiper;
swiper.params.scrollbar = createelementifnotdefined(swiper, swiper.originalparams.scrollbar, swiper.params.scrollbar, {
el: 'swiper-scrollbar'
});
const params = swiper.params.scrollbar;
if (!params.el) return;
let $el = $(params.el);
if (swiper.params.uniquenavelements && typeof params.el === 'string' && $el.length > 1 && $swiperel.find(params.el).length === 1) {
$el = $swiperel.find(params.el);
}
$el.addclass(swiper.ishorizontal() ? params.horizontalclass : params.verticalclass);
let $dragel = $el.find(`.${swiper.params.scrollbar.dragclass}`);
if ($dragel.length === 0) {
$dragel = $(``);
$el.append($dragel);
}
object.assign(scrollbar, {
$el,
el: $el[0],
$dragel,
dragel: $dragel[0]
});
if (params.draggable) {
enabledraggable();
}
if ($el) {
$el[swiper.enabled ? 'removeclass' : 'addclass'](swiper.params.scrollbar.lockclass);
}
}
function destroy() {
const params = swiper.params.scrollbar;
const $el = swiper.scrollbar.$el;
if ($el) {
$el.removeclass(swiper.ishorizontal() ? params.horizontalclass : params.verticalclass);
}
disabledraggable();
}
on('init', () => {
if (swiper.params.scrollbar.enabled === false) {
// eslint-disable-next-line
disable();
} else {
init();
updatesize();
settranslate();
}
});
on('update resize observerupdate lock unlock', () => {
updatesize();
});
on('settranslate', () => {
settranslate();
});
on('settransition', (_s, duration) => {
settransition(duration);
});
on('enable disable', () => {
const {
$el
} = swiper.scrollbar;
if ($el) {
$el[swiper.enabled ? 'removeclass' : 'addclass'](swiper.params.scrollbar.lockclass);
}
});
on('destroy', () => {
destroy();
});
const enable = () => {
swiper.$el.removeclass(swiper.params.scrollbar.scrollbardisabledclass);
if (swiper.scrollbar.$el) {
swiper.scrollbar.$el.removeclass(swiper.params.scrollbar.scrollbardisabledclass);
}
init();
updatesize();
settranslate();
};
const disable = () => {
swiper.$el.addclass(swiper.params.scrollbar.scrollbardisabledclass);
if (swiper.scrollbar.$el) {
swiper.scrollbar.$el.addclass(swiper.params.scrollbar.scrollbardisabledclass);
}
destroy();
};
object.assign(swiper.scrollbar, {
enable,
disable,
updatesize,
settranslate,
init,
destroy
});
}
function parallax(_ref) {
let {
swiper,
extendparams,
on
} = _ref;
extendparams({
parallax: {
enabled: false
}
});
const settransform = (el, progress) => {
const {
rtl
} = swiper;
const $el = $(el);
const rtlfactor = rtl ? -1 : 1;
const p = $el.attr('data-swiper-parallax') || '0';
let x = $el.attr('data-swiper-parallax-x');
let y = $el.attr('data-swiper-parallax-y');
const scale = $el.attr('data-swiper-parallax-scale');
const opacity = $el.attr('data-swiper-parallax-opacity');
if (x || y) {
x = x || '0';
y = y || '0';
} else if (swiper.ishorizontal()) {
x = p;
y = '0';
} else {
y = p;
x = '0';
}
if (x.indexof('%') >= 0) {
x = `${parseint(x, 10) * progress * rtlfactor}%`;
} else {
x = `${x * progress * rtlfactor}px`;
}
if (y.indexof('%') >= 0) {
y = `${parseint(y, 10) * progress}%`;
} else {
y = `${y * progress}px`;
}
if (typeof opacity !== 'undefined' && opacity !== null) {
const currentopacity = opacity - (opacity - 1) * (1 - math.abs(progress));
$el[0].style.opacity = currentopacity;
}
if (typeof scale === 'undefined' || scale === null) {
$el.transform(`translate3d(${x}, ${y}, 0px)`);
} else {
const currentscale = scale - (scale - 1) * (1 - math.abs(progress));
$el.transform(`translate3d(${x}, ${y}, 0px) scale(${currentscale})`);
}
};
const settranslate = () => {
const {
$el,
slides,
progress,
snapgrid
} = swiper;
$el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => {
settransform(el, progress);
});
slides.each((slideel, slideindex) => {
let slideprogress = slideel.progress;
if (swiper.params.slidespergroup > 1 && swiper.params.slidesperview !== 'auto') {
slideprogress += math.ceil(slideindex / 2) - progress * (snapgrid.length - 1);
}
slideprogress = math.min(math.max(slideprogress, -1), 1);
$(slideel).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => {
settransform(el, slideprogress);
});
});
};
const settransition = function (duration) {
if (duration === void 0) {
duration = swiper.params.speed;
}
const {
$el
} = swiper;
$el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(parallaxel => {
const $parallaxel = $(parallaxel);
let parallaxduration = parseint($parallaxel.attr('data-swiper-parallax-duration'), 10) || duration;
if (duration === 0) parallaxduration = 0;
$parallaxel.transition(parallaxduration);
});
};
on('beforeinit', () => {
if (!swiper.params.parallax.enabled) return;
swiper.params.watchslidesprogress = true;
swiper.originalparams.watchslidesprogress = true;
});
on('init', () => {
if (!swiper.params.parallax.enabled) return;
settranslate();
});
on('settranslate', () => {
if (!swiper.params.parallax.enabled) return;
settranslate();
});
on('settransition', (_swiper, duration) => {
if (!swiper.params.parallax.enabled) return;
settransition(duration);
});
}
function zoom(_ref) {
let {
swiper,
extendparams,
on,
emit
} = _ref;
const window = getwindow();
extendparams({
zoom: {
enabled: false,
maxratio: 3,
minratio: 1,
toggle: true,
containerclass: 'swiper-zoom-container',
zoomedslideclass: 'swiper-slide-zoomed'
}
});
swiper.zoom = {
enabled: false
};
let currentscale = 1;
let isscaling = false;
let gesturesenabled;
let fakegesturetouched;
let fakegesturemoved;
const gesture = {
$slideel: undefined,
slidewidth: undefined,
slideheight: undefined,
$imageel: undefined,
$imagewrapel: undefined,
maxratio: 3
};
const image = {
istouched: undefined,
ismoved: undefined,
currentx: undefined,
currenty: undefined,
minx: undefined,
miny: undefined,
maxx: undefined,
maxy: undefined,
width: undefined,
height: undefined,
startx: undefined,
starty: undefined,
touchesstart: {},
touchescurrent: {}
};
const velocity = {
x: undefined,
y: undefined,
prevpositionx: undefined,
prevpositiony: undefined,
prevtime: undefined
};
let scale = 1;
object.defineproperty(swiper.zoom, 'scale', {
get() {
return scale;
},
set(value) {
if (scale !== value) {
const imageel = gesture.$imageel ? gesture.$imageel[0] : undefined;
const slideel = gesture.$slideel ? gesture.$slideel[0] : undefined;
emit('zoomchange', value, imageel, slideel);
}
scale = value;
}
});
function getdistancebetweentouches(e) {
if (e.targettouches.length < 2) return 1;
const x1 = e.targettouches[0].pagex;
const y1 = e.targettouches[0].pagey;
const x2 = e.targettouches[1].pagex;
const y2 = e.targettouches[1].pagey;
const distance = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
return distance;
} // events
function ongesturestart(e) {
const support = swiper.support;
const params = swiper.params.zoom;
fakegesturetouched = false;
fakegesturemoved = false;
if (!support.gestures) {
if (e.type !== 'touchstart' || e.type === 'touchstart' && e.targettouches.length < 2) {
return;
}
fakegesturetouched = true;
gesture.scalestart = getdistancebetweentouches(e);
}
if (!gesture.$slideel || !gesture.$slideel.length) {
gesture.$slideel = $(e.target).closest(`.${swiper.params.slideclass}`);
if (gesture.$slideel.length === 0) gesture.$slideel = swiper.slides.eq(swiper.activeindex);
gesture.$imageel = gesture.$slideel.find(`.${params.containerclass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0);
gesture.$imagewrapel = gesture.$imageel.parent(`.${params.containerclass}`);
gesture.maxratio = gesture.$imagewrapel.attr('data-swiper-zoom') || params.maxratio;
if (gesture.$imagewrapel.length === 0) {
gesture.$imageel = undefined;
return;
}
}
if (gesture.$imageel) {
gesture.$imageel.transition(0);
}
isscaling = true;
}
function ongesturechange(e) {
const support = swiper.support;
const params = swiper.params.zoom;
const zoom = swiper.zoom;
if (!support.gestures) {
if (e.type !== 'touchmove' || e.type === 'touchmove' && e.targettouches.length < 2) {
return;
}
fakegesturemoved = true;
gesture.scalemove = getdistancebetweentouches(e);
}
if (!gesture.$imageel || gesture.$imageel.length === 0) {
if (e.type === 'gesturechange') ongesturestart(e);
return;
}
if (support.gestures) {
zoom.scale = e.scale * currentscale;
} else {
zoom.scale = gesture.scalemove / gesture.scalestart * currentscale;
}
if (zoom.scale > gesture.maxratio) {
zoom.scale = gesture.maxratio - 1 + (zoom.scale - gesture.maxratio + 1) ** 0.5;
}
if (zoom.scale < params.minratio) {
zoom.scale = params.minratio + 1 - (params.minratio - zoom.scale + 1) ** 0.5;
}
gesture.$imageel.transform(`translate3d(0,0,0) scale(${zoom.scale})`);
}
function ongestureend(e) {
const device = swiper.device;
const support = swiper.support;
const params = swiper.params.zoom;
const zoom = swiper.zoom;
if (!support.gestures) {
if (!fakegesturetouched || !fakegesturemoved) {
return;
}
if (e.type !== 'touchend' || e.type === 'touchend' && e.changedtouches.length < 2 && !device.android) {
return;
}
fakegesturetouched = false;
fakegesturemoved = false;
}
if (!gesture.$imageel || gesture.$imageel.length === 0) return;
zoom.scale = math.max(math.min(zoom.scale, gesture.maxratio), params.minratio);
gesture.$imageel.transition(swiper.params.speed).transform(`translate3d(0,0,0) scale(${zoom.scale})`);
currentscale = zoom.scale;
isscaling = false;
if (zoom.scale === 1) gesture.$slideel = undefined;
}
function ontouchstart(e) {
const device = swiper.device;
if (!gesture.$imageel || gesture.$imageel.length === 0) return;
if (image.istouched) return;
if (device.android && e.cancelable) e.preventdefault();
image.istouched = true;
image.touchesstart.x = e.type === 'touchstart' ? e.targettouches[0].pagex : e.pagex;
image.touchesstart.y = e.type === 'touchstart' ? e.targettouches[0].pagey : e.pagey;
}
function ontouchmove(e) {
const zoom = swiper.zoom;
if (!gesture.$imageel || gesture.$imageel.length === 0) return;
swiper.allowclick = false;
if (!image.istouched || !gesture.$slideel) return;
if (!image.ismoved) {
image.width = gesture.$imageel[0].offsetwidth;
image.height = gesture.$imageel[0].offsetheight;
image.startx = gettranslate(gesture.$imagewrapel[0], 'x') || 0;
image.starty = gettranslate(gesture.$imagewrapel[0], 'y') || 0;
gesture.slidewidth = gesture.$slideel[0].offsetwidth;
gesture.slideheight = gesture.$slideel[0].offsetheight;
gesture.$imagewrapel.transition(0);
} // define if we need image drag
const scaledwidth = image.width * zoom.scale;
const scaledheight = image.height * zoom.scale;
if (scaledwidth < gesture.slidewidth && scaledheight < gesture.slideheight) return;
image.minx = math.min(gesture.slidewidth / 2 - scaledwidth / 2, 0);
image.maxx = -image.minx;
image.miny = math.min(gesture.slideheight / 2 - scaledheight / 2, 0);
image.maxy = -image.miny;
image.touchescurrent.x = e.type === 'touchmove' ? e.targettouches[0].pagex : e.pagex;
image.touchescurrent.y = e.type === 'touchmove' ? e.targettouches[0].pagey : e.pagey;
if (!image.ismoved && !isscaling) {
if (swiper.ishorizontal() && (math.floor(image.minx) === math.floor(image.startx) && image.touchescurrent.x < image.touchesstart.x || math.floor(image.maxx) === math.floor(image.startx) && image.touchescurrent.x > image.touchesstart.x)) {
image.istouched = false;
return;
}
if (!swiper.ishorizontal() && (math.floor(image.miny) === math.floor(image.starty) && image.touchescurrent.y < image.touchesstart.y || math.floor(image.maxy) === math.floor(image.starty) && image.touchescurrent.y > image.touchesstart.y)) {
image.istouched = false;
return;
}
}
if (e.cancelable) {
e.preventdefault();
}
e.stoppropagation();
image.ismoved = true;
image.currentx = image.touchescurrent.x - image.touchesstart.x + image.startx;
image.currenty = image.touchescurrent.y - image.touchesstart.y + image.starty;
if (image.currentx < image.minx) {
image.currentx = image.minx + 1 - (image.minx - image.currentx + 1) ** 0.8;
}
if (image.currentx > image.maxx) {
image.currentx = image.maxx - 1 + (image.currentx - image.maxx + 1) ** 0.8;
}
if (image.currenty < image.miny) {
image.currenty = image.miny + 1 - (image.miny - image.currenty + 1) ** 0.8;
}
if (image.currenty > image.maxy) {
image.currenty = image.maxy - 1 + (image.currenty - image.maxy + 1) ** 0.8;
} // velocity
if (!velocity.prevpositionx) velocity.prevpositionx = image.touchescurrent.x;
if (!velocity.prevpositiony) velocity.prevpositiony = image.touchescurrent.y;
if (!velocity.prevtime) velocity.prevtime = date.now();
velocity.x = (image.touchescurrent.x - velocity.prevpositionx) / (date.now() - velocity.prevtime) / 2;
velocity.y = (image.touchescurrent.y - velocity.prevpositiony) / (date.now() - velocity.prevtime) / 2;
if (math.abs(image.touchescurrent.x - velocity.prevpositionx) < 2) velocity.x = 0;
if (math.abs(image.touchescurrent.y - velocity.prevpositiony) < 2) velocity.y = 0;
velocity.prevpositionx = image.touchescurrent.x;
velocity.prevpositiony = image.touchescurrent.y;
velocity.prevtime = date.now();
gesture.$imagewrapel.transform(`translate3d(${image.currentx}px, ${image.currenty}px,0)`);
}
function ontouchend() {
const zoom = swiper.zoom;
if (!gesture.$imageel || gesture.$imageel.length === 0) return;
if (!image.istouched || !image.ismoved) {
image.istouched = false;
image.ismoved = false;
return;
}
image.istouched = false;
image.ismoved = false;
let momentumdurationx = 300;
let momentumdurationy = 300;
const momentumdistancex = velocity.x * momentumdurationx;
const newpositionx = image.currentx + momentumdistancex;
const momentumdistancey = velocity.y * momentumdurationy;
const newpositiony = image.currenty + momentumdistancey; // fix duration
if (velocity.x !== 0) momentumdurationx = math.abs((newpositionx - image.currentx) / velocity.x);
if (velocity.y !== 0) momentumdurationy = math.abs((newpositiony - image.currenty) / velocity.y);
const momentumduration = math.max(momentumdurationx, momentumdurationy);
image.currentx = newpositionx;
image.currenty = newpositiony; // define if we need image drag
const scaledwidth = image.width * zoom.scale;
const scaledheight = image.height * zoom.scale;
image.minx = math.min(gesture.slidewidth / 2 - scaledwidth / 2, 0);
image.maxx = -image.minx;
image.miny = math.min(gesture.slideheight / 2 - scaledheight / 2, 0);
image.maxy = -image.miny;
image.currentx = math.max(math.min(image.currentx, image.maxx), image.minx);
image.currenty = math.max(math.min(image.currenty, image.maxy), image.miny);
gesture.$imagewrapel.transition(momentumduration).transform(`translate3d(${image.currentx}px, ${image.currenty}px,0)`);
}
function ontransitionend() {
const zoom = swiper.zoom;
if (gesture.$slideel && swiper.previousindex !== swiper.activeindex) {
if (gesture.$imageel) {
gesture.$imageel.transform('translate3d(0,0,0) scale(1)');
}
if (gesture.$imagewrapel) {
gesture.$imagewrapel.transform('translate3d(0,0,0)');
}
zoom.scale = 1;
currentscale = 1;
gesture.$slideel = undefined;
gesture.$imageel = undefined;
gesture.$imagewrapel = undefined;
}
}
function zoomin(e) {
const zoom = swiper.zoom;
const params = swiper.params.zoom;
if (!gesture.$slideel) {
if (e && e.target) {
gesture.$slideel = $(e.target).closest(`.${swiper.params.slideclass}`);
}
if (!gesture.$slideel) {
if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
gesture.$slideel = swiper.$wrapperel.children(`.${swiper.params.slideactiveclass}`);
} else {
gesture.$slideel = swiper.slides.eq(swiper.activeindex);
}
}
gesture.$imageel = gesture.$slideel.find(`.${params.containerclass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0);
gesture.$imagewrapel = gesture.$imageel.parent(`.${params.containerclass}`);
}
if (!gesture.$imageel || gesture.$imageel.length === 0 || !gesture.$imagewrapel || gesture.$imagewrapel.length === 0) return;
if (swiper.params.cssmode) {
swiper.wrapperel.style.overflow = 'hidden';
swiper.wrapperel.style.touchaction = 'none';
}
gesture.$slideel.addclass(`${params.zoomedslideclass}`);
let touchx;
let touchy;
let offsetx;
let offsety;
let diffx;
let diffy;
let translatex;
let translatey;
let imagewidth;
let imageheight;
let scaledwidth;
let scaledheight;
let translateminx;
let translateminy;
let translatemaxx;
let translatemaxy;
let slidewidth;
let slideheight;
if (typeof image.touchesstart.x === 'undefined' && e) {
touchx = e.type === 'touchend' ? e.changedtouches[0].pagex : e.pagex;
touchy = e.type === 'touchend' ? e.changedtouches[0].pagey : e.pagey;
} else {
touchx = image.touchesstart.x;
touchy = image.touchesstart.y;
}
zoom.scale = gesture.$imagewrapel.attr('data-swiper-zoom') || params.maxratio;
currentscale = gesture.$imagewrapel.attr('data-swiper-zoom') || params.maxratio;
if (e) {
slidewidth = gesture.$slideel[0].offsetwidth;
slideheight = gesture.$slideel[0].offsetheight;
offsetx = gesture.$slideel.offset().left + window.scrollx;
offsety = gesture.$slideel.offset().top + window.scrolly;
diffx = offsetx + slidewidth / 2 - touchx;
diffy = offsety + slideheight / 2 - touchy;
imagewidth = gesture.$imageel[0].offsetwidth;
imageheight = gesture.$imageel[0].offsetheight;
scaledwidth = imagewidth * zoom.scale;
scaledheight = imageheight * zoom.scale;
translateminx = math.min(slidewidth / 2 - scaledwidth / 2, 0);
translateminy = math.min(slideheight / 2 - scaledheight / 2, 0);
translatemaxx = -translateminx;
translatemaxy = -translateminy;
translatex = diffx * zoom.scale;
translatey = diffy * zoom.scale;
if (translatex < translateminx) {
translatex = translateminx;
}
if (translatex > translatemaxx) {
translatex = translatemaxx;
}
if (translatey < translateminy) {
translatey = translateminy;
}
if (translatey > translatemaxy) {
translatey = translatemaxy;
}
} else {
translatex = 0;
translatey = 0;
}
gesture.$imagewrapel.transition(300).transform(`translate3d(${translatex}px, ${translatey}px,0)`);
gesture.$imageel.transition(300).transform(`translate3d(0,0,0) scale(${zoom.scale})`);
}
function zoomout() {
const zoom = swiper.zoom;
const params = swiper.params.zoom;
if (!gesture.$slideel) {
if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
gesture.$slideel = swiper.$wrapperel.children(`.${swiper.params.slideactiveclass}`);
} else {
gesture.$slideel = swiper.slides.eq(swiper.activeindex);
}
gesture.$imageel = gesture.$slideel.find(`.${params.containerclass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0);
gesture.$imagewrapel = gesture.$imageel.parent(`.${params.containerclass}`);
}
if (!gesture.$imageel || gesture.$imageel.length === 0 || !gesture.$imagewrapel || gesture.$imagewrapel.length === 0) return;
if (swiper.params.cssmode) {
swiper.wrapperel.style.overflow = '';
swiper.wrapperel.style.touchaction = '';
}
zoom.scale = 1;
currentscale = 1;
gesture.$imagewrapel.transition(300).transform('translate3d(0,0,0)');
gesture.$imageel.transition(300).transform('translate3d(0,0,0) scale(1)');
gesture.$slideel.removeclass(`${params.zoomedslideclass}`);
gesture.$slideel = undefined;
} // toggle zoom
function zoomtoggle(e) {
const zoom = swiper.zoom;
if (zoom.scale && zoom.scale !== 1) {
// zoom out
zoomout();
} else {
// zoom in
zoomin(e);
}
}
function getlisteners() {
const support = swiper.support;
const passivelistener = swiper.touchevents.start === 'touchstart' && support.passivelistener && swiper.params.passivelisteners ? {
passive: true,
capture: false
} : false;
const activelistenerwithcapture = support.passivelistener ? {
passive: false,
capture: true
} : true;
return {
passivelistener,
activelistenerwithcapture
};
}
function getslideselector() {
return `.${swiper.params.slideclass}`;
}
function togglegestures(method) {
const {
passivelistener
} = getlisteners();
const slideselector = getslideselector();
swiper.$wrapperel[method]('gesturestart', slideselector, ongesturestart, passivelistener);
swiper.$wrapperel[method]('gesturechange', slideselector, ongesturechange, passivelistener);
swiper.$wrapperel[method]('gestureend', slideselector, ongestureend, passivelistener);
}
function enablegestures() {
if (gesturesenabled) return;
gesturesenabled = true;
togglegestures('on');
}
function disablegestures() {
if (!gesturesenabled) return;
gesturesenabled = false;
togglegestures('off');
} // attach/detach events
function enable() {
const zoom = swiper.zoom;
if (zoom.enabled) return;
zoom.enabled = true;
const support = swiper.support;
const {
passivelistener,
activelistenerwithcapture
} = getlisteners();
const slideselector = getslideselector(); // scale image
if (support.gestures) {
swiper.$wrapperel.on(swiper.touchevents.start, enablegestures, passivelistener);
swiper.$wrapperel.on(swiper.touchevents.end, disablegestures, passivelistener);
} else if (swiper.touchevents.start === 'touchstart') {
swiper.$wrapperel.on(swiper.touchevents.start, slideselector, ongesturestart, passivelistener);
swiper.$wrapperel.on(swiper.touchevents.move, slideselector, ongesturechange, activelistenerwithcapture);
swiper.$wrapperel.on(swiper.touchevents.end, slideselector, ongestureend, passivelistener);
if (swiper.touchevents.cancel) {
swiper.$wrapperel.on(swiper.touchevents.cancel, slideselector, ongestureend, passivelistener);
}
} // move image
swiper.$wrapperel.on(swiper.touchevents.move, `.${swiper.params.zoom.containerclass}`, ontouchmove, activelistenerwithcapture);
}
function disable() {
const zoom = swiper.zoom;
if (!zoom.enabled) return;
const support = swiper.support;
zoom.enabled = false;
const {
passivelistener,
activelistenerwithcapture
} = getlisteners();
const slideselector = getslideselector(); // scale image
if (support.gestures) {
swiper.$wrapperel.off(swiper.touchevents.start, enablegestures, passivelistener);
swiper.$wrapperel.off(swiper.touchevents.end, disablegestures, passivelistener);
} else if (swiper.touchevents.start === 'touchstart') {
swiper.$wrapperel.off(swiper.touchevents.start, slideselector, ongesturestart, passivelistener);
swiper.$wrapperel.off(swiper.touchevents.move, slideselector, ongesturechange, activelistenerwithcapture);
swiper.$wrapperel.off(swiper.touchevents.end, slideselector, ongestureend, passivelistener);
if (swiper.touchevents.cancel) {
swiper.$wrapperel.off(swiper.touchevents.cancel, slideselector, ongestureend, passivelistener);
}
} // move image
swiper.$wrapperel.off(swiper.touchevents.move, `.${swiper.params.zoom.containerclass}`, ontouchmove, activelistenerwithcapture);
}
on('init', () => {
if (swiper.params.zoom.enabled) {
enable();
}
});
on('destroy', () => {
disable();
});
on('touchstart', (_s, e) => {
if (!swiper.zoom.enabled) return;
ontouchstart(e);
});
on('touchend', (_s, e) => {
if (!swiper.zoom.enabled) return;
ontouchend();
});
on('doubletap', (_s, e) => {
if (!swiper.animating && swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) {
zoomtoggle(e);
}
});
on('transitionend', () => {
if (swiper.zoom.enabled && swiper.params.zoom.enabled) {
ontransitionend();
}
});
on('slidechange', () => {
if (swiper.zoom.enabled && swiper.params.zoom.enabled && swiper.params.cssmode) {
ontransitionend();
}
});
object.assign(swiper.zoom, {
enable,
disable,
in: zoomin,
out: zoomout,
toggle: zoomtoggle
});
}
function lazy(_ref) {
let {
swiper,
extendparams,
on,
emit
} = _ref;
extendparams({
lazy: {
checkinview: false,
enabled: false,
loadprevnext: false,
loadprevnextamount: 1,
loadontransitionstart: false,
scrollingelement: '',
elementclass: 'swiper-lazy',
loadingclass: 'swiper-lazy-loading',
loadedclass: 'swiper-lazy-loaded',
preloaderclass: 'swiper-lazy-preloader'
}
});
swiper.lazy = {};
let scrollhandlerattached = false;
let initialimageloaded = false;
function loadinslide(index, loadinduplicate) {
if (loadinduplicate === void 0) {
loadinduplicate = true;
}
const params = swiper.params.lazy;
if (typeof index === 'undefined') return;
if (swiper.slides.length === 0) return;
const isvirtual = swiper.virtual && swiper.params.virtual.enabled;
const $slideel = isvirtual ? swiper.$wrapperel.children(`.${swiper.params.slideclass}[data-swiper-slide-index="${index}"]`) : swiper.slides.eq(index);
const $images = $slideel.find(`.${params.elementclass}:not(.${params.loadedclass}):not(.${params.loadingclass})`);
if ($slideel.hasclass(params.elementclass) && !$slideel.hasclass(params.loadedclass) && !$slideel.hasclass(params.loadingclass)) {
$images.push($slideel[0]);
}
if ($images.length === 0) return;
$images.each(imageel => {
const $imageel = $(imageel);
$imageel.addclass(params.loadingclass);
const background = $imageel.attr('data-background');
const src = $imageel.attr('data-src');
const srcset = $imageel.attr('data-srcset');
const sizes = $imageel.attr('data-sizes');
const $pictureel = $imageel.parent('picture');
swiper.loadimage($imageel[0], src || background, srcset, sizes, false, () => {
if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper && !swiper.params || swiper.destroyed) return;
if (background) {
$imageel.css('background-image', `url("${background}")`);
$imageel.removeattr('data-background');
} else {
if (srcset) {
$imageel.attr('srcset', srcset);
$imageel.removeattr('data-srcset');
}
if (sizes) {
$imageel.attr('sizes', sizes);
$imageel.removeattr('data-sizes');
}
if ($pictureel.length) {
$pictureel.children('source').each(sourceel => {
const $source = $(sourceel);
if ($source.attr('data-srcset')) {
$source.attr('srcset', $source.attr('data-srcset'));
$source.removeattr('data-srcset');
}
});
}
if (src) {
$imageel.attr('src', src);
$imageel.removeattr('data-src');
}
}
$imageel.addclass(params.loadedclass).removeclass(params.loadingclass);
$slideel.find(`.${params.preloaderclass}`).remove();
if (swiper.params.loop && loadinduplicate) {
const slideoriginalindex = $slideel.attr('data-swiper-slide-index');
if ($slideel.hasclass(swiper.params.slideduplicateclass)) {
const originalslide = swiper.$wrapperel.children(`[data-swiper-slide-index="${slideoriginalindex}"]:not(.${swiper.params.slideduplicateclass})`);
loadinslide(originalslide.index(), false);
} else {
const duplicatedslide = swiper.$wrapperel.children(`.${swiper.params.slideduplicateclass}[data-swiper-slide-index="${slideoriginalindex}"]`);
loadinslide(duplicatedslide.index(), false);
}
}
emit('lazyimageready', $slideel[0], $imageel[0]);
if (swiper.params.autoheight) {
swiper.updateautoheight();
}
});
emit('lazyimageload', $slideel[0], $imageel[0]);
});
}
function load() {
const {
$wrapperel,
params: swiperparams,
slides,
activeindex
} = swiper;
const isvirtual = swiper.virtual && swiperparams.virtual.enabled;
const params = swiperparams.lazy;
let slidesperview = swiperparams.slidesperview;
if (slidesperview === 'auto') {
slidesperview = 0;
}
function slideexist(index) {
if (isvirtual) {
if ($wrapperel.children(`.${swiperparams.slideclass}[data-swiper-slide-index="${index}"]`).length) {
return true;
}
} else if (slides[index]) return true;
return false;
}
function slideindex(slideel) {
if (isvirtual) {
return $(slideel).attr('data-swiper-slide-index');
}
return $(slideel).index();
}
if (!initialimageloaded) initialimageloaded = true;
if (swiper.params.watchslidesprogress) {
$wrapperel.children(`.${swiperparams.slidevisibleclass}`).each(slideel => {
const index = isvirtual ? $(slideel).attr('data-swiper-slide-index') : $(slideel).index();
loadinslide(index);
});
} else if (slidesperview > 1) {
for (let i = activeindex; i < activeindex + slidesperview; i += 1) {
if (slideexist(i)) loadinslide(i);
}
} else {
loadinslide(activeindex);
}
if (params.loadprevnext) {
if (slidesperview > 1 || params.loadprevnextamount && params.loadprevnextamount > 1) {
const amount = params.loadprevnextamount;
const spv = math.ceil(slidesperview);
const maxindex = math.min(activeindex + spv + math.max(amount, spv), slides.length);
const minindex = math.max(activeindex - math.max(spv, amount), 0); // next slides
for (let i = activeindex + spv; i < maxindex; i += 1) {
if (slideexist(i)) loadinslide(i);
} // prev slides
for (let i = minindex; i < activeindex; i += 1) {
if (slideexist(i)) loadinslide(i);
}
} else {
const nextslide = $wrapperel.children(`.${swiperparams.slidenextclass}`);
if (nextslide.length > 0) loadinslide(slideindex(nextslide));
const prevslide = $wrapperel.children(`.${swiperparams.slideprevclass}`);
if (prevslide.length > 0) loadinslide(slideindex(prevslide));
}
}
}
function checkinviewonload() {
const window = getwindow();
if (!swiper || swiper.destroyed) return;
const $scrollelement = swiper.params.lazy.scrollingelement ? $(swiper.params.lazy.scrollingelement) : $(window);
const iswindow = $scrollelement[0] === window;
const scrollelementwidth = iswindow ? window.innerwidth : $scrollelement[0].offsetwidth;
const scrollelementheight = iswindow ? window.innerheight : $scrollelement[0].offsetheight;
const swiperoffset = swiper.$el.offset();
const {
rtltranslate: rtl
} = swiper;
let inview = false;
if (rtl) swiperoffset.left -= swiper.$el[0].scrollleft;
const swipercoord = [[swiperoffset.left, swiperoffset.top], [swiperoffset.left + swiper.width, swiperoffset.top], [swiperoffset.left, swiperoffset.top + swiper.height], [swiperoffset.left + swiper.width, swiperoffset.top + swiper.height]];
for (let i = 0; i < swipercoord.length; i += 1) {
const point = swipercoord[i];
if (point[0] >= 0 && point[0] <= scrollelementwidth && point[1] >= 0 && point[1] <= scrollelementheight) {
if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line
inview = true;
}
}
const passivelistener = swiper.touchevents.start === 'touchstart' && swiper.support.passivelistener && swiper.params.passivelisteners ? {
passive: true,
capture: false
} : false;
if (inview) {
load();
$scrollelement.off('scroll', checkinviewonload, passivelistener);
} else if (!scrollhandlerattached) {
scrollhandlerattached = true;
$scrollelement.on('scroll', checkinviewonload, passivelistener);
}
}
on('beforeinit', () => {
if (swiper.params.lazy.enabled && swiper.params.preloadimages) {
swiper.params.preloadimages = false;
}
});
on('init', () => {
if (swiper.params.lazy.enabled) {
if (swiper.params.lazy.checkinview) {
checkinviewonload();
} else {
load();
}
}
});
on('scroll', () => {
if (swiper.params.freemode && swiper.params.freemode.enabled && !swiper.params.freemode.sticky) {
load();
}
});
on('scrollbardragmove resize _freemodenomomentumrelease', () => {
if (swiper.params.lazy.enabled) {
if (swiper.params.lazy.checkinview) {
checkinviewonload();
} else {
load();
}
}
});
on('transitionstart', () => {
if (swiper.params.lazy.enabled) {
if (swiper.params.lazy.loadontransitionstart || !swiper.params.lazy.loadontransitionstart && !initialimageloaded) {
if (swiper.params.lazy.checkinview) {
checkinviewonload();
} else {
load();
}
}
}
});
on('transitionend', () => {
if (swiper.params.lazy.enabled && !swiper.params.lazy.loadontransitionstart) {
if (swiper.params.lazy.checkinview) {
checkinviewonload();
} else {
load();
}
}
});
on('slidechange', () => {
const {
lazy,
cssmode,
watchslidesprogress,
touchreleaseonedges,
resistanceratio
} = swiper.params;
if (lazy.enabled && (cssmode || watchslidesprogress && (touchreleaseonedges || resistanceratio === 0))) {
load();
}
});
on('destroy', () => {
if (!swiper.$el) return;
swiper.$el.find(`.${swiper.params.lazy.loadingclass}`).removeclass(swiper.params.lazy.loadingclass);
});
object.assign(swiper.lazy, {
load,
loadinslide
});
}
/* eslint no-bitwise: ["error", { "allow": [">>"] }] */
function controller(_ref) {
let {
swiper,
extendparams,
on
} = _ref;
extendparams({
controller: {
control: undefined,
inverse: false,
by: 'slide' // or 'container'
}
});
swiper.controller = {
control: undefined
};
function linearspline(x, y) {
const binarysearch = function search() {
let maxindex;
let minindex;
let guess;
return (array, val) => {
minindex = -1;
maxindex = array.length;
while (maxindex - minindex > 1) {
guess = maxindex + minindex >> 1;
if (array[guess] <= val) {
minindex = guess;
} else {
maxindex = guess;
}
}
return maxindex;
};
}();
this.x = x;
this.y = y;
this.lastindex = x.length - 1; // given an x value (x2), return the expected y2 value:
// (x1,y1) is the known point before given value,
// (x3,y3) is the known point after given value.
let i1;
let i3;
this.interpolate = function interpolate(x2) {
if (!x2) return 0; // get the indexes of x1 and x3 (the array indexes before and after given x2):
i3 = binarysearch(this.x, x2);
i1 = i3 - 1; // we have our indexes i1 & i3, so we can calculate already:
// y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1
return (x2 - this.x[i1]) * (this.y[i3] - this.y[i1]) / (this.x[i3] - this.x[i1]) + this.y[i1];
};
return this;
} // xxx: for now i will just save one spline function to to
function getinterpolatefunction(c) {
if (!swiper.controller.spline) {
swiper.controller.spline = swiper.params.loop ? new linearspline(swiper.slidesgrid, c.slidesgrid) : new linearspline(swiper.snapgrid, c.snapgrid);
}
}
function settranslate(_t, bycontroller) {
const controlled = swiper.controller.control;
let multiplier;
let controlledtranslate;
const swiper = swiper.constructor;
function setcontrolledtranslate(c) {
// this will create an interpolate function based on the snapgrids
// x is the grid of the scrolled scroller and y will be the controlled scroller
// it makes sense to create this only once and recall it for the interpolation
// the function does a lot of value caching for performance
const translate = swiper.rtltranslate ? -swiper.translate : swiper.translate;
if (swiper.params.controller.by === 'slide') {
getinterpolatefunction(c); // i am not sure why the values have to be multiplicated this way, tried to invert the snapgrid
// but it did not work out
controlledtranslate = -swiper.controller.spline.interpolate(-translate);
}
if (!controlledtranslate || swiper.params.controller.by === 'container') {
multiplier = (c.maxtranslate() - c.mintranslate()) / (swiper.maxtranslate() - swiper.mintranslate());
controlledtranslate = (translate - swiper.mintranslate()) * multiplier + c.mintranslate();
}
if (swiper.params.controller.inverse) {
controlledtranslate = c.maxtranslate() - controlledtranslate;
}
c.updateprogress(controlledtranslate);
c.settranslate(controlledtranslate, swiper);
c.updateactiveindex();
c.updateslidesclasses();
}
if (array.isarray(controlled)) {
for (let i = 0; i < controlled.length; i += 1) {
if (controlled[i] !== bycontroller && controlled[i] instanceof swiper) {
setcontrolledtranslate(controlled[i]);
}
}
} else if (controlled instanceof swiper && bycontroller !== controlled) {
setcontrolledtranslate(controlled);
}
}
function settransition(duration, bycontroller) {
const swiper = swiper.constructor;
const controlled = swiper.controller.control;
let i;
function setcontrolledtransition(c) {
c.settransition(duration, swiper);
if (duration !== 0) {
c.transitionstart();
if (c.params.autoheight) {
nexttick(() => {
c.updateautoheight();
});
}
c.$wrapperel.transitionend(() => {
if (!controlled) return;
if (c.params.loop && swiper.params.controller.by === 'slide') {
c.loopfix();
}
c.transitionend();
});
}
}
if (array.isarray(controlled)) {
for (i = 0; i < controlled.length; i += 1) {
if (controlled[i] !== bycontroller && controlled[i] instanceof swiper) {
setcontrolledtransition(controlled[i]);
}
}
} else if (controlled instanceof swiper && bycontroller !== controlled) {
setcontrolledtransition(controlled);
}
}
function removespline() {
if (!swiper.controller.control) return;
if (swiper.controller.spline) {
swiper.controller.spline = undefined;
delete swiper.controller.spline;
}
}
on('beforeinit', () => {
swiper.controller.control = swiper.params.controller.control;
});
on('update', () => {
removespline();
});
on('resize', () => {
removespline();
});
on('observerupdate', () => {
removespline();
});
on('settranslate', (_s, translate, bycontroller) => {
if (!swiper.controller.control) return;
swiper.controller.settranslate(translate, bycontroller);
});
on('settransition', (_s, duration, bycontroller) => {
if (!swiper.controller.control) return;
swiper.controller.settransition(duration, bycontroller);
});
object.assign(swiper.controller, {
settranslate,
settransition
});
}
function a11y(_ref) {
let {
swiper,
extendparams,
on
} = _ref;
extendparams({
a11y: {
enabled: true,
notificationclass: 'swiper-notification',
prevslidemessage: 'previous slide',
nextslidemessage: 'next slide',
firstslidemessage: 'this is the first slide',
lastslidemessage: 'this is the last slide',
paginationbulletmessage: 'go to slide {{index}}',
slidelabelmessage: '{{index}} / {{slideslength}}',
containermessage: null,
containerroledescriptionmessage: null,
itemroledescriptionmessage: null,
sliderole: 'group',
id: null
}
});
let liveregion = null;
function notify(message) {
const notification = liveregion;
if (notification.length === 0) return;
notification.html('');
notification.html(message);
}
function getrandomnumber(size) {
if (size === void 0) {
size = 16;
}
const randomchar = () => math.round(16 * math.random()).tostring(16);
return 'x'.repeat(size).replace(/x/g, randomchar);
}
function makeelfocusable($el) {
$el.attr('tabindex', '0');
}
function makeelnotfocusable($el) {
$el.attr('tabindex', '-1');
}
function addelrole($el, role) {
$el.attr('role', role);
}
function addelroledescription($el, description) {
$el.attr('aria-roledescription', description);
}
function addelcontrols($el, controls) {
$el.attr('aria-controls', controls);
}
function addellabel($el, label) {
$el.attr('aria-label', label);
}
function addelid($el, id) {
$el.attr('id', id);
}
function addellive($el, live) {
$el.attr('aria-live', live);
}
function disableel($el) {
$el.attr('aria-disabled', true);
}
function enableel($el) {
$el.attr('aria-disabled', false);
}
function onenterorspacekey(e) {
if (e.keycode !== 13 && e.keycode !== 32) return;
const params = swiper.params.a11y;
const $targetel = $(e.target);
if (swiper.navigation && swiper.navigation.$nextel && $targetel.is(swiper.navigation.$nextel)) {
if (!(swiper.isend && !swiper.params.loop)) {
swiper.slidenext();
}
if (swiper.isend) {
notify(params.lastslidemessage);
} else {
notify(params.nextslidemessage);
}
}
if (swiper.navigation && swiper.navigation.$prevel && $targetel.is(swiper.navigation.$prevel)) {
if (!(swiper.isbeginning && !swiper.params.loop)) {
swiper.slideprev();
}
if (swiper.isbeginning) {
notify(params.firstslidemessage);
} else {
notify(params.prevslidemessage);
}
}
if (swiper.pagination && $targetel.is(classestoselector(swiper.params.pagination.bulletclass))) {
$targetel[0].click();
}
}
function updatenavigation() {
if (swiper.params.loop || swiper.params.rewind || !swiper.navigation) return;
const {
$nextel,
$prevel
} = swiper.navigation;
if ($prevel && $prevel.length > 0) {
if (swiper.isbeginning) {
disableel($prevel);
makeelnotfocusable($prevel);
} else {
enableel($prevel);
makeelfocusable($prevel);
}
}
if ($nextel && $nextel.length > 0) {
if (swiper.isend) {
disableel($nextel);
makeelnotfocusable($nextel);
} else {
enableel($nextel);
makeelfocusable($nextel);
}
}
}
function haspagination() {
return swiper.pagination && swiper.pagination.bullets && swiper.pagination.bullets.length;
}
function hasclickablepagination() {
return haspagination() && swiper.params.pagination.clickable;
}
function updatepagination() {
const params = swiper.params.a11y;
if (!haspagination()) return;
swiper.pagination.bullets.each(bulletel => {
const $bulletel = $(bulletel);
if (swiper.params.pagination.clickable) {
makeelfocusable($bulletel);
if (!swiper.params.pagination.renderbullet) {
addelrole($bulletel, 'button');
addellabel($bulletel, params.paginationbulletmessage.replace(/\{\{index\}\}/, $bulletel.index() + 1));
}
}
if ($bulletel.is(`.${swiper.params.pagination.bulletactiveclass}`)) {
$bulletel.attr('aria-current', 'true');
} else {
$bulletel.removeattr('aria-current');
}
});
}
const initnavel = ($el, wrapperid, message) => {
makeelfocusable($el);
if ($el[0].tagname !== 'button') {
addelrole($el, 'button');
$el.on('keydown', onenterorspacekey);
}
addellabel($el, message);
addelcontrols($el, wrapperid);
};
const handlefocus = e => {
const slideel = e.target.closest(`.${swiper.params.slideclass}`);
if (!slideel || !swiper.slides.includes(slideel)) return;
const isactive = swiper.slides.indexof(slideel) === swiper.activeindex;
const isvisible = swiper.params.watchslidesprogress && swiper.visibleslides && swiper.visibleslides.includes(slideel);
if (isactive || isvisible) return;
swiper.slideto(swiper.slides.indexof(slideel), 0);
};
const initslides = () => {
const params = swiper.params.a11y;
if (params.itemroledescriptionmessage) {
addelroledescription($(swiper.slides), params.itemroledescriptionmessage);
}
if (params.sliderole) {
addelrole($(swiper.slides), params.sliderole);
}
const slideslength = swiper.params.loop ? swiper.slides.filter(el => !el.classlist.contains(swiper.params.slideduplicateclass)).length : swiper.slides.length;
if (params.slidelabelmessage) {
swiper.slides.each((slideel, index) => {
const $slideel = $(slideel);
const slideindex = swiper.params.loop ? parseint($slideel.attr('data-swiper-slide-index'), 10) : index;
const arialabelmessage = params.slidelabelmessage.replace(/\{\{index\}\}/, slideindex + 1).replace(/\{\{slideslength\}\}/, slideslength);
addellabel($slideel, arialabelmessage);
});
}
};
const init = () => {
const params = swiper.params.a11y;
swiper.$el.append(liveregion); // container
const $containerel = swiper.$el;
if (params.containerroledescriptionmessage) {
addelroledescription($containerel, params.containerroledescriptionmessage);
}
if (params.containermessage) {
addellabel($containerel, params.containermessage);
} // wrapper
const $wrapperel = swiper.$wrapperel;
const wrapperid = params.id || $wrapperel.attr('id') || `swiper-wrapper-${getrandomnumber(16)}`;
const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? 'off' : 'polite';
addelid($wrapperel, wrapperid);
addellive($wrapperel, live); // slide
initslides(); // navigation
let $nextel;
let $prevel;
if (swiper.navigation && swiper.navigation.$nextel) {
$nextel = swiper.navigation.$nextel;
}
if (swiper.navigation && swiper.navigation.$prevel) {
$prevel = swiper.navigation.$prevel;
}
if ($nextel && $nextel.length) {
initnavel($nextel, wrapperid, params.nextslidemessage);
}
if ($prevel && $prevel.length) {
initnavel($prevel, wrapperid, params.prevslidemessage);
} // pagination
if (hasclickablepagination()) {
swiper.pagination.$el.on('keydown', classestoselector(swiper.params.pagination.bulletclass), onenterorspacekey);
} // tab focus
swiper.$el.on('focus', handlefocus, true);
};
function destroy() {
if (liveregion && liveregion.length > 0) liveregion.remove();
let $nextel;
let $prevel;
if (swiper.navigation && swiper.navigation.$nextel) {
$nextel = swiper.navigation.$nextel;
}
if (swiper.navigation && swiper.navigation.$prevel) {
$prevel = swiper.navigation.$prevel;
}
if ($nextel) {
$nextel.off('keydown', onenterorspacekey);
}
if ($prevel) {
$prevel.off('keydown', onenterorspacekey);
} // pagination
if (hasclickablepagination()) {
swiper.pagination.$el.off('keydown', classestoselector(swiper.params.pagination.bulletclass), onenterorspacekey);
} // tab focus
swiper.$el.off('focus', handlefocus, true);
}
on('beforeinit', () => {
liveregion = $(``);
});
on('afterinit', () => {
if (!swiper.params.a11y.enabled) return;
init();
});
on('slideslengthchange snapgridlengthchange slidesgridlengthchange', () => {
if (!swiper.params.a11y.enabled) return;
initslides();
});
on('fromedge toedge afterinit lock unlock', () => {
if (!swiper.params.a11y.enabled) return;
updatenavigation();
});
on('paginationupdate', () => {
if (!swiper.params.a11y.enabled) return;
updatepagination();
});
on('destroy', () => {
if (!swiper.params.a11y.enabled) return;
destroy();
});
}
function history(_ref) {
let {
swiper,
extendparams,
on
} = _ref;
extendparams({
history: {
enabled: false,
root: '',
replacestate: false,
key: 'slides',
keepquery: false
}
});
let initialized = false;
let paths = {};
const slugify = text => {
return text.tostring().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
};
const getpathvalues = urloverride => {
const window = getwindow();
let location;
if (urloverride) {
location = new url(urloverride);
} else {
location = window.location;
}
const patharray = location.pathname.slice(1).split('/').filter(part => part !== '');
const total = patharray.length;
const key = patharray[total - 2];
const value = patharray[total - 1];
return {
key,
value
};
};
const sethistory = (key, index) => {
const window = getwindow();
if (!initialized || !swiper.params.history.enabled) return;
let location;
if (swiper.params.url) {
location = new url(swiper.params.url);
} else {
location = window.location;
}
const slide = swiper.slides.eq(index);
let value = slugify(slide.attr('data-history'));
if (swiper.params.history.root.length > 0) {
let root = swiper.params.history.root;
if (root[root.length - 1] === '/') root = root.slice(0, root.length - 1);
value = `${root}/${key}/${value}`;
} else if (!location.pathname.includes(key)) {
value = `${key}/${value}`;
}
if (swiper.params.history.keepquery) {
value += location.search;
}
const currentstate = window.history.state;
if (currentstate && currentstate.value === value) {
return;
}
if (swiper.params.history.replacestate) {
window.history.replacestate({
value
}, null, value);
} else {
window.history.pushstate({
value
}, null, value);
}
};
const scrolltoslide = (speed, value, runcallbacks) => {
if (value) {
for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
const slide = swiper.slides.eq(i);
const slidehistory = slugify(slide.attr('data-history'));
if (slidehistory === value && !slide.hasclass(swiper.params.slideduplicateclass)) {
const index = slide.index();
swiper.slideto(index, speed, runcallbacks);
}
}
} else {
swiper.slideto(0, speed, runcallbacks);
}
};
const sethistorypopstate = () => {
paths = getpathvalues(swiper.params.url);
scrolltoslide(swiper.params.speed, paths.value, false);
};
const init = () => {
const window = getwindow();
if (!swiper.params.history) return;
if (!window.history || !window.history.pushstate) {
swiper.params.history.enabled = false;
swiper.params.hashnavigation.enabled = true;
return;
}
initialized = true;
paths = getpathvalues(swiper.params.url);
if (!paths.key && !paths.value) return;
scrolltoslide(0, paths.value, swiper.params.runcallbacksoninit);
if (!swiper.params.history.replacestate) {
window.addeventlistener('popstate', sethistorypopstate);
}
};
const destroy = () => {
const window = getwindow();
if (!swiper.params.history.replacestate) {
window.removeeventlistener('popstate', sethistorypopstate);
}
};
on('init', () => {
if (swiper.params.history.enabled) {
init();
}
});
on('destroy', () => {
if (swiper.params.history.enabled) {
destroy();
}
});
on('transitionend _freemodenomomentumrelease', () => {
if (initialized) {
sethistory(swiper.params.history.key, swiper.activeindex);
}
});
on('slidechange', () => {
if (initialized && swiper.params.cssmode) {
sethistory(swiper.params.history.key, swiper.activeindex);
}
});
}
function hashnavigation(_ref) {
let {
swiper,
extendparams,
emit,
on
} = _ref;
let initialized = false;
const document = getdocument();
const window = getwindow();
extendparams({
hashnavigation: {
enabled: false,
replacestate: false,
watchstate: false
}
});
const onhashchange = () => {
emit('hashchange');
const newhash = document.location.hash.replace('#', '');
const activeslidehash = swiper.slides.eq(swiper.activeindex).attr('data-hash');
if (newhash !== activeslidehash) {
const newindex = swiper.$wrapperel.children(`.${swiper.params.slideclass}[data-hash="${newhash}"]`).index();
if (typeof newindex === 'undefined') return;
swiper.slideto(newindex);
}
};
const sethash = () => {
if (!initialized || !swiper.params.hashnavigation.enabled) return;
if (swiper.params.hashnavigation.replacestate && window.history && window.history.replacestate) {
window.history.replacestate(null, null, `#${swiper.slides.eq(swiper.activeindex).attr('data-hash')}` || '');
emit('hashset');
} else {
const slide = swiper.slides.eq(swiper.activeindex);
const hash = slide.attr('data-hash') || slide.attr('data-history');
document.location.hash = hash || '';
emit('hashset');
}
};
const init = () => {
if (!swiper.params.hashnavigation.enabled || swiper.params.history && swiper.params.history.enabled) return;
initialized = true;
const hash = document.location.hash.replace('#', '');
if (hash) {
const speed = 0;
for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
const slide = swiper.slides.eq(i);
const slidehash = slide.attr('data-hash') || slide.attr('data-history');
if (slidehash === hash && !slide.hasclass(swiper.params.slideduplicateclass)) {
const index = slide.index();
swiper.slideto(index, speed, swiper.params.runcallbacksoninit, true);
}
}
}
if (swiper.params.hashnavigation.watchstate) {
$(window).on('hashchange', onhashchange);
}
};
const destroy = () => {
if (swiper.params.hashnavigation.watchstate) {
$(window).off('hashchange', onhashchange);
}
};
on('init', () => {
if (swiper.params.hashnavigation.enabled) {
init();
}
});
on('destroy', () => {
if (swiper.params.hashnavigation.enabled) {
destroy();
}
});
on('transitionend _freemodenomomentumrelease', () => {
if (initialized) {
sethash();
}
});
on('slidechange', () => {
if (initialized && swiper.params.cssmode) {
sethash();
}
});
}
/* eslint no-underscore-dangle: "off" */
function autoplay(_ref) {
let {
swiper,
extendparams,
on,
emit
} = _ref;
let timeout;
swiper.autoplay = {
running: false,
paused: false
};
extendparams({
autoplay: {
enabled: false,
delay: 3000,
waitfortransition: true,
disableoninteraction: true,
stoponlastslide: false,
reversedirection: false,
pauseonmouseenter: false
}
});
function run() {
const $activeslideel = swiper.slides.eq(swiper.activeindex);
let delay = swiper.params.autoplay.delay;
if ($activeslideel.attr('data-swiper-autoplay')) {
delay = $activeslideel.attr('data-swiper-autoplay') || swiper.params.autoplay.delay;
}
cleartimeout(timeout);
timeout = nexttick(() => {
let autoplayresult;
if (swiper.params.autoplay.reversedirection) {
if (swiper.params.loop) {
swiper.loopfix();
autoplayresult = swiper.slideprev(swiper.params.speed, true, true);
emit('autoplay');
} else if (!swiper.isbeginning) {
autoplayresult = swiper.slideprev(swiper.params.speed, true, true);
emit('autoplay');
} else if (!swiper.params.autoplay.stoponlastslide) {
autoplayresult = swiper.slideto(swiper.slides.length - 1, swiper.params.speed, true, true);
emit('autoplay');
} else {
stop();
}
} else if (swiper.params.loop) {
swiper.loopfix();
autoplayresult = swiper.slidenext(swiper.params.speed, true, true);
emit('autoplay');
} else if (!swiper.isend) {
autoplayresult = swiper.slidenext(swiper.params.speed, true, true);
emit('autoplay');
} else if (!swiper.params.autoplay.stoponlastslide) {
autoplayresult = swiper.slideto(0, swiper.params.speed, true, true);
emit('autoplay');
} else {
stop();
}
if (swiper.params.cssmode && swiper.autoplay.running) run();else if (autoplayresult === false) {
run();
}
}, delay);
}
function start() {
if (typeof timeout !== 'undefined') return false;
if (swiper.autoplay.running) return false;
swiper.autoplay.running = true;
emit('autoplaystart');
run();
return true;
}
function stop() {
if (!swiper.autoplay.running) return false;
if (typeof timeout === 'undefined') return false;
if (timeout) {
cleartimeout(timeout);
timeout = undefined;
}
swiper.autoplay.running = false;
emit('autoplaystop');
return true;
}
function pause(speed) {
if (!swiper.autoplay.running) return;
if (swiper.autoplay.paused) return;
if (timeout) cleartimeout(timeout);
swiper.autoplay.paused = true;
if (speed === 0 || !swiper.params.autoplay.waitfortransition) {
swiper.autoplay.paused = false;
run();
} else {
['transitionend', 'webkittransitionend'].foreach(event => {
swiper.$wrapperel[0].addeventlistener(event, ontransitionend);
});
}
}
function onvisibilitychange() {
const document = getdocument();
if (document.visibilitystate === 'hidden' && swiper.autoplay.running) {
pause();
}
if (document.visibilitystate === 'visible' && swiper.autoplay.paused) {
run();
swiper.autoplay.paused = false;
}
}
function ontransitionend(e) {
if (!swiper || swiper.destroyed || !swiper.$wrapperel) return;
if (e.target !== swiper.$wrapperel[0]) return;
['transitionend', 'webkittransitionend'].foreach(event => {
swiper.$wrapperel[0].removeeventlistener(event, ontransitionend);
});
swiper.autoplay.paused = false;
if (!swiper.autoplay.running) {
stop();
} else {
run();
}
}
function onmouseenter() {
if (swiper.params.autoplay.disableoninteraction) {
stop();
} else {
emit('autoplaypause');
pause();
}
['transitionend', 'webkittransitionend'].foreach(event => {
swiper.$wrapperel[0].removeeventlistener(event, ontransitionend);
});
}
function onmouseleave() {
if (swiper.params.autoplay.disableoninteraction) {
return;
}
swiper.autoplay.paused = false;
emit('autoplayresume');
run();
}
function attachmouseevents() {
if (swiper.params.autoplay.pauseonmouseenter) {
swiper.$el.on('mouseenter', onmouseenter);
swiper.$el.on('mouseleave', onmouseleave);
}
}
function detachmouseevents() {
swiper.$el.off('mouseenter', onmouseenter);
swiper.$el.off('mouseleave', onmouseleave);
}
on('init', () => {
if (swiper.params.autoplay.enabled) {
start();
const document = getdocument();
document.addeventlistener('visibilitychange', onvisibilitychange);
attachmouseevents();
}
});
on('beforetransitionstart', (_s, speed, internal) => {
if (swiper.autoplay.running) {
if (internal || !swiper.params.autoplay.disableoninteraction) {
swiper.autoplay.pause(speed);
} else {
stop();
}
}
});
on('sliderfirstmove', () => {
if (swiper.autoplay.running) {
if (swiper.params.autoplay.disableoninteraction) {
stop();
} else {
pause();
}
}
});
on('touchend', () => {
if (swiper.params.cssmode && swiper.autoplay.paused && !swiper.params.autoplay.disableoninteraction) {
run();
}
});
on('destroy', () => {
detachmouseevents();
if (swiper.autoplay.running) {
stop();
}
const document = getdocument();
document.removeeventlistener('visibilitychange', onvisibilitychange);
});
object.assign(swiper.autoplay, {
pause,
run,
start,
stop
});
}
function thumb(_ref) {
let {
swiper,
extendparams,
on
} = _ref;
extendparams({
thumbs: {
swiper: null,
multipleactivethumbs: true,
autoscrolloffset: 0,
slidethumbactiveclass: 'swiper-slide-thumb-active',
thumbscontainerclass: 'swiper-thumbs'
}
});
let initialized = false;
let swipercreated = false;
swiper.thumbs = {
swiper: null
};
function onthumbclick() {
const thumbsswiper = swiper.thumbs.swiper;
if (!thumbsswiper || thumbsswiper.destroyed) return;
const clickedindex = thumbsswiper.clickedindex;
const clickedslide = thumbsswiper.clickedslide;
if (clickedslide && $(clickedslide).hasclass(swiper.params.thumbs.slidethumbactiveclass)) return;
if (typeof clickedindex === 'undefined' || clickedindex === null) return;
let slidetoindex;
if (thumbsswiper.params.loop) {
slidetoindex = parseint($(thumbsswiper.clickedslide).attr('data-swiper-slide-index'), 10);
} else {
slidetoindex = clickedindex;
}
if (swiper.params.loop) {
let currentindex = swiper.activeindex;
if (swiper.slides.eq(currentindex).hasclass(swiper.params.slideduplicateclass)) {
swiper.loopfix(); // eslint-disable-next-line
swiper._clientleft = swiper.$wrapperel[0].clientleft;
currentindex = swiper.activeindex;
}
const previndex = swiper.slides.eq(currentindex).prevall(`[data-swiper-slide-index="${slidetoindex}"]`).eq(0).index();
const nextindex = swiper.slides.eq(currentindex).nextall(`[data-swiper-slide-index="${slidetoindex}"]`).eq(0).index();
if (typeof previndex === 'undefined') slidetoindex = nextindex;else if (typeof nextindex === 'undefined') slidetoindex = previndex;else if (nextindex - currentindex < currentindex - previndex) slidetoindex = nextindex;else slidetoindex = previndex;
}
swiper.slideto(slidetoindex);
}
function init() {
const {
thumbs: thumbsparams
} = swiper.params;
if (initialized) return false;
initialized = true;
const swiperclass = swiper.constructor;
if (thumbsparams.swiper instanceof swiperclass) {
swiper.thumbs.swiper = thumbsparams.swiper;
object.assign(swiper.thumbs.swiper.originalparams, {
watchslidesprogress: true,
slidetoclickedslide: false
});
object.assign(swiper.thumbs.swiper.params, {
watchslidesprogress: true,
slidetoclickedslide: false
});
} else if (isobject(thumbsparams.swiper)) {
const thumbsswiperparams = object.assign({}, thumbsparams.swiper);
object.assign(thumbsswiperparams, {
watchslidesprogress: true,
slidetoclickedslide: false
});
swiper.thumbs.swiper = new swiperclass(thumbsswiperparams);
swipercreated = true;
}
swiper.thumbs.swiper.$el.addclass(swiper.params.thumbs.thumbscontainerclass);
swiper.thumbs.swiper.on('tap', onthumbclick);
return true;
}
function update(initial) {
const thumbsswiper = swiper.thumbs.swiper;
if (!thumbsswiper || thumbsswiper.destroyed) return;
const slidesperview = thumbsswiper.params.slidesperview === 'auto' ? thumbsswiper.slidesperviewdynamic() : thumbsswiper.params.slidesperview; // activate thumbs
let thumbstoactivate = 1;
const thumbactiveclass = swiper.params.thumbs.slidethumbactiveclass;
if (swiper.params.slidesperview > 1 && !swiper.params.centeredslides) {
thumbstoactivate = swiper.params.slidesperview;
}
if (!swiper.params.thumbs.multipleactivethumbs) {
thumbstoactivate = 1;
}
thumbstoactivate = math.floor(thumbstoactivate);
thumbsswiper.slides.removeclass(thumbactiveclass);
if (thumbsswiper.params.loop || thumbsswiper.params.virtual && thumbsswiper.params.virtual.enabled) {
for (let i = 0; i < thumbstoactivate; i += 1) {
thumbsswiper.$wrapperel.children(`[data-swiper-slide-index="${swiper.realindex + i}"]`).addclass(thumbactiveclass);
}
} else {
for (let i = 0; i < thumbstoactivate; i += 1) {
thumbsswiper.slides.eq(swiper.realindex + i).addclass(thumbactiveclass);
}
}
const autoscrolloffset = swiper.params.thumbs.autoscrolloffset;
const useoffset = autoscrolloffset && !thumbsswiper.params.loop;
if (swiper.realindex !== thumbsswiper.realindex || useoffset) {
let currentthumbsindex = thumbsswiper.activeindex;
let newthumbsindex;
let direction;
if (thumbsswiper.params.loop) {
if (thumbsswiper.slides.eq(currentthumbsindex).hasclass(thumbsswiper.params.slideduplicateclass)) {
thumbsswiper.loopfix(); // eslint-disable-next-line
thumbsswiper._clientleft = thumbsswiper.$wrapperel[0].clientleft;
currentthumbsindex = thumbsswiper.activeindex;
} // find actual thumbs index to slide to
const prevthumbsindex = thumbsswiper.slides.eq(currentthumbsindex).prevall(`[data-swiper-slide-index="${swiper.realindex}"]`).eq(0).index();
const nextthumbsindex = thumbsswiper.slides.eq(currentthumbsindex).nextall(`[data-swiper-slide-index="${swiper.realindex}"]`).eq(0).index();
if (typeof prevthumbsindex === 'undefined') {
newthumbsindex = nextthumbsindex;
} else if (typeof nextthumbsindex === 'undefined') {
newthumbsindex = prevthumbsindex;
} else if (nextthumbsindex - currentthumbsindex === currentthumbsindex - prevthumbsindex) {
newthumbsindex = thumbsswiper.params.slidespergroup > 1 ? nextthumbsindex : currentthumbsindex;
} else if (nextthumbsindex - currentthumbsindex < currentthumbsindex - prevthumbsindex) {
newthumbsindex = nextthumbsindex;
} else {
newthumbsindex = prevthumbsindex;
}
direction = swiper.activeindex > swiper.previousindex ? 'next' : 'prev';
} else {
newthumbsindex = swiper.realindex;
direction = newthumbsindex > swiper.previousindex ? 'next' : 'prev';
}
if (useoffset) {
newthumbsindex += direction === 'next' ? autoscrolloffset : -1 * autoscrolloffset;
}
if (thumbsswiper.visibleslidesindexes && thumbsswiper.visibleslidesindexes.indexof(newthumbsindex) < 0) {
if (thumbsswiper.params.centeredslides) {
if (newthumbsindex > currentthumbsindex) {
newthumbsindex = newthumbsindex - math.floor(slidesperview / 2) + 1;
} else {
newthumbsindex = newthumbsindex + math.floor(slidesperview / 2) - 1;
}
} else if (newthumbsindex > currentthumbsindex && thumbsswiper.params.slidespergroup === 1) ;
thumbsswiper.slideto(newthumbsindex, initial ? 0 : undefined);
}
}
}
on('beforeinit', () => {
const {
thumbs
} = swiper.params;
if (!thumbs || !thumbs.swiper) return;
init();
update(true);
});
on('slidechange update resize observerupdate', () => {
update();
});
on('settransition', (_s, duration) => {
const thumbsswiper = swiper.thumbs.swiper;
if (!thumbsswiper || thumbsswiper.destroyed) return;
thumbsswiper.settransition(duration);
});
on('beforedestroy', () => {
const thumbsswiper = swiper.thumbs.swiper;
if (!thumbsswiper || thumbsswiper.destroyed) return;
if (swipercreated) {
thumbsswiper.destroy();
}
});
object.assign(swiper.thumbs, {
init,
update
});
}
function freemode(_ref) {
let {
swiper,
extendparams,
emit,
once
} = _ref;
extendparams({
freemode: {
enabled: false,
momentum: true,
momentumratio: 1,
momentumbounce: true,
momentumbounceratio: 1,
momentumvelocityratio: 1,
sticky: false,
minimumvelocity: 0.02
}
});
function ontouchstart() {
const translate = swiper.gettranslate();
swiper.settranslate(translate);
swiper.settransition(0);
swiper.toucheventsdata.velocities.length = 0;
swiper.freemode.ontouchend({
currentpos: swiper.rtl ? swiper.translate : -swiper.translate
});
}
function ontouchmove() {
const {
toucheventsdata: data,
touches
} = swiper; // velocity
if (data.velocities.length === 0) {
data.velocities.push({
position: touches[swiper.ishorizontal() ? 'startx' : 'starty'],
time: data.touchstarttime
});
}
data.velocities.push({
position: touches[swiper.ishorizontal() ? 'currentx' : 'currenty'],
time: now()
});
}
function ontouchend(_ref2) {
let {
currentpos
} = _ref2;
const {
params,
$wrapperel,
rtltranslate: rtl,
snapgrid,
toucheventsdata: data
} = swiper; // time diff
const touchendtime = now();
const timediff = touchendtime - data.touchstarttime;
if (currentpos < -swiper.mintranslate()) {
swiper.slideto(swiper.activeindex);
return;
}
if (currentpos > -swiper.maxtranslate()) {
if (swiper.slides.length < snapgrid.length) {
swiper.slideto(snapgrid.length - 1);
} else {
swiper.slideto(swiper.slides.length - 1);
}
return;
}
if (params.freemode.momentum) {
if (data.velocities.length > 1) {
const lastmoveevent = data.velocities.pop();
const velocityevent = data.velocities.pop();
const distance = lastmoveevent.position - velocityevent.position;
const time = lastmoveevent.time - velocityevent.time;
swiper.velocity = distance / time;
swiper.velocity /= 2;
if (math.abs(swiper.velocity) < params.freemode.minimumvelocity) {
swiper.velocity = 0;
} // this implies that the user stopped moving a finger then released.
// there would be no events with distance zero, so the last event is stale.
if (time > 150 || now() - lastmoveevent.time > 300) {
swiper.velocity = 0;
}
} else {
swiper.velocity = 0;
}
swiper.velocity *= params.freemode.momentumvelocityratio;
data.velocities.length = 0;
let momentumduration = 1000 * params.freemode.momentumratio;
const momentumdistance = swiper.velocity * momentumduration;
let newposition = swiper.translate + momentumdistance;
if (rtl) newposition = -newposition;
let dobounce = false;
let afterbounceposition;
const bounceamount = math.abs(swiper.velocity) * 20 * params.freemode.momentumbounceratio;
let needsloopfix;
if (newposition < swiper.maxtranslate()) {
if (params.freemode.momentumbounce) {
if (newposition + swiper.maxtranslate() < -bounceamount) {
newposition = swiper.maxtranslate() - bounceamount;
}
afterbounceposition = swiper.maxtranslate();
dobounce = true;
data.allowmomentumbounce = true;
} else {
newposition = swiper.maxtranslate();
}
if (params.loop && params.centeredslides) needsloopfix = true;
} else if (newposition > swiper.mintranslate()) {
if (params.freemode.momentumbounce) {
if (newposition - swiper.mintranslate() > bounceamount) {
newposition = swiper.mintranslate() + bounceamount;
}
afterbounceposition = swiper.mintranslate();
dobounce = true;
data.allowmomentumbounce = true;
} else {
newposition = swiper.mintranslate();
}
if (params.loop && params.centeredslides) needsloopfix = true;
} else if (params.freemode.sticky) {
let nextslide;
for (let j = 0; j < snapgrid.length; j += 1) {
if (snapgrid[j] > -newposition) {
nextslide = j;
break;
}
}
if (math.abs(snapgrid[nextslide] - newposition) < math.abs(snapgrid[nextslide - 1] - newposition) || swiper.swipedirection === 'next') {
newposition = snapgrid[nextslide];
} else {
newposition = snapgrid[nextslide - 1];
}
newposition = -newposition;
}
if (needsloopfix) {
once('transitionend', () => {
swiper.loopfix();
});
} // fix duration
if (swiper.velocity !== 0) {
if (rtl) {
momentumduration = math.abs((-newposition - swiper.translate) / swiper.velocity);
} else {
momentumduration = math.abs((newposition - swiper.translate) / swiper.velocity);
}
if (params.freemode.sticky) {
// if freemode.sticky is active and the user ends a swipe with a slow-velocity
// event, then durations can be 20+ seconds to slide one (or zero!) slides.
// it's easy to see this when simulating touch with mouse events. to fix this,
// limit single-slide swipes to the default slide duration. this also has the
// nice side effect of matching slide speed if the user stopped moving before
// lifting finger or mouse vs. moving slowly before lifting the finger/mouse.
// for faster swipes, also apply limits (albeit higher ones).
const movedistance = math.abs((rtl ? -newposition : newposition) - swiper.translate);
const currentslidesize = swiper.slidessizesgrid[swiper.activeindex];
if (movedistance < currentslidesize) {
momentumduration = params.speed;
} else if (movedistance < 2 * currentslidesize) {
momentumduration = params.speed * 1.5;
} else {
momentumduration = params.speed * 2.5;
}
}
} else if (params.freemode.sticky) {
swiper.slidetoclosest();
return;
}
if (params.freemode.momentumbounce && dobounce) {
swiper.updateprogress(afterbounceposition);
swiper.settransition(momentumduration);
swiper.settranslate(newposition);
swiper.transitionstart(true, swiper.swipedirection);
swiper.animating = true;
$wrapperel.transitionend(() => {
if (!swiper || swiper.destroyed || !data.allowmomentumbounce) return;
emit('momentumbounce');
swiper.settransition(params.speed);
settimeout(() => {
swiper.settranslate(afterbounceposition);
$wrapperel.transitionend(() => {
if (!swiper || swiper.destroyed) return;
swiper.transitionend();
});
}, 0);
});
} else if (swiper.velocity) {
emit('_freemodenomomentumrelease');
swiper.updateprogress(newposition);
swiper.settransition(momentumduration);
swiper.settranslate(newposition);
swiper.transitionstart(true, swiper.swipedirection);
if (!swiper.animating) {
swiper.animating = true;
$wrapperel.transitionend(() => {
if (!swiper || swiper.destroyed) return;
swiper.transitionend();
});
}
} else {
swiper.updateprogress(newposition);
}
swiper.updateactiveindex();
swiper.updateslidesclasses();
} else if (params.freemode.sticky) {
swiper.slidetoclosest();
return;
} else if (params.freemode) {
emit('_freemodenomomentumrelease');
}
if (!params.freemode.momentum || timediff >= params.longswipesms) {
swiper.updateprogress();
swiper.updateactiveindex();
swiper.updateslidesclasses();
}
}
object.assign(swiper, {
freemode: {
ontouchstart,
ontouchmove,
ontouchend
}
});
}
function grid(_ref) {
let {
swiper,
extendparams
} = _ref;
extendparams({
grid: {
rows: 1,
fill: 'column'
}
});
let slidesnumbereventorows;
let slidesperrow;
let numfullcolumns;
const initslides = slideslength => {
const {
slidesperview
} = swiper.params;
const {
rows,
fill
} = swiper.params.grid;
slidesperrow = slidesnumbereventorows / rows;
numfullcolumns = math.floor(slideslength / rows);
if (math.floor(slideslength / rows) === slideslength / rows) {
slidesnumbereventorows = slideslength;
} else {
slidesnumbereventorows = math.ceil(slideslength / rows) * rows;
}
if (slidesperview !== 'auto' && fill === 'row') {
slidesnumbereventorows = math.max(slidesnumbereventorows, slidesperview * rows);
}
};
const updateslide = (i, slide, slideslength, getdirectionlabel) => {
const {
slidespergroup,
spacebetween
} = swiper.params;
const {
rows,
fill
} = swiper.params.grid; // set slides order
let newslideorderindex;
let column;
let row;
if (fill === 'row' && slidespergroup > 1) {
const groupindex = math.floor(i / (slidespergroup * rows));
const slideindexingroup = i - rows * slidespergroup * groupindex;
const columnsingroup = groupindex === 0 ? slidespergroup : math.min(math.ceil((slideslength - groupindex * rows * slidespergroup) / rows), slidespergroup);
row = math.floor(slideindexingroup / columnsingroup);
column = slideindexingroup - row * columnsingroup + groupindex * slidespergroup;
newslideorderindex = column + row * slidesnumbereventorows / rows;
slide.css({
'-webkit-order': newslideorderindex,
order: newslideorderindex
});
} else if (fill === 'column') {
column = math.floor(i / rows);
row = i - column * rows;
if (column > numfullcolumns || column === numfullcolumns && row === rows - 1) {
row += 1;
if (row >= rows) {
row = 0;
column += 1;
}
}
} else {
row = math.floor(i / slidesperrow);
column = i - row * slidesperrow;
}
slide.css(getdirectionlabel('margin-top'), row !== 0 ? spacebetween && `${spacebetween}px` : '');
};
const updatewrappersize = (slidesize, snapgrid, getdirectionlabel) => {
const {
spacebetween,
centeredslides,
roundlengths
} = swiper.params;
const {
rows
} = swiper.params.grid;
swiper.virtualsize = (slidesize + spacebetween) * slidesnumbereventorows;
swiper.virtualsize = math.ceil(swiper.virtualsize / rows) - spacebetween;
swiper.$wrapperel.css({
[getdirectionlabel('width')]: `${swiper.virtualsize + spacebetween}px`
});
if (centeredslides) {
snapgrid.splice(0, snapgrid.length);
const newslidesgrid = [];
for (let i = 0; i < snapgrid.length; i += 1) {
let slidesgriditem = snapgrid[i];
if (roundlengths) slidesgriditem = math.floor(slidesgriditem);
if (snapgrid[i] < swiper.virtualsize + snapgrid[0]) newslidesgrid.push(slidesgriditem);
}
snapgrid.push(...newslidesgrid);
}
};
swiper.grid = {
initslides,
updateslide,
updatewrappersize
};
}
function appendslide(slides) {
const swiper = this;
const {
$wrapperel,
params
} = swiper;
if (params.loop) {
swiper.loopdestroy();
}
if (typeof slides === 'object' && 'length' in slides) {
for (let i = 0; i < slides.length; i += 1) {
if (slides[i]) $wrapperel.append(slides[i]);
}
} else {
$wrapperel.append(slides);
}
if (params.loop) {
swiper.loopcreate();
}
if (!params.observer) {
swiper.update();
}
}
function prependslide(slides) {
const swiper = this;
const {
params,
$wrapperel,
activeindex
} = swiper;
if (params.loop) {
swiper.loopdestroy();
}
let newactiveindex = activeindex + 1;
if (typeof slides === 'object' && 'length' in slides) {
for (let i = 0; i < slides.length; i += 1) {
if (slides[i]) $wrapperel.prepend(slides[i]);
}
newactiveindex = activeindex + slides.length;
} else {
$wrapperel.prepend(slides);
}
if (params.loop) {
swiper.loopcreate();
}
if (!params.observer) {
swiper.update();
}
swiper.slideto(newactiveindex, 0, false);
}
function addslide(index, slides) {
const swiper = this;
const {
$wrapperel,
params,
activeindex
} = swiper;
let activeindexbuffer = activeindex;
if (params.loop) {
activeindexbuffer -= swiper.loopedslides;
swiper.loopdestroy();
swiper.slides = $wrapperel.children(`.${params.slideclass}`);
}
const baselength = swiper.slides.length;
if (index <= 0) {
swiper.prependslide(slides);
return;
}
if (index >= baselength) {
swiper.appendslide(slides);
return;
}
let newactiveindex = activeindexbuffer > index ? activeindexbuffer + 1 : activeindexbuffer;
const slidesbuffer = [];
for (let i = baselength - 1; i >= index; i -= 1) {
const currentslide = swiper.slides.eq(i);
currentslide.remove();
slidesbuffer.unshift(currentslide);
}
if (typeof slides === 'object' && 'length' in slides) {
for (let i = 0; i < slides.length; i += 1) {
if (slides[i]) $wrapperel.append(slides[i]);
}
newactiveindex = activeindexbuffer > index ? activeindexbuffer + slides.length : activeindexbuffer;
} else {
$wrapperel.append(slides);
}
for (let i = 0; i < slidesbuffer.length; i += 1) {
$wrapperel.append(slidesbuffer[i]);
}
if (params.loop) {
swiper.loopcreate();
}
if (!params.observer) {
swiper.update();
}
if (params.loop) {
swiper.slideto(newactiveindex + swiper.loopedslides, 0, false);
} else {
swiper.slideto(newactiveindex, 0, false);
}
}
function removeslide(slidesindexes) {
const swiper = this;
const {
params,
$wrapperel,
activeindex
} = swiper;
let activeindexbuffer = activeindex;
if (params.loop) {
activeindexbuffer -= swiper.loopedslides;
swiper.loopdestroy();
swiper.slides = $wrapperel.children(`.${params.slideclass}`);
}
let newactiveindex = activeindexbuffer;
let indextoremove;
if (typeof slidesindexes === 'object' && 'length' in slidesindexes) {
for (let i = 0; i < slidesindexes.length; i += 1) {
indextoremove = slidesindexes[i];
if (swiper.slides[indextoremove]) swiper.slides.eq(indextoremove).remove();
if (indextoremove < newactiveindex) newactiveindex -= 1;
}
newactiveindex = math.max(newactiveindex, 0);
} else {
indextoremove = slidesindexes;
if (swiper.slides[indextoremove]) swiper.slides.eq(indextoremove).remove();
if (indextoremove < newactiveindex) newactiveindex -= 1;
newactiveindex = math.max(newactiveindex, 0);
}
if (params.loop) {
swiper.loopcreate();
}
if (!params.observer) {
swiper.update();
}
if (params.loop) {
swiper.slideto(newactiveindex + swiper.loopedslides, 0, false);
} else {
swiper.slideto(newactiveindex, 0, false);
}
}
function removeallslides() {
const swiper = this;
const slidesindexes = [];
for (let i = 0; i < swiper.slides.length; i += 1) {
slidesindexes.push(i);
}
swiper.removeslide(slidesindexes);
}
function manipulation(_ref) {
let {
swiper
} = _ref;
object.assign(swiper, {
appendslide: appendslide.bind(swiper),
prependslide: prependslide.bind(swiper),
addslide: addslide.bind(swiper),
removeslide: removeslide.bind(swiper),
removeallslides: removeallslides.bind(swiper)
});
}
function effectinit(params) {
const {
effect,
swiper,
on,
settranslate,
settransition,
overwriteparams,
perspective,
recreateshadows,
geteffectparams
} = params;
on('beforeinit', () => {
if (swiper.params.effect !== effect) return;
swiper.classnames.push(`${swiper.params.containermodifierclass}${effect}`);
if (perspective && perspective()) {
swiper.classnames.push(`${swiper.params.containermodifierclass}3d`);
}
const overwriteparamsresult = overwriteparams ? overwriteparams() : {};
object.assign(swiper.params, overwriteparamsresult);
object.assign(swiper.originalparams, overwriteparamsresult);
});
on('settranslate', () => {
if (swiper.params.effect !== effect) return;
settranslate();
});
on('settransition', (_s, duration) => {
if (swiper.params.effect !== effect) return;
settransition(duration);
});
on('transitionend', () => {
if (swiper.params.effect !== effect) return;
if (recreateshadows) {
if (!geteffectparams || !geteffectparams().slideshadows) return; // remove shadows
swiper.slides.each(slideel => {
const $slideel = swiper.$(slideel);
$slideel.find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').remove();
}); // create new one
recreateshadows();
}
});
let requireupdateonvirtual;
on('virtualupdate', () => {
if (swiper.params.effect !== effect) return;
if (!swiper.slides.length) {
requireupdateonvirtual = true;
}
requestanimationframe(() => {
if (requireupdateonvirtual && swiper.slides && swiper.slides.length) {
settranslate();
requireupdateonvirtual = false;
}
});
});
}
function effecttarget(effectparams, $slideel) {
if (effectparams.transformel) {
return $slideel.find(effectparams.transformel).css({
'backface-visibility': 'hidden',
'-webkit-backface-visibility': 'hidden'
});
}
return $slideel;
}
function effectvirtualtransitionend(_ref) {
let {
swiper,
duration,
transformel,
allslides
} = _ref;
const {
slides,
activeindex,
$wrapperel
} = swiper;
if (swiper.params.virtualtranslate && duration !== 0) {
let eventtriggered = false;
let $transitionendtarget;
if (allslides) {
$transitionendtarget = transformel ? slides.find(transformel) : slides;
} else {
$transitionendtarget = transformel ? slides.eq(activeindex).find(transformel) : slides.eq(activeindex);
}
$transitionendtarget.transitionend(() => {
if (eventtriggered) return;
if (!swiper || swiper.destroyed) return;
eventtriggered = true;
swiper.animating = false;
const triggerevents = ['webkittransitionend', 'transitionend'];
for (let i = 0; i < triggerevents.length; i += 1) {
$wrapperel.trigger(triggerevents[i]);
}
});
}
}
function effectfade(_ref) {
let {
swiper,
extendparams,
on
} = _ref;
extendparams({
fadeeffect: {
crossfade: false,
transformel: null
}
});
const settranslate = () => {
const {
slides
} = swiper;
const params = swiper.params.fadeeffect;
for (let i = 0; i < slides.length; i += 1) {
const $slideel = swiper.slides.eq(i);
const offset = $slideel[0].swiperslideoffset;
let tx = -offset;
if (!swiper.params.virtualtranslate) tx -= swiper.translate;
let ty = 0;
if (!swiper.ishorizontal()) {
ty = tx;
tx = 0;
}
const slideopacity = swiper.params.fadeeffect.crossfade ? math.max(1 - math.abs($slideel[0].progress), 0) : 1 + math.min(math.max($slideel[0].progress, -1), 0);
const $targetel = effecttarget(params, $slideel);
$targetel.css({
opacity: slideopacity
}).transform(`translate3d(${tx}px, ${ty}px, 0px)`);
}
};
const settransition = duration => {
const {
transformel
} = swiper.params.fadeeffect;
const $transitionelements = transformel ? swiper.slides.find(transformel) : swiper.slides;
$transitionelements.transition(duration);
effectvirtualtransitionend({
swiper,
duration,
transformel,
allslides: true
});
};
effectinit({
effect: 'fade',
swiper,
on,
settranslate,
settransition,
overwriteparams: () => ({
slidesperview: 1,
slidespergroup: 1,
watchslidesprogress: true,
spacebetween: 0,
virtualtranslate: !swiper.params.cssmode
})
});
}
function effectcube(_ref) {
let {
swiper,
extendparams,
on
} = _ref;
extendparams({
cubeeffect: {
slideshadows: true,
shadow: true,
shadowoffset: 20,
shadowscale: 0.94
}
});
const createslideshadows = ($slideel, progress, ishorizontal) => {
let shadowbefore = ishorizontal ? $slideel.find('.swiper-slide-shadow-left') : $slideel.find('.swiper-slide-shadow-top');
let shadowafter = ishorizontal ? $slideel.find('.swiper-slide-shadow-right') : $slideel.find('.swiper-slide-shadow-bottom');
if (shadowbefore.length === 0) {
shadowbefore = $(``);
$slideel.append(shadowbefore);
}
if (shadowafter.length === 0) {
shadowafter = $(``);
$slideel.append(shadowafter);
}
if (shadowbefore.length) shadowbefore[0].style.opacity = math.max(-progress, 0);
if (shadowafter.length) shadowafter[0].style.opacity = math.max(progress, 0);
};
const recreateshadows = () => {
// create new ones
const ishorizontal = swiper.ishorizontal();
swiper.slides.each(slideel => {
const progress = math.max(math.min(slideel.progress, 1), -1);
createslideshadows($(slideel), progress, ishorizontal);
});
};
const settranslate = () => {
const {
$el,
$wrapperel,
slides,
width: swiperwidth,
height: swiperheight,
rtltranslate: rtl,
size: swipersize,
browser
} = swiper;
const params = swiper.params.cubeeffect;
const ishorizontal = swiper.ishorizontal();
const isvirtual = swiper.virtual && swiper.params.virtual.enabled;
let wrapperrotate = 0;
let $cubeshadowel;
if (params.shadow) {
if (ishorizontal) {
$cubeshadowel = $wrapperel.find('.swiper-cube-shadow');
if ($cubeshadowel.length === 0) {
$cubeshadowel = $('');
$wrapperel.append($cubeshadowel);
}
$cubeshadowel.css({
height: `${swiperwidth}px`
});
} else {
$cubeshadowel = $el.find('.swiper-cube-shadow');
if ($cubeshadowel.length === 0) {
$cubeshadowel = $('');
$el.append($cubeshadowel);
}
}
}
for (let i = 0; i < slides.length; i += 1) {
const $slideel = slides.eq(i);
let slideindex = i;
if (isvirtual) {
slideindex = parseint($slideel.attr('data-swiper-slide-index'), 10);
}
let slideangle = slideindex * 90;
let round = math.floor(slideangle / 360);
if (rtl) {
slideangle = -slideangle;
round = math.floor(-slideangle / 360);
}
const progress = math.max(math.min($slideel[0].progress, 1), -1);
let tx = 0;
let ty = 0;
let tz = 0;
if (slideindex % 4 === 0) {
tx = -round * 4 * swipersize;
tz = 0;
} else if ((slideindex - 1) % 4 === 0) {
tx = 0;
tz = -round * 4 * swipersize;
} else if ((slideindex - 2) % 4 === 0) {
tx = swipersize + round * 4 * swipersize;
tz = swipersize;
} else if ((slideindex - 3) % 4 === 0) {
tx = -swipersize;
tz = 3 * swipersize + swipersize * 4 * round;
}
if (rtl) {
tx = -tx;
}
if (!ishorizontal) {
ty = tx;
tx = 0;
}
const transform = `rotatex(${ishorizontal ? 0 : -slideangle}deg) rotatey(${ishorizontal ? slideangle : 0}deg) translate3d(${tx}px, ${ty}px, ${tz}px)`;
if (progress <= 1 && progress > -1) {
wrapperrotate = slideindex * 90 + progress * 90;
if (rtl) wrapperrotate = -slideindex * 90 - progress * 90;
}
$slideel.transform(transform);
if (params.slideshadows) {
createslideshadows($slideel, progress, ishorizontal);
}
}
$wrapperel.css({
'-webkit-transform-origin': `50% 50% -${swipersize / 2}px`,
'transform-origin': `50% 50% -${swipersize / 2}px`
});
if (params.shadow) {
if (ishorizontal) {
$cubeshadowel.transform(`translate3d(0px, ${swiperwidth / 2 + params.shadowoffset}px, ${-swiperwidth / 2}px) rotatex(90deg) rotatez(0deg) scale(${params.shadowscale})`);
} else {
const shadowangle = math.abs(wrapperrotate) - math.floor(math.abs(wrapperrotate) / 90) * 90;
const multiplier = 1.5 - (math.sin(shadowangle * 2 * math.pi / 360) / 2 + math.cos(shadowangle * 2 * math.pi / 360) / 2);
const scale1 = params.shadowscale;
const scale2 = params.shadowscale / multiplier;
const offset = params.shadowoffset;
$cubeshadowel.transform(`scale3d(${scale1}, 1, ${scale2}) translate3d(0px, ${swiperheight / 2 + offset}px, ${-swiperheight / 2 / scale2}px) rotatex(-90deg)`);
}
}
const zfactor = browser.issafari || browser.iswebview ? -swipersize / 2 : 0;
$wrapperel.transform(`translate3d(0px,0,${zfactor}px) rotatex(${swiper.ishorizontal() ? 0 : wrapperrotate}deg) rotatey(${swiper.ishorizontal() ? -wrapperrotate : 0}deg)`);
$wrapperel[0].style.setproperty('--swiper-cube-translate-z', `${zfactor}px`);
};
const settransition = duration => {
const {
$el,
slides
} = swiper;
slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
if (swiper.params.cubeeffect.shadow && !swiper.ishorizontal()) {
$el.find('.swiper-cube-shadow').transition(duration);
}
};
effectinit({
effect: 'cube',
swiper,
on,
settranslate,
settransition,
recreateshadows,
geteffectparams: () => swiper.params.cubeeffect,
perspective: () => true,
overwriteparams: () => ({
slidesperview: 1,
slidespergroup: 1,
watchslidesprogress: true,
resistanceratio: 0,
spacebetween: 0,
centeredslides: false,
virtualtranslate: true
})
});
}
function createshadow(params, $slideel, side) {
const shadowclass = `swiper-slide-shadow${side ? `-${side}` : ''}`;
const $shadowcontainer = params.transformel ? $slideel.find(params.transformel) : $slideel;
let $shadowel = $shadowcontainer.children(`.${shadowclass}`);
if (!$shadowel.length) {
$shadowel = $(``);
$shadowcontainer.append($shadowel);
}
return $shadowel;
}
function effectflip(_ref) {
let {
swiper,
extendparams,
on
} = _ref;
extendparams({
flipeffect: {
slideshadows: true,
limitrotation: true,
transformel: null
}
});
const createslideshadows = ($slideel, progress, params) => {
let shadowbefore = swiper.ishorizontal() ? $slideel.find('.swiper-slide-shadow-left') : $slideel.find('.swiper-slide-shadow-top');
let shadowafter = swiper.ishorizontal() ? $slideel.find('.swiper-slide-shadow-right') : $slideel.find('.swiper-slide-shadow-bottom');
if (shadowbefore.length === 0) {
shadowbefore = createshadow(params, $slideel, swiper.ishorizontal() ? 'left' : 'top');
}
if (shadowafter.length === 0) {
shadowafter = createshadow(params, $slideel, swiper.ishorizontal() ? 'right' : 'bottom');
}
if (shadowbefore.length) shadowbefore[0].style.opacity = math.max(-progress, 0);
if (shadowafter.length) shadowafter[0].style.opacity = math.max(progress, 0);
};
const recreateshadows = () => {
// set shadows
const params = swiper.params.flipeffect;
swiper.slides.each(slideel => {
const $slideel = $(slideel);
let progress = $slideel[0].progress;
if (swiper.params.flipeffect.limitrotation) {
progress = math.max(math.min(slideel.progress, 1), -1);
}
createslideshadows($slideel, progress, params);
});
};
const settranslate = () => {
const {
slides,
rtltranslate: rtl
} = swiper;
const params = swiper.params.flipeffect;
for (let i = 0; i < slides.length; i += 1) {
const $slideel = slides.eq(i);
let progress = $slideel[0].progress;
if (swiper.params.flipeffect.limitrotation) {
progress = math.max(math.min($slideel[0].progress, 1), -1);
}
const offset = $slideel[0].swiperslideoffset;
const rotate = -180 * progress;
let rotatey = rotate;
let rotatex = 0;
let tx = swiper.params.cssmode ? -offset - swiper.translate : -offset;
let ty = 0;
if (!swiper.ishorizontal()) {
ty = tx;
tx = 0;
rotatex = -rotatey;
rotatey = 0;
} else if (rtl) {
rotatey = -rotatey;
}
$slideel[0].style.zindex = -math.abs(math.round(progress)) + slides.length;
if (params.slideshadows) {
createslideshadows($slideel, progress, params);
}
const transform = `translate3d(${tx}px, ${ty}px, 0px) rotatex(${rotatex}deg) rotatey(${rotatey}deg)`;
const $targetel = effecttarget(params, $slideel);
$targetel.transform(transform);
}
};
const settransition = duration => {
const {
transformel
} = swiper.params.flipeffect;
const $transitionelements = transformel ? swiper.slides.find(transformel) : swiper.slides;
$transitionelements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
effectvirtualtransitionend({
swiper,
duration,
transformel
});
};
effectinit({
effect: 'flip',
swiper,
on,
settranslate,
settransition,
recreateshadows,
geteffectparams: () => swiper.params.flipeffect,
perspective: () => true,
overwriteparams: () => ({
slidesperview: 1,
slidespergroup: 1,
watchslidesprogress: true,
spacebetween: 0,
virtualtranslate: !swiper.params.cssmode
})
});
}
function effectcoverflow(_ref) {
let {
swiper,
extendparams,
on
} = _ref;
extendparams({
coverfloweffect: {
rotate: 50,
stretch: 0,
depth: 100,
scale: 1,
modifier: 1,
slideshadows: true,
transformel: null
}
});
const settranslate = () => {
const {
width: swiperwidth,
height: swiperheight,
slides,
slidessizesgrid
} = swiper;
const params = swiper.params.coverfloweffect;
const ishorizontal = swiper.ishorizontal();
const transform = swiper.translate;
const center = ishorizontal ? -transform + swiperwidth / 2 : -transform + swiperheight / 2;
const rotate = ishorizontal ? params.rotate : -params.rotate;
const translate = params.depth; // each slide offset from center
for (let i = 0, length = slides.length; i < length; i += 1) {
const $slideel = slides.eq(i);
const slidesize = slidessizesgrid[i];
const slideoffset = $slideel[0].swiperslideoffset;
const centeroffset = (center - slideoffset - slidesize / 2) / slidesize;
const offsetmultiplier = typeof params.modifier === 'function' ? params.modifier(centeroffset) : centeroffset * params.modifier;
let rotatey = ishorizontal ? rotate * offsetmultiplier : 0;
let rotatex = ishorizontal ? 0 : rotate * offsetmultiplier; // var rotatez = 0
let translatez = -translate * math.abs(offsetmultiplier);
let stretch = params.stretch; // allow percentage to make a relative stretch for responsive sliders
if (typeof stretch === 'string' && stretch.indexof('%') !== -1) {
stretch = parsefloat(params.stretch) / 100 * slidesize;
}
let translatey = ishorizontal ? 0 : stretch * offsetmultiplier;
let translatex = ishorizontal ? stretch * offsetmultiplier : 0;
let scale = 1 - (1 - params.scale) * math.abs(offsetmultiplier); // fix for ultra small values
if (math.abs(translatex) < 0.001) translatex = 0;
if (math.abs(translatey) < 0.001) translatey = 0;
if (math.abs(translatez) < 0.001) translatez = 0;
if (math.abs(rotatey) < 0.001) rotatey = 0;
if (math.abs(rotatex) < 0.001) rotatex = 0;
if (math.abs(scale) < 0.001) scale = 0;
const slidetransform = `translate3d(${translatex}px,${translatey}px,${translatez}px) rotatex(${rotatex}deg) rotatey(${rotatey}deg) scale(${scale})`;
const $targetel = effecttarget(params, $slideel);
$targetel.transform(slidetransform);
$slideel[0].style.zindex = -math.abs(math.round(offsetmultiplier)) + 1;
if (params.slideshadows) {
// set shadows
let $shadowbeforeel = ishorizontal ? $slideel.find('.swiper-slide-shadow-left') : $slideel.find('.swiper-slide-shadow-top');
let $shadowafterel = ishorizontal ? $slideel.find('.swiper-slide-shadow-right') : $slideel.find('.swiper-slide-shadow-bottom');
if ($shadowbeforeel.length === 0) {
$shadowbeforeel = createshadow(params, $slideel, ishorizontal ? 'left' : 'top');
}
if ($shadowafterel.length === 0) {
$shadowafterel = createshadow(params, $slideel, ishorizontal ? 'right' : 'bottom');
}
if ($shadowbeforeel.length) $shadowbeforeel[0].style.opacity = offsetmultiplier > 0 ? offsetmultiplier : 0;
if ($shadowafterel.length) $shadowafterel[0].style.opacity = -offsetmultiplier > 0 ? -offsetmultiplier : 0;
}
}
};
const settransition = duration => {
const {
transformel
} = swiper.params.coverfloweffect;
const $transitionelements = transformel ? swiper.slides.find(transformel) : swiper.slides;
$transitionelements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
};
effectinit({
effect: 'coverflow',
swiper,
on,
settranslate,
settransition,
perspective: () => true,
overwriteparams: () => ({
watchslidesprogress: true
})
});
}
function effectcreative(_ref) {
let {
swiper,
extendparams,
on
} = _ref;
extendparams({
creativeeffect: {
transformel: null,
limitprogress: 1,
shadowperprogress: false,
progressmultiplier: 1,
perspective: true,
prev: {
translate: [0, 0, 0],
rotate: [0, 0, 0],
opacity: 1,
scale: 1
},
next: {
translate: [0, 0, 0],
rotate: [0, 0, 0],
opacity: 1,
scale: 1
}
}
});
const gettranslatevalue = value => {
if (typeof value === 'string') return value;
return `${value}px`;
};
const settranslate = () => {
const {
slides,
$wrapperel,
slidessizesgrid
} = swiper;
const params = swiper.params.creativeeffect;
const {
progressmultiplier: multiplier
} = params;
const iscenteredslides = swiper.params.centeredslides;
if (iscenteredslides) {
const margin = slidessizesgrid[0] / 2 - swiper.params.slidesoffsetbefore || 0;
$wrapperel.transform(`translatex(calc(50% - ${margin}px))`);
}
for (let i = 0; i < slides.length; i += 1) {
const $slideel = slides.eq(i);
const slideprogress = $slideel[0].progress;
const progress = math.min(math.max($slideel[0].progress, -params.limitprogress), params.limitprogress);
let originalprogress = progress;
if (!iscenteredslides) {
originalprogress = math.min(math.max($slideel[0].originalprogress, -params.limitprogress), params.limitprogress);
}
const offset = $slideel[0].swiperslideoffset;
const t = [swiper.params.cssmode ? -offset - swiper.translate : -offset, 0, 0];
const r = [0, 0, 0];
let custom = false;
if (!swiper.ishorizontal()) {
t[1] = t[0];
t[0] = 0;
}
let data = {
translate: [0, 0, 0],
rotate: [0, 0, 0],
scale: 1,
opacity: 1
};
if (progress < 0) {
data = params.next;
custom = true;
} else if (progress > 0) {
data = params.prev;
custom = true;
} // set translate
t.foreach((value, index) => {
t[index] = `calc(${value}px + (${gettranslatevalue(data.translate[index])} * ${math.abs(progress * multiplier)}))`;
}); // set rotates
r.foreach((value, index) => {
r[index] = data.rotate[index] * math.abs(progress * multiplier);
});
$slideel[0].style.zindex = -math.abs(math.round(slideprogress)) + slides.length;
const translatestring = t.join(', ');
const rotatestring = `rotatex(${r[0]}deg) rotatey(${r[1]}deg) rotatez(${r[2]}deg)`;
const scalestring = originalprogress < 0 ? `scale(${1 + (1 - data.scale) * originalprogress * multiplier})` : `scale(${1 - (1 - data.scale) * originalprogress * multiplier})`;
const opacitystring = originalprogress < 0 ? 1 + (1 - data.opacity) * originalprogress * multiplier : 1 - (1 - data.opacity) * originalprogress * multiplier;
const transform = `translate3d(${translatestring}) ${rotatestring} ${scalestring}`; // set shadows
if (custom && data.shadow || !custom) {
let $shadowel = $slideel.children('.swiper-slide-shadow');
if ($shadowel.length === 0 && data.shadow) {
$shadowel = createshadow(params, $slideel);
}
if ($shadowel.length) {
const shadowopacity = params.shadowperprogress ? progress * (1 / params.limitprogress) : progress;
$shadowel[0].style.opacity = math.min(math.max(math.abs(shadowopacity), 0), 1);
}
}
const $targetel = effecttarget(params, $slideel);
$targetel.transform(transform).css({
opacity: opacitystring
});
if (data.origin) {
$targetel.css('transform-origin', data.origin);
}
}
};
const settransition = duration => {
const {
transformel
} = swiper.params.creativeeffect;
const $transitionelements = transformel ? swiper.slides.find(transformel) : swiper.slides;
$transitionelements.transition(duration).find('.swiper-slide-shadow').transition(duration);
effectvirtualtransitionend({
swiper,
duration,
transformel,
allslides: true
});
};
effectinit({
effect: 'creative',
swiper,
on,
settranslate,
settransition,
perspective: () => swiper.params.creativeeffect.perspective,
overwriteparams: () => ({
watchslidesprogress: true,
virtualtranslate: !swiper.params.cssmode
})
});
}
function effectcards(_ref) {
let {
swiper,
extendparams,
on
} = _ref;
extendparams({
cardseffect: {
slideshadows: true,
transformel: null,
rotate: true
}
});
const settranslate = () => {
const {
slides,
activeindex
} = swiper;
const params = swiper.params.cardseffect;
const {
starttranslate,
istouched
} = swiper.toucheventsdata;
const currenttranslate = swiper.translate;
for (let i = 0; i < slides.length; i += 1) {
const $slideel = slides.eq(i);
const slideprogress = $slideel[0].progress;
const progress = math.min(math.max(slideprogress, -4), 4);
let offset = $slideel[0].swiperslideoffset;
if (swiper.params.centeredslides && !swiper.params.cssmode) {
swiper.$wrapperel.transform(`translatex(${swiper.mintranslate()}px)`);
}
if (swiper.params.centeredslides && swiper.params.cssmode) {
offset -= slides[0].swiperslideoffset;
}
let tx = swiper.params.cssmode ? -offset - swiper.translate : -offset;
let ty = 0;
const tz = -100 * math.abs(progress);
let scale = 1;
let rotate = -2 * progress;
let txadd = 8 - math.abs(progress) * 0.75;
const slideindex = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.from + i : i;
const isswipetonext = (slideindex === activeindex || slideindex === activeindex - 1) && progress > 0 && progress < 1 && (istouched || swiper.params.cssmode) && currenttranslate < starttranslate;
const isswipetoprev = (slideindex === activeindex || slideindex === activeindex + 1) && progress < 0 && progress > -1 && (istouched || swiper.params.cssmode) && currenttranslate > starttranslate;
if (isswipetonext || isswipetoprev) {
const subprogress = (1 - math.abs((math.abs(progress) - 0.5) / 0.5)) ** 0.5;
rotate += -28 * progress * subprogress;
scale += -0.5 * subprogress;
txadd += 96 * subprogress;
ty = `${-25 * subprogress * math.abs(progress)}%`;
}
if (progress < 0) {
// next
tx = `calc(${tx}px + (${txadd * math.abs(progress)}%))`;
} else if (progress > 0) {
// prev
tx = `calc(${tx}px + (-${txadd * math.abs(progress)}%))`;
} else {
tx = `${tx}px`;
}
if (!swiper.ishorizontal()) {
const prevy = ty;
ty = tx;
tx = prevy;
}
const scalestring = progress < 0 ? `${1 + (1 - scale) * progress}` : `${1 - (1 - scale) * progress}`;
const transform = `
translate3d(${tx}, ${ty}, ${tz}px)
rotatez(${params.rotate ? rotate : 0}deg)
scale(${scalestring})
`;
if (params.slideshadows) {
// set shadows
let $shadowel = $slideel.find('.swiper-slide-shadow');
if ($shadowel.length === 0) {
$shadowel = createshadow(params, $slideel);
}
if ($shadowel.length) $shadowel[0].style.opacity = math.min(math.max((math.abs(progress) - 0.5) / 0.5, 0), 1);
}
$slideel[0].style.zindex = -math.abs(math.round(slideprogress)) + slides.length;
const $targetel = effecttarget(params, $slideel);
$targetel.transform(transform);
}
};
const settransition = duration => {
const {
transformel
} = swiper.params.cardseffect;
const $transitionelements = transformel ? swiper.slides.find(transformel) : swiper.slides;
$transitionelements.transition(duration).find('.swiper-slide-shadow').transition(duration);
effectvirtualtransitionend({
swiper,
duration,
transformel
});
};
effectinit({
effect: 'cards',
swiper,
on,
settranslate,
settransition,
perspective: () => true,
overwriteparams: () => ({
watchslidesprogress: true,
virtualtranslate: !swiper.params.cssmode
})
});
}
// swiper class
const modules = [virtual, keyboard, mousewheel, navigation, pagination, scrollbar, parallax, zoom, lazy, controller, a11y, history, hashnavigation, autoplay, thumb, freemode, grid, manipulation, effectfade, effectcube, effectflip, effectcoverflow, effectcreative, effectcards];
swiper.use(modules);
return swiper;
}));