@realsee/dnalogel 2.1.0-alpha.12 → 2.1.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PanoTagPlugin/index.js +4126 -24
- package/dist/index.es.js +4105 -3
- package/dist/index.js +4127 -25
- package/dist/index.umd.js +4128 -27
- package/package.json +2 -1
|
@@ -7,12 +7,13 @@ var THREE = require('three');
|
|
|
7
7
|
var objectAssignDeep = require('object-assign-deep');
|
|
8
8
|
var store = require('svelte/store');
|
|
9
9
|
var internal = require('svelte/internal');
|
|
10
|
-
var transition = require('svelte/transition');
|
|
10
|
+
var transition$1 = require('svelte/transition');
|
|
11
11
|
var anime = require('animejs');
|
|
12
12
|
var svelte = require('svelte');
|
|
13
13
|
var easing = require('svelte/easing');
|
|
14
14
|
var svelte$1 = require('swiper/svelte');
|
|
15
|
-
var
|
|
15
|
+
var ssrWindow = require('ssr-window');
|
|
16
|
+
var dom7 = require('dom7');
|
|
16
17
|
require('swiper/css');
|
|
17
18
|
require('swiper/css/autoplay');
|
|
18
19
|
var CSS3DRenderer = require('three/examples/jsm/renderers/CSS3DRenderer');
|
|
@@ -340,7 +341,7 @@ function create_if_block$h(ctx) {
|
|
|
340
341
|
internal.add_render_callback(() => {
|
|
341
342
|
if (path_outro) path_outro.end(1);
|
|
342
343
|
|
|
343
|
-
path_intro = internal.create_in_transition(path, transition.draw, {
|
|
344
|
+
path_intro = internal.create_in_transition(path, transition$1.draw, {
|
|
344
345
|
duration: /*duration*/ ctx[1],
|
|
345
346
|
delay: /*inDelay*/ ctx[0]
|
|
346
347
|
});
|
|
@@ -355,7 +356,7 @@ function create_if_block$h(ctx) {
|
|
|
355
356
|
if (path_intro) path_intro.invalidate();
|
|
356
357
|
|
|
357
358
|
if (local) {
|
|
358
|
-
path_outro = internal.create_out_transition(path, transition.draw, {
|
|
359
|
+
path_outro = internal.create_out_transition(path, transition$1.draw, {
|
|
359
360
|
duration: /*duration*/ ctx[1],
|
|
360
361
|
delay: /*outDelay*/ ctx[2]
|
|
361
362
|
});
|
|
@@ -561,7 +562,7 @@ function create_if_block$g(ctx) {
|
|
|
561
562
|
if (local) {
|
|
562
563
|
internal.add_render_callback(() => {
|
|
563
564
|
if (div_outro) div_outro.end(1);
|
|
564
|
-
div_intro = internal.create_in_transition(div, transition.fade, { duration: /*inDelay*/ ctx[0] });
|
|
565
|
+
div_intro = internal.create_in_transition(div, transition$1.fade, { duration: /*inDelay*/ ctx[0] });
|
|
565
566
|
div_intro.start();
|
|
566
567
|
});
|
|
567
568
|
}
|
|
@@ -572,7 +573,7 @@ function create_if_block$g(ctx) {
|
|
|
572
573
|
if (div_intro) div_intro.invalidate();
|
|
573
574
|
|
|
574
575
|
if (local) {
|
|
575
|
-
div_outro = internal.create_out_transition(div, transition.fade, { duration: /*outDelay*/ ctx[1] });
|
|
576
|
+
div_outro = internal.create_out_transition(div, transition$1.fade, { duration: /*outDelay*/ ctx[1] });
|
|
576
577
|
}
|
|
577
578
|
|
|
578
579
|
current = false;
|
|
@@ -1035,7 +1036,7 @@ function create_if_block$f(ctx) {
|
|
|
1035
1036
|
internal.add_render_callback(() => {
|
|
1036
1037
|
if (div0_outro) div0_outro.end(1);
|
|
1037
1038
|
|
|
1038
|
-
div0_intro = internal.create_in_transition(div0, transition.fade, {
|
|
1039
|
+
div0_intro = internal.create_in_transition(div0, transition$1.fade, {
|
|
1039
1040
|
duration: /*duration*/ ctx[2],
|
|
1040
1041
|
delay: /*inDelay*/ ctx[3],
|
|
1041
1042
|
easing: easing.cubicInOut
|
|
@@ -1052,7 +1053,7 @@ function create_if_block$f(ctx) {
|
|
|
1052
1053
|
if (div0_intro) div0_intro.invalidate();
|
|
1053
1054
|
|
|
1054
1055
|
if (local) {
|
|
1055
|
-
div0_outro = internal.create_out_transition(div0, transition.fade, {
|
|
1056
|
+
div0_outro = internal.create_out_transition(div0, transition$1.fade, {
|
|
1056
1057
|
duration: /*duration*/ ctx[2],
|
|
1057
1058
|
delay: /*outDelay*/ ctx[4],
|
|
1058
1059
|
easing: easing.cubicInOut
|
|
@@ -1771,7 +1772,7 @@ function create_if_block$c(ctx) {
|
|
|
1771
1772
|
internal.add_render_callback(() => {
|
|
1772
1773
|
if (path_outro) path_outro.end(1);
|
|
1773
1774
|
|
|
1774
|
-
path_intro = internal.create_in_transition(path, transition.draw, {
|
|
1775
|
+
path_intro = internal.create_in_transition(path, transition$1.draw, {
|
|
1775
1776
|
duration: /*duration*/ ctx[1],
|
|
1776
1777
|
delay: /*inDelay*/ ctx[0],
|
|
1777
1778
|
easing: easing.cubicOut
|
|
@@ -1787,7 +1788,7 @@ function create_if_block$c(ctx) {
|
|
|
1787
1788
|
if (path_intro) path_intro.invalidate();
|
|
1788
1789
|
|
|
1789
1790
|
if (local) {
|
|
1790
|
-
path_outro = internal.create_out_transition(path, transition.draw, {
|
|
1791
|
+
path_outro = internal.create_out_transition(path, transition$1.draw, {
|
|
1791
1792
|
duration: /*duration*/ ctx[1],
|
|
1792
1793
|
delay: /*outDelay*/ ctx[2],
|
|
1793
1794
|
easing: easing.cubicInOut
|
|
@@ -1913,6 +1914,4107 @@ class Polyline extends internal.SvelteComponent {
|
|
|
1913
1914
|
}
|
|
1914
1915
|
}
|
|
1915
1916
|
|
|
1917
|
+
const Methods = {
|
|
1918
|
+
addClass: dom7.addClass,
|
|
1919
|
+
removeClass: dom7.removeClass,
|
|
1920
|
+
hasClass: dom7.hasClass,
|
|
1921
|
+
toggleClass: dom7.toggleClass,
|
|
1922
|
+
attr: dom7.attr,
|
|
1923
|
+
removeAttr: dom7.removeAttr,
|
|
1924
|
+
transform: dom7.transform,
|
|
1925
|
+
transition: dom7.transition,
|
|
1926
|
+
on: dom7.on,
|
|
1927
|
+
off: dom7.off,
|
|
1928
|
+
trigger: dom7.trigger,
|
|
1929
|
+
transitionEnd: dom7.transitionEnd,
|
|
1930
|
+
outerWidth: dom7.outerWidth,
|
|
1931
|
+
outerHeight: dom7.outerHeight,
|
|
1932
|
+
styles: dom7.styles,
|
|
1933
|
+
offset: dom7.offset,
|
|
1934
|
+
css: dom7.css,
|
|
1935
|
+
each: dom7.each,
|
|
1936
|
+
html: dom7.html,
|
|
1937
|
+
text: dom7.text,
|
|
1938
|
+
is: dom7.is,
|
|
1939
|
+
index: dom7.index,
|
|
1940
|
+
eq: dom7.eq,
|
|
1941
|
+
append: dom7.append,
|
|
1942
|
+
prepend: dom7.prepend,
|
|
1943
|
+
next: dom7.next,
|
|
1944
|
+
nextAll: dom7.nextAll,
|
|
1945
|
+
prev: dom7.prev,
|
|
1946
|
+
prevAll: dom7.prevAll,
|
|
1947
|
+
parent: dom7.parent,
|
|
1948
|
+
parents: dom7.parents,
|
|
1949
|
+
closest: dom7.closest,
|
|
1950
|
+
find: dom7.find,
|
|
1951
|
+
children: dom7.children,
|
|
1952
|
+
filter: dom7.filter,
|
|
1953
|
+
remove: dom7.remove
|
|
1954
|
+
};
|
|
1955
|
+
Object.keys(Methods).forEach(methodName => {
|
|
1956
|
+
Object.defineProperty(dom7.$.fn, methodName, {
|
|
1957
|
+
value: Methods[methodName],
|
|
1958
|
+
writable: true
|
|
1959
|
+
});
|
|
1960
|
+
});
|
|
1961
|
+
|
|
1962
|
+
function deleteProps(obj) {
|
|
1963
|
+
const object = obj;
|
|
1964
|
+
Object.keys(object).forEach(key => {
|
|
1965
|
+
try {
|
|
1966
|
+
object[key] = null;
|
|
1967
|
+
} catch (e) {// no getter for object
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
try {
|
|
1971
|
+
delete object[key];
|
|
1972
|
+
} catch (e) {// something got wrong
|
|
1973
|
+
}
|
|
1974
|
+
});
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
function nextTick(callback, delay = 0) {
|
|
1978
|
+
return setTimeout(callback, delay);
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
function now() {
|
|
1982
|
+
return Date.now();
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
function getComputedStyle$1(el) {
|
|
1986
|
+
const window = ssrWindow.getWindow();
|
|
1987
|
+
let style;
|
|
1988
|
+
|
|
1989
|
+
if (window.getComputedStyle) {
|
|
1990
|
+
style = window.getComputedStyle(el, null);
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
if (!style && el.currentStyle) {
|
|
1994
|
+
style = el.currentStyle;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
if (!style) {
|
|
1998
|
+
style = el.style;
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
return style;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
function getTranslate(el, axis = 'x') {
|
|
2005
|
+
const window = ssrWindow.getWindow();
|
|
2006
|
+
let matrix;
|
|
2007
|
+
let curTransform;
|
|
2008
|
+
let transformMatrix;
|
|
2009
|
+
const curStyle = getComputedStyle$1(el);
|
|
2010
|
+
|
|
2011
|
+
if (window.WebKitCSSMatrix) {
|
|
2012
|
+
curTransform = curStyle.transform || curStyle.webkitTransform;
|
|
2013
|
+
|
|
2014
|
+
if (curTransform.split(',').length > 6) {
|
|
2015
|
+
curTransform = curTransform.split(', ').map(a => a.replace(',', '.')).join(', ');
|
|
2016
|
+
} // Some old versions of Webkit choke when 'none' is passed; pass
|
|
2017
|
+
// empty string instead in this case
|
|
2018
|
+
|
|
2019
|
+
|
|
2020
|
+
transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
|
|
2021
|
+
} else {
|
|
2022
|
+
transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
|
|
2023
|
+
matrix = transformMatrix.toString().split(',');
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
if (axis === 'x') {
|
|
2027
|
+
// Latest Chrome and webkits Fix
|
|
2028
|
+
if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41; // Crazy IE10 Matrix
|
|
2029
|
+
else if (matrix.length === 16) curTransform = parseFloat(matrix[12]); // Normal Browsers
|
|
2030
|
+
else curTransform = parseFloat(matrix[4]);
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
if (axis === 'y') {
|
|
2034
|
+
// Latest Chrome and webkits Fix
|
|
2035
|
+
if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42; // Crazy IE10 Matrix
|
|
2036
|
+
else if (matrix.length === 16) curTransform = parseFloat(matrix[13]); // Normal Browsers
|
|
2037
|
+
else curTransform = parseFloat(matrix[5]);
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
return curTransform || 0;
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
function isObject(o) {
|
|
2044
|
+
return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
function isNode(node) {
|
|
2048
|
+
// eslint-disable-next-line
|
|
2049
|
+
if (typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined') {
|
|
2050
|
+
return node instanceof HTMLElement;
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
return node && (node.nodeType === 1 || node.nodeType === 11);
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2056
|
+
function extend(...args) {
|
|
2057
|
+
const to = Object(args[0]);
|
|
2058
|
+
const noExtend = ['__proto__', 'constructor', 'prototype'];
|
|
2059
|
+
|
|
2060
|
+
for (let i = 1; i < args.length; i += 1) {
|
|
2061
|
+
const nextSource = args[i];
|
|
2062
|
+
|
|
2063
|
+
if (nextSource !== undefined && nextSource !== null && !isNode(nextSource)) {
|
|
2064
|
+
const keysArray = Object.keys(Object(nextSource)).filter(key => noExtend.indexOf(key) < 0);
|
|
2065
|
+
|
|
2066
|
+
for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
|
|
2067
|
+
const nextKey = keysArray[nextIndex];
|
|
2068
|
+
const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
|
|
2069
|
+
|
|
2070
|
+
if (desc !== undefined && desc.enumerable) {
|
|
2071
|
+
if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
|
|
2072
|
+
if (nextSource[nextKey].__swiper__) {
|
|
2073
|
+
to[nextKey] = nextSource[nextKey];
|
|
2074
|
+
} else {
|
|
2075
|
+
extend(to[nextKey], nextSource[nextKey]);
|
|
2076
|
+
}
|
|
2077
|
+
} else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
|
|
2078
|
+
to[nextKey] = {};
|
|
2079
|
+
|
|
2080
|
+
if (nextSource[nextKey].__swiper__) {
|
|
2081
|
+
to[nextKey] = nextSource[nextKey];
|
|
2082
|
+
} else {
|
|
2083
|
+
extend(to[nextKey], nextSource[nextKey]);
|
|
2084
|
+
}
|
|
2085
|
+
} else {
|
|
2086
|
+
to[nextKey] = nextSource[nextKey];
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
return to;
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
function setCSSProperty(el, varName, varValue) {
|
|
2097
|
+
el.style.setProperty(varName, varValue);
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
function animateCSSModeScroll({
|
|
2101
|
+
swiper,
|
|
2102
|
+
targetPosition,
|
|
2103
|
+
side
|
|
2104
|
+
}) {
|
|
2105
|
+
const window = ssrWindow.getWindow();
|
|
2106
|
+
const startPosition = -swiper.translate;
|
|
2107
|
+
let startTime = null;
|
|
2108
|
+
let time;
|
|
2109
|
+
const duration = swiper.params.speed;
|
|
2110
|
+
swiper.wrapperEl.style.scrollSnapType = 'none';
|
|
2111
|
+
window.cancelAnimationFrame(swiper.cssModeFrameID);
|
|
2112
|
+
const dir = targetPosition > startPosition ? 'next' : 'prev';
|
|
2113
|
+
|
|
2114
|
+
const isOutOfBound = (current, target) => {
|
|
2115
|
+
return dir === 'next' && current >= target || dir === 'prev' && current <= target;
|
|
2116
|
+
};
|
|
2117
|
+
|
|
2118
|
+
const animate = () => {
|
|
2119
|
+
time = new Date().getTime();
|
|
2120
|
+
|
|
2121
|
+
if (startTime === null) {
|
|
2122
|
+
startTime = time;
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
|
|
2126
|
+
const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2;
|
|
2127
|
+
let currentPosition = startPosition + easeProgress * (targetPosition - startPosition);
|
|
2128
|
+
|
|
2129
|
+
if (isOutOfBound(currentPosition, targetPosition)) {
|
|
2130
|
+
currentPosition = targetPosition;
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
swiper.wrapperEl.scrollTo({
|
|
2134
|
+
[side]: currentPosition
|
|
2135
|
+
});
|
|
2136
|
+
|
|
2137
|
+
if (isOutOfBound(currentPosition, targetPosition)) {
|
|
2138
|
+
swiper.wrapperEl.style.overflow = 'hidden';
|
|
2139
|
+
swiper.wrapperEl.style.scrollSnapType = '';
|
|
2140
|
+
setTimeout(() => {
|
|
2141
|
+
swiper.wrapperEl.style.overflow = '';
|
|
2142
|
+
swiper.wrapperEl.scrollTo({
|
|
2143
|
+
[side]: currentPosition
|
|
2144
|
+
});
|
|
2145
|
+
});
|
|
2146
|
+
window.cancelAnimationFrame(swiper.cssModeFrameID);
|
|
2147
|
+
return;
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
swiper.cssModeFrameID = window.requestAnimationFrame(animate);
|
|
2151
|
+
};
|
|
2152
|
+
|
|
2153
|
+
animate();
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
let support;
|
|
2157
|
+
|
|
2158
|
+
function calcSupport() {
|
|
2159
|
+
const window = ssrWindow.getWindow();
|
|
2160
|
+
const document = ssrWindow.getDocument();
|
|
2161
|
+
return {
|
|
2162
|
+
smoothScroll: document.documentElement && 'scrollBehavior' in document.documentElement.style,
|
|
2163
|
+
touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch),
|
|
2164
|
+
passiveListener: function checkPassiveListener() {
|
|
2165
|
+
let supportsPassive = false;
|
|
2166
|
+
|
|
2167
|
+
try {
|
|
2168
|
+
const opts = Object.defineProperty({}, 'passive', {
|
|
2169
|
+
// eslint-disable-next-line
|
|
2170
|
+
get() {
|
|
2171
|
+
supportsPassive = true;
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
});
|
|
2175
|
+
window.addEventListener('testPassiveListener', null, opts);
|
|
2176
|
+
} catch (e) {// No support
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
return supportsPassive;
|
|
2180
|
+
}(),
|
|
2181
|
+
gestures: function checkGestures() {
|
|
2182
|
+
return 'ongesturestart' in window;
|
|
2183
|
+
}()
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
function getSupport() {
|
|
2188
|
+
if (!support) {
|
|
2189
|
+
support = calcSupport();
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
return support;
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
let deviceCached;
|
|
2196
|
+
|
|
2197
|
+
function calcDevice({
|
|
2198
|
+
userAgent
|
|
2199
|
+
} = {}) {
|
|
2200
|
+
const support = getSupport();
|
|
2201
|
+
const window = ssrWindow.getWindow();
|
|
2202
|
+
const platform = window.navigator.platform;
|
|
2203
|
+
const ua = userAgent || window.navigator.userAgent;
|
|
2204
|
+
const device = {
|
|
2205
|
+
ios: false,
|
|
2206
|
+
android: false
|
|
2207
|
+
};
|
|
2208
|
+
const screenWidth = window.screen.width;
|
|
2209
|
+
const screenHeight = window.screen.height;
|
|
2210
|
+
const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line
|
|
2211
|
+
|
|
2212
|
+
let ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
|
|
2213
|
+
const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
|
|
2214
|
+
const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
|
|
2215
|
+
const windows = platform === 'Win32';
|
|
2216
|
+
let macos = platform === 'MacIntel'; // iPadOs 13 fix
|
|
2217
|
+
|
|
2218
|
+
const iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
|
|
2219
|
+
|
|
2220
|
+
if (!ipad && macos && support.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) {
|
|
2221
|
+
ipad = ua.match(/(Version)\/([\d.]+)/);
|
|
2222
|
+
if (!ipad) ipad = [0, 1, '13_0_0'];
|
|
2223
|
+
macos = false;
|
|
2224
|
+
} // Android
|
|
2225
|
+
|
|
2226
|
+
|
|
2227
|
+
if (android && !windows) {
|
|
2228
|
+
device.os = 'android';
|
|
2229
|
+
device.android = true;
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
if (ipad || iphone || ipod) {
|
|
2233
|
+
device.os = 'ios';
|
|
2234
|
+
device.ios = true;
|
|
2235
|
+
} // Export object
|
|
2236
|
+
|
|
2237
|
+
|
|
2238
|
+
return device;
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
function getDevice(overrides = {}) {
|
|
2242
|
+
if (!deviceCached) {
|
|
2243
|
+
deviceCached = calcDevice(overrides);
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
return deviceCached;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
let browser;
|
|
2250
|
+
|
|
2251
|
+
function calcBrowser() {
|
|
2252
|
+
const window = ssrWindow.getWindow();
|
|
2253
|
+
|
|
2254
|
+
function isSafari() {
|
|
2255
|
+
const ua = window.navigator.userAgent.toLowerCase();
|
|
2256
|
+
return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
return {
|
|
2260
|
+
isSafari: isSafari(),
|
|
2261
|
+
isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent)
|
|
2262
|
+
};
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
function getBrowser() {
|
|
2266
|
+
if (!browser) {
|
|
2267
|
+
browser = calcBrowser();
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
return browser;
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
function Resize({
|
|
2274
|
+
swiper,
|
|
2275
|
+
on,
|
|
2276
|
+
emit
|
|
2277
|
+
}) {
|
|
2278
|
+
const window = ssrWindow.getWindow();
|
|
2279
|
+
let observer = null;
|
|
2280
|
+
let animationFrame = null;
|
|
2281
|
+
|
|
2282
|
+
const resizeHandler = () => {
|
|
2283
|
+
if (!swiper || swiper.destroyed || !swiper.initialized) return;
|
|
2284
|
+
emit('beforeResize');
|
|
2285
|
+
emit('resize');
|
|
2286
|
+
};
|
|
2287
|
+
|
|
2288
|
+
const createObserver = () => {
|
|
2289
|
+
if (!swiper || swiper.destroyed || !swiper.initialized) return;
|
|
2290
|
+
observer = new ResizeObserver(entries => {
|
|
2291
|
+
animationFrame = window.requestAnimationFrame(() => {
|
|
2292
|
+
const {
|
|
2293
|
+
width,
|
|
2294
|
+
height
|
|
2295
|
+
} = swiper;
|
|
2296
|
+
let newWidth = width;
|
|
2297
|
+
let newHeight = height;
|
|
2298
|
+
entries.forEach(({
|
|
2299
|
+
contentBoxSize,
|
|
2300
|
+
contentRect,
|
|
2301
|
+
target
|
|
2302
|
+
}) => {
|
|
2303
|
+
if (target && target !== swiper.el) return;
|
|
2304
|
+
newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize;
|
|
2305
|
+
newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize;
|
|
2306
|
+
});
|
|
2307
|
+
|
|
2308
|
+
if (newWidth !== width || newHeight !== height) {
|
|
2309
|
+
resizeHandler();
|
|
2310
|
+
}
|
|
2311
|
+
});
|
|
2312
|
+
});
|
|
2313
|
+
observer.observe(swiper.el);
|
|
2314
|
+
};
|
|
2315
|
+
|
|
2316
|
+
const removeObserver = () => {
|
|
2317
|
+
if (animationFrame) {
|
|
2318
|
+
window.cancelAnimationFrame(animationFrame);
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
if (observer && observer.unobserve && swiper.el) {
|
|
2322
|
+
observer.unobserve(swiper.el);
|
|
2323
|
+
observer = null;
|
|
2324
|
+
}
|
|
2325
|
+
};
|
|
2326
|
+
|
|
2327
|
+
const orientationChangeHandler = () => {
|
|
2328
|
+
if (!swiper || swiper.destroyed || !swiper.initialized) return;
|
|
2329
|
+
emit('orientationchange');
|
|
2330
|
+
};
|
|
2331
|
+
|
|
2332
|
+
on('init', () => {
|
|
2333
|
+
if (swiper.params.resizeObserver && typeof window.ResizeObserver !== 'undefined') {
|
|
2334
|
+
createObserver();
|
|
2335
|
+
return;
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
window.addEventListener('resize', resizeHandler);
|
|
2339
|
+
window.addEventListener('orientationchange', orientationChangeHandler);
|
|
2340
|
+
});
|
|
2341
|
+
on('destroy', () => {
|
|
2342
|
+
removeObserver();
|
|
2343
|
+
window.removeEventListener('resize', resizeHandler);
|
|
2344
|
+
window.removeEventListener('orientationchange', orientationChangeHandler);
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
function Observer({
|
|
2349
|
+
swiper,
|
|
2350
|
+
extendParams,
|
|
2351
|
+
on,
|
|
2352
|
+
emit
|
|
2353
|
+
}) {
|
|
2354
|
+
const observers = [];
|
|
2355
|
+
const window = ssrWindow.getWindow();
|
|
2356
|
+
|
|
2357
|
+
const attach = (target, options = {}) => {
|
|
2358
|
+
const ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
|
|
2359
|
+
const observer = new ObserverFunc(mutations => {
|
|
2360
|
+
// The observerUpdate event should only be triggered
|
|
2361
|
+
// once despite the number of mutations. Additional
|
|
2362
|
+
// triggers are redundant and are very costly
|
|
2363
|
+
if (mutations.length === 1) {
|
|
2364
|
+
emit('observerUpdate', mutations[0]);
|
|
2365
|
+
return;
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
const observerUpdate = function observerUpdate() {
|
|
2369
|
+
emit('observerUpdate', mutations[0]);
|
|
2370
|
+
};
|
|
2371
|
+
|
|
2372
|
+
if (window.requestAnimationFrame) {
|
|
2373
|
+
window.requestAnimationFrame(observerUpdate);
|
|
2374
|
+
} else {
|
|
2375
|
+
window.setTimeout(observerUpdate, 0);
|
|
2376
|
+
}
|
|
2377
|
+
});
|
|
2378
|
+
observer.observe(target, {
|
|
2379
|
+
attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
|
|
2380
|
+
childList: typeof options.childList === 'undefined' ? true : options.childList,
|
|
2381
|
+
characterData: typeof options.characterData === 'undefined' ? true : options.characterData
|
|
2382
|
+
});
|
|
2383
|
+
observers.push(observer);
|
|
2384
|
+
};
|
|
2385
|
+
|
|
2386
|
+
const init = () => {
|
|
2387
|
+
if (!swiper.params.observer) return;
|
|
2388
|
+
|
|
2389
|
+
if (swiper.params.observeParents) {
|
|
2390
|
+
const containerParents = swiper.$el.parents();
|
|
2391
|
+
|
|
2392
|
+
for (let i = 0; i < containerParents.length; i += 1) {
|
|
2393
|
+
attach(containerParents[i]);
|
|
2394
|
+
}
|
|
2395
|
+
} // Observe container
|
|
2396
|
+
|
|
2397
|
+
|
|
2398
|
+
attach(swiper.$el[0], {
|
|
2399
|
+
childList: swiper.params.observeSlideChildren
|
|
2400
|
+
}); // Observe wrapper
|
|
2401
|
+
|
|
2402
|
+
attach(swiper.$wrapperEl[0], {
|
|
2403
|
+
attributes: false
|
|
2404
|
+
});
|
|
2405
|
+
};
|
|
2406
|
+
|
|
2407
|
+
const destroy = () => {
|
|
2408
|
+
observers.forEach(observer => {
|
|
2409
|
+
observer.disconnect();
|
|
2410
|
+
});
|
|
2411
|
+
observers.splice(0, observers.length);
|
|
2412
|
+
};
|
|
2413
|
+
|
|
2414
|
+
extendParams({
|
|
2415
|
+
observer: false,
|
|
2416
|
+
observeParents: false,
|
|
2417
|
+
observeSlideChildren: false
|
|
2418
|
+
});
|
|
2419
|
+
on('init', init);
|
|
2420
|
+
on('destroy', destroy);
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
/* eslint-disable no-underscore-dangle */
|
|
2424
|
+
var eventsEmitter = {
|
|
2425
|
+
on(events, handler, priority) {
|
|
2426
|
+
const self = this;
|
|
2427
|
+
if (!self.eventsListeners || self.destroyed) return self;
|
|
2428
|
+
if (typeof handler !== 'function') return self;
|
|
2429
|
+
const method = priority ? 'unshift' : 'push';
|
|
2430
|
+
events.split(' ').forEach(event => {
|
|
2431
|
+
if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
|
|
2432
|
+
self.eventsListeners[event][method](handler);
|
|
2433
|
+
});
|
|
2434
|
+
return self;
|
|
2435
|
+
},
|
|
2436
|
+
|
|
2437
|
+
once(events, handler, priority) {
|
|
2438
|
+
const self = this;
|
|
2439
|
+
if (!self.eventsListeners || self.destroyed) return self;
|
|
2440
|
+
if (typeof handler !== 'function') return self;
|
|
2441
|
+
|
|
2442
|
+
function onceHandler(...args) {
|
|
2443
|
+
self.off(events, onceHandler);
|
|
2444
|
+
|
|
2445
|
+
if (onceHandler.__emitterProxy) {
|
|
2446
|
+
delete onceHandler.__emitterProxy;
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
handler.apply(self, args);
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
onceHandler.__emitterProxy = handler;
|
|
2453
|
+
return self.on(events, onceHandler, priority);
|
|
2454
|
+
},
|
|
2455
|
+
|
|
2456
|
+
onAny(handler, priority) {
|
|
2457
|
+
const self = this;
|
|
2458
|
+
if (!self.eventsListeners || self.destroyed) return self;
|
|
2459
|
+
if (typeof handler !== 'function') return self;
|
|
2460
|
+
const method = priority ? 'unshift' : 'push';
|
|
2461
|
+
|
|
2462
|
+
if (self.eventsAnyListeners.indexOf(handler) < 0) {
|
|
2463
|
+
self.eventsAnyListeners[method](handler);
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
return self;
|
|
2467
|
+
},
|
|
2468
|
+
|
|
2469
|
+
offAny(handler) {
|
|
2470
|
+
const self = this;
|
|
2471
|
+
if (!self.eventsListeners || self.destroyed) return self;
|
|
2472
|
+
if (!self.eventsAnyListeners) return self;
|
|
2473
|
+
const index = self.eventsAnyListeners.indexOf(handler);
|
|
2474
|
+
|
|
2475
|
+
if (index >= 0) {
|
|
2476
|
+
self.eventsAnyListeners.splice(index, 1);
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
return self;
|
|
2480
|
+
},
|
|
2481
|
+
|
|
2482
|
+
off(events, handler) {
|
|
2483
|
+
const self = this;
|
|
2484
|
+
if (!self.eventsListeners || self.destroyed) return self;
|
|
2485
|
+
if (!self.eventsListeners) return self;
|
|
2486
|
+
events.split(' ').forEach(event => {
|
|
2487
|
+
if (typeof handler === 'undefined') {
|
|
2488
|
+
self.eventsListeners[event] = [];
|
|
2489
|
+
} else if (self.eventsListeners[event]) {
|
|
2490
|
+
self.eventsListeners[event].forEach((eventHandler, index) => {
|
|
2491
|
+
if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) {
|
|
2492
|
+
self.eventsListeners[event].splice(index, 1);
|
|
2493
|
+
}
|
|
2494
|
+
});
|
|
2495
|
+
}
|
|
2496
|
+
});
|
|
2497
|
+
return self;
|
|
2498
|
+
},
|
|
2499
|
+
|
|
2500
|
+
emit(...args) {
|
|
2501
|
+
const self = this;
|
|
2502
|
+
if (!self.eventsListeners || self.destroyed) return self;
|
|
2503
|
+
if (!self.eventsListeners) return self;
|
|
2504
|
+
let events;
|
|
2505
|
+
let data;
|
|
2506
|
+
let context;
|
|
2507
|
+
|
|
2508
|
+
if (typeof args[0] === 'string' || Array.isArray(args[0])) {
|
|
2509
|
+
events = args[0];
|
|
2510
|
+
data = args.slice(1, args.length);
|
|
2511
|
+
context = self;
|
|
2512
|
+
} else {
|
|
2513
|
+
events = args[0].events;
|
|
2514
|
+
data = args[0].data;
|
|
2515
|
+
context = args[0].context || self;
|
|
2516
|
+
}
|
|
2517
|
+
|
|
2518
|
+
data.unshift(context);
|
|
2519
|
+
const eventsArray = Array.isArray(events) ? events : events.split(' ');
|
|
2520
|
+
eventsArray.forEach(event => {
|
|
2521
|
+
if (self.eventsAnyListeners && self.eventsAnyListeners.length) {
|
|
2522
|
+
self.eventsAnyListeners.forEach(eventHandler => {
|
|
2523
|
+
eventHandler.apply(context, [event, ...data]);
|
|
2524
|
+
});
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
if (self.eventsListeners && self.eventsListeners[event]) {
|
|
2528
|
+
self.eventsListeners[event].forEach(eventHandler => {
|
|
2529
|
+
eventHandler.apply(context, data);
|
|
2530
|
+
});
|
|
2531
|
+
}
|
|
2532
|
+
});
|
|
2533
|
+
return self;
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
};
|
|
2537
|
+
|
|
2538
|
+
function updateSize() {
|
|
2539
|
+
const swiper = this;
|
|
2540
|
+
let width;
|
|
2541
|
+
let height;
|
|
2542
|
+
const $el = swiper.$el;
|
|
2543
|
+
|
|
2544
|
+
if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
|
|
2545
|
+
width = swiper.params.width;
|
|
2546
|
+
} else {
|
|
2547
|
+
width = $el[0].clientWidth;
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
|
|
2551
|
+
height = swiper.params.height;
|
|
2552
|
+
} else {
|
|
2553
|
+
height = $el[0].clientHeight;
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) {
|
|
2557
|
+
return;
|
|
2558
|
+
} // Subtract paddings
|
|
2559
|
+
|
|
2560
|
+
|
|
2561
|
+
width = width - parseInt($el.css('padding-left') || 0, 10) - parseInt($el.css('padding-right') || 0, 10);
|
|
2562
|
+
height = height - parseInt($el.css('padding-top') || 0, 10) - parseInt($el.css('padding-bottom') || 0, 10);
|
|
2563
|
+
if (Number.isNaN(width)) width = 0;
|
|
2564
|
+
if (Number.isNaN(height)) height = 0;
|
|
2565
|
+
Object.assign(swiper, {
|
|
2566
|
+
width,
|
|
2567
|
+
height,
|
|
2568
|
+
size: swiper.isHorizontal() ? width : height
|
|
2569
|
+
});
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
function updateSlides() {
|
|
2573
|
+
const swiper = this;
|
|
2574
|
+
|
|
2575
|
+
function getDirectionLabel(property) {
|
|
2576
|
+
if (swiper.isHorizontal()) {
|
|
2577
|
+
return property;
|
|
2578
|
+
} // prettier-ignore
|
|
2579
|
+
|
|
2580
|
+
|
|
2581
|
+
return {
|
|
2582
|
+
'width': 'height',
|
|
2583
|
+
'margin-top': 'margin-left',
|
|
2584
|
+
'margin-bottom ': 'margin-right',
|
|
2585
|
+
'margin-left': 'margin-top',
|
|
2586
|
+
'margin-right': 'margin-bottom',
|
|
2587
|
+
'padding-left': 'padding-top',
|
|
2588
|
+
'padding-right': 'padding-bottom',
|
|
2589
|
+
'marginRight': 'marginBottom'
|
|
2590
|
+
}[property];
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
function getDirectionPropertyValue(node, label) {
|
|
2594
|
+
return parseFloat(node.getPropertyValue(getDirectionLabel(label)) || 0);
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
const params = swiper.params;
|
|
2598
|
+
const {
|
|
2599
|
+
$wrapperEl,
|
|
2600
|
+
size: swiperSize,
|
|
2601
|
+
rtlTranslate: rtl,
|
|
2602
|
+
wrongRTL
|
|
2603
|
+
} = swiper;
|
|
2604
|
+
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
2605
|
+
const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
|
|
2606
|
+
const slides = $wrapperEl.children(`.${swiper.params.slideClass}`);
|
|
2607
|
+
const slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length;
|
|
2608
|
+
let snapGrid = [];
|
|
2609
|
+
const slidesGrid = [];
|
|
2610
|
+
const slidesSizesGrid = [];
|
|
2611
|
+
let offsetBefore = params.slidesOffsetBefore;
|
|
2612
|
+
|
|
2613
|
+
if (typeof offsetBefore === 'function') {
|
|
2614
|
+
offsetBefore = params.slidesOffsetBefore.call(swiper);
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
let offsetAfter = params.slidesOffsetAfter;
|
|
2618
|
+
|
|
2619
|
+
if (typeof offsetAfter === 'function') {
|
|
2620
|
+
offsetAfter = params.slidesOffsetAfter.call(swiper);
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
const previousSnapGridLength = swiper.snapGrid.length;
|
|
2624
|
+
const previousSlidesGridLength = swiper.slidesGrid.length;
|
|
2625
|
+
let spaceBetween = params.spaceBetween;
|
|
2626
|
+
let slidePosition = -offsetBefore;
|
|
2627
|
+
let prevSlideSize = 0;
|
|
2628
|
+
let index = 0;
|
|
2629
|
+
|
|
2630
|
+
if (typeof swiperSize === 'undefined') {
|
|
2631
|
+
return;
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
|
2635
|
+
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
swiper.virtualSize = -spaceBetween; // reset margins
|
|
2639
|
+
|
|
2640
|
+
if (rtl) slides.css({
|
|
2641
|
+
marginLeft: '',
|
|
2642
|
+
marginBottom: '',
|
|
2643
|
+
marginTop: ''
|
|
2644
|
+
});else slides.css({
|
|
2645
|
+
marginRight: '',
|
|
2646
|
+
marginBottom: '',
|
|
2647
|
+
marginTop: ''
|
|
2648
|
+
}); // reset cssMode offsets
|
|
2649
|
+
|
|
2650
|
+
if (params.centeredSlides && params.cssMode) {
|
|
2651
|
+
setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-before', '');
|
|
2652
|
+
setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-after', '');
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
|
|
2656
|
+
|
|
2657
|
+
if (gridEnabled) {
|
|
2658
|
+
swiper.grid.initSlides(slidesLength);
|
|
2659
|
+
} // Calc slides
|
|
2660
|
+
|
|
2661
|
+
|
|
2662
|
+
let slideSize;
|
|
2663
|
+
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => {
|
|
2664
|
+
return typeof params.breakpoints[key].slidesPerView !== 'undefined';
|
|
2665
|
+
}).length > 0;
|
|
2666
|
+
|
|
2667
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
2668
|
+
slideSize = 0;
|
|
2669
|
+
const slide = slides.eq(i);
|
|
2670
|
+
|
|
2671
|
+
if (gridEnabled) {
|
|
2672
|
+
swiper.grid.updateSlide(i, slide, slidesLength, getDirectionLabel);
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
if (slide.css('display') === 'none') continue; // eslint-disable-line
|
|
2676
|
+
|
|
2677
|
+
if (params.slidesPerView === 'auto') {
|
|
2678
|
+
if (shouldResetSlideSize) {
|
|
2679
|
+
slides[i].style[getDirectionLabel('width')] = ``;
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
const slideStyles = getComputedStyle(slide[0]);
|
|
2683
|
+
const currentTransform = slide[0].style.transform;
|
|
2684
|
+
const currentWebKitTransform = slide[0].style.webkitTransform;
|
|
2685
|
+
|
|
2686
|
+
if (currentTransform) {
|
|
2687
|
+
slide[0].style.transform = 'none';
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
if (currentWebKitTransform) {
|
|
2691
|
+
slide[0].style.webkitTransform = 'none';
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
if (params.roundLengths) {
|
|
2695
|
+
slideSize = swiper.isHorizontal() ? slide.outerWidth(true) : slide.outerHeight(true);
|
|
2696
|
+
} else {
|
|
2697
|
+
// eslint-disable-next-line
|
|
2698
|
+
const width = getDirectionPropertyValue(slideStyles, 'width');
|
|
2699
|
+
const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left');
|
|
2700
|
+
const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right');
|
|
2701
|
+
const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
|
|
2702
|
+
const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
|
|
2703
|
+
const boxSizing = slideStyles.getPropertyValue('box-sizing');
|
|
2704
|
+
|
|
2705
|
+
if (boxSizing && boxSizing === 'border-box') {
|
|
2706
|
+
slideSize = width + marginLeft + marginRight;
|
|
2707
|
+
} else {
|
|
2708
|
+
const {
|
|
2709
|
+
clientWidth,
|
|
2710
|
+
offsetWidth
|
|
2711
|
+
} = slide[0];
|
|
2712
|
+
slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
if (currentTransform) {
|
|
2717
|
+
slide[0].style.transform = currentTransform;
|
|
2718
|
+
}
|
|
2719
|
+
|
|
2720
|
+
if (currentWebKitTransform) {
|
|
2721
|
+
slide[0].style.webkitTransform = currentWebKitTransform;
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
|
2725
|
+
} else {
|
|
2726
|
+
slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
|
2727
|
+
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
|
2728
|
+
|
|
2729
|
+
if (slides[i]) {
|
|
2730
|
+
slides[i].style[getDirectionLabel('width')] = `${slideSize}px`;
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
if (slides[i]) {
|
|
2735
|
+
slides[i].swiperSlideSize = slideSize;
|
|
2736
|
+
}
|
|
2737
|
+
|
|
2738
|
+
slidesSizesGrid.push(slideSize);
|
|
2739
|
+
|
|
2740
|
+
if (params.centeredSlides) {
|
|
2741
|
+
slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
|
|
2742
|
+
if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
2743
|
+
if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
2744
|
+
if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
|
|
2745
|
+
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
2746
|
+
if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition);
|
|
2747
|
+
slidesGrid.push(slidePosition);
|
|
2748
|
+
} else {
|
|
2749
|
+
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
2750
|
+
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition);
|
|
2751
|
+
slidesGrid.push(slidePosition);
|
|
2752
|
+
slidePosition = slidePosition + slideSize + spaceBetween;
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
swiper.virtualSize += slideSize + spaceBetween;
|
|
2756
|
+
prevSlideSize = slideSize;
|
|
2757
|
+
index += 1;
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter;
|
|
2761
|
+
|
|
2762
|
+
if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) {
|
|
2763
|
+
$wrapperEl.css({
|
|
2764
|
+
width: `${swiper.virtualSize + params.spaceBetween}px`
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2767
|
+
|
|
2768
|
+
if (params.setWrapperSize) {
|
|
2769
|
+
$wrapperEl.css({
|
|
2770
|
+
[getDirectionLabel('width')]: `${swiper.virtualSize + params.spaceBetween}px`
|
|
2771
|
+
});
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
if (gridEnabled) {
|
|
2775
|
+
swiper.grid.updateWrapperSize(slideSize, snapGrid, getDirectionLabel);
|
|
2776
|
+
} // Remove last grid elements depending on width
|
|
2777
|
+
|
|
2778
|
+
|
|
2779
|
+
if (!params.centeredSlides) {
|
|
2780
|
+
const newSlidesGrid = [];
|
|
2781
|
+
|
|
2782
|
+
for (let i = 0; i < snapGrid.length; i += 1) {
|
|
2783
|
+
let slidesGridItem = snapGrid[i];
|
|
2784
|
+
if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
|
2785
|
+
|
|
2786
|
+
if (snapGrid[i] <= swiper.virtualSize - swiperSize) {
|
|
2787
|
+
newSlidesGrid.push(slidesGridItem);
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
snapGrid = newSlidesGrid;
|
|
2792
|
+
|
|
2793
|
+
if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
|
2794
|
+
snapGrid.push(swiper.virtualSize - swiperSize);
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2798
|
+
if (snapGrid.length === 0) snapGrid = [0];
|
|
2799
|
+
|
|
2800
|
+
if (params.spaceBetween !== 0) {
|
|
2801
|
+
const key = swiper.isHorizontal() && rtl ? 'marginLeft' : getDirectionLabel('marginRight');
|
|
2802
|
+
slides.filter((_, slideIndex) => {
|
|
2803
|
+
if (!params.cssMode) return true;
|
|
2804
|
+
|
|
2805
|
+
if (slideIndex === slides.length - 1) {
|
|
2806
|
+
return false;
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
return true;
|
|
2810
|
+
}).css({
|
|
2811
|
+
[key]: `${spaceBetween}px`
|
|
2812
|
+
});
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
if (params.centeredSlides && params.centeredSlidesBounds) {
|
|
2816
|
+
let allSlidesSize = 0;
|
|
2817
|
+
slidesSizesGrid.forEach(slideSizeValue => {
|
|
2818
|
+
allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0);
|
|
2819
|
+
});
|
|
2820
|
+
allSlidesSize -= params.spaceBetween;
|
|
2821
|
+
const maxSnap = allSlidesSize - swiperSize;
|
|
2822
|
+
snapGrid = snapGrid.map(snap => {
|
|
2823
|
+
if (snap < 0) return -offsetBefore;
|
|
2824
|
+
if (snap > maxSnap) return maxSnap + offsetAfter;
|
|
2825
|
+
return snap;
|
|
2826
|
+
});
|
|
2827
|
+
}
|
|
2828
|
+
|
|
2829
|
+
if (params.centerInsufficientSlides) {
|
|
2830
|
+
let allSlidesSize = 0;
|
|
2831
|
+
slidesSizesGrid.forEach(slideSizeValue => {
|
|
2832
|
+
allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0);
|
|
2833
|
+
});
|
|
2834
|
+
allSlidesSize -= params.spaceBetween;
|
|
2835
|
+
|
|
2836
|
+
if (allSlidesSize < swiperSize) {
|
|
2837
|
+
const allSlidesOffset = (swiperSize - allSlidesSize) / 2;
|
|
2838
|
+
snapGrid.forEach((snap, snapIndex) => {
|
|
2839
|
+
snapGrid[snapIndex] = snap - allSlidesOffset;
|
|
2840
|
+
});
|
|
2841
|
+
slidesGrid.forEach((snap, snapIndex) => {
|
|
2842
|
+
slidesGrid[snapIndex] = snap + allSlidesOffset;
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
Object.assign(swiper, {
|
|
2848
|
+
slides,
|
|
2849
|
+
snapGrid,
|
|
2850
|
+
slidesGrid,
|
|
2851
|
+
slidesSizesGrid
|
|
2852
|
+
});
|
|
2853
|
+
|
|
2854
|
+
if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) {
|
|
2855
|
+
setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-before', `${-snapGrid[0]}px`);
|
|
2856
|
+
setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-after', `${swiper.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`);
|
|
2857
|
+
const addToSnapGrid = -swiper.snapGrid[0];
|
|
2858
|
+
const addToSlidesGrid = -swiper.slidesGrid[0];
|
|
2859
|
+
swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
|
|
2860
|
+
swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
if (slidesLength !== previousSlidesLength) {
|
|
2864
|
+
swiper.emit('slidesLengthChange');
|
|
2865
|
+
}
|
|
2866
|
+
|
|
2867
|
+
if (snapGrid.length !== previousSnapGridLength) {
|
|
2868
|
+
if (swiper.params.watchOverflow) swiper.checkOverflow();
|
|
2869
|
+
swiper.emit('snapGridLengthChange');
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
if (slidesGrid.length !== previousSlidesGridLength) {
|
|
2873
|
+
swiper.emit('slidesGridLengthChange');
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
if (params.watchSlidesProgress) {
|
|
2877
|
+
swiper.updateSlidesOffset();
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
if (!isVirtual && !params.cssMode && (params.effect === 'slide' || params.effect === 'fade')) {
|
|
2881
|
+
const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
|
|
2882
|
+
const hasClassBackfaceClassAdded = swiper.$el.hasClass(backFaceHiddenClass);
|
|
2883
|
+
|
|
2884
|
+
if (slidesLength <= params.maxBackfaceHiddenSlides) {
|
|
2885
|
+
if (!hasClassBackfaceClassAdded) swiper.$el.addClass(backFaceHiddenClass);
|
|
2886
|
+
} else if (hasClassBackfaceClassAdded) {
|
|
2887
|
+
swiper.$el.removeClass(backFaceHiddenClass);
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
function updateAutoHeight(speed) {
|
|
2893
|
+
const swiper = this;
|
|
2894
|
+
const activeSlides = [];
|
|
2895
|
+
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
2896
|
+
let newHeight = 0;
|
|
2897
|
+
let i;
|
|
2898
|
+
|
|
2899
|
+
if (typeof speed === 'number') {
|
|
2900
|
+
swiper.setTransition(speed);
|
|
2901
|
+
} else if (speed === true) {
|
|
2902
|
+
swiper.setTransition(swiper.params.speed);
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2905
|
+
const getSlideByIndex = index => {
|
|
2906
|
+
if (isVirtual) {
|
|
2907
|
+
return swiper.slides.filter(el => parseInt(el.getAttribute('data-swiper-slide-index'), 10) === index)[0];
|
|
2908
|
+
}
|
|
2909
|
+
|
|
2910
|
+
return swiper.slides.eq(index)[0];
|
|
2911
|
+
}; // Find slides currently in view
|
|
2912
|
+
|
|
2913
|
+
|
|
2914
|
+
if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
|
|
2915
|
+
if (swiper.params.centeredSlides) {
|
|
2916
|
+
(swiper.visibleSlides || dom7.$([])).each(slide => {
|
|
2917
|
+
activeSlides.push(slide);
|
|
2918
|
+
});
|
|
2919
|
+
} else {
|
|
2920
|
+
for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
2921
|
+
const index = swiper.activeIndex + i;
|
|
2922
|
+
if (index > swiper.slides.length && !isVirtual) break;
|
|
2923
|
+
activeSlides.push(getSlideByIndex(index));
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
} else {
|
|
2927
|
+
activeSlides.push(getSlideByIndex(swiper.activeIndex));
|
|
2928
|
+
} // Find new height from highest slide in view
|
|
2929
|
+
|
|
2930
|
+
|
|
2931
|
+
for (i = 0; i < activeSlides.length; i += 1) {
|
|
2932
|
+
if (typeof activeSlides[i] !== 'undefined') {
|
|
2933
|
+
const height = activeSlides[i].offsetHeight;
|
|
2934
|
+
newHeight = height > newHeight ? height : newHeight;
|
|
2935
|
+
}
|
|
2936
|
+
} // Update Height
|
|
2937
|
+
|
|
2938
|
+
|
|
2939
|
+
if (newHeight || newHeight === 0) swiper.$wrapperEl.css('height', `${newHeight}px`);
|
|
2940
|
+
}
|
|
2941
|
+
|
|
2942
|
+
function updateSlidesOffset() {
|
|
2943
|
+
const swiper = this;
|
|
2944
|
+
const slides = swiper.slides;
|
|
2945
|
+
|
|
2946
|
+
for (let i = 0; i < slides.length; i += 1) {
|
|
2947
|
+
slides[i].swiperSlideOffset = swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop;
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2950
|
+
|
|
2951
|
+
function updateSlidesProgress(translate = this && this.translate || 0) {
|
|
2952
|
+
const swiper = this;
|
|
2953
|
+
const params = swiper.params;
|
|
2954
|
+
const {
|
|
2955
|
+
slides,
|
|
2956
|
+
rtlTranslate: rtl,
|
|
2957
|
+
snapGrid
|
|
2958
|
+
} = swiper;
|
|
2959
|
+
if (slides.length === 0) return;
|
|
2960
|
+
if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset();
|
|
2961
|
+
let offsetCenter = -translate;
|
|
2962
|
+
if (rtl) offsetCenter = translate; // Visible Slides
|
|
2963
|
+
|
|
2964
|
+
slides.removeClass(params.slideVisibleClass);
|
|
2965
|
+
swiper.visibleSlidesIndexes = [];
|
|
2966
|
+
swiper.visibleSlides = [];
|
|
2967
|
+
|
|
2968
|
+
for (let i = 0; i < slides.length; i += 1) {
|
|
2969
|
+
const slide = slides[i];
|
|
2970
|
+
let slideOffset = slide.swiperSlideOffset;
|
|
2971
|
+
|
|
2972
|
+
if (params.cssMode && params.centeredSlides) {
|
|
2973
|
+
slideOffset -= slides[0].swiperSlideOffset;
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2976
|
+
const slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + params.spaceBetween);
|
|
2977
|
+
const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + params.spaceBetween);
|
|
2978
|
+
const slideBefore = -(offsetCenter - slideOffset);
|
|
2979
|
+
const slideAfter = slideBefore + swiper.slidesSizesGrid[i];
|
|
2980
|
+
const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size;
|
|
2981
|
+
|
|
2982
|
+
if (isVisible) {
|
|
2983
|
+
swiper.visibleSlides.push(slide);
|
|
2984
|
+
swiper.visibleSlidesIndexes.push(i);
|
|
2985
|
+
slides.eq(i).addClass(params.slideVisibleClass);
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
slide.progress = rtl ? -slideProgress : slideProgress;
|
|
2989
|
+
slide.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
swiper.visibleSlides = dom7.$(swiper.visibleSlides);
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2995
|
+
function updateProgress(translate) {
|
|
2996
|
+
const swiper = this;
|
|
2997
|
+
|
|
2998
|
+
if (typeof translate === 'undefined') {
|
|
2999
|
+
const multiplier = swiper.rtlTranslate ? -1 : 1; // eslint-disable-next-line
|
|
3000
|
+
|
|
3001
|
+
translate = swiper && swiper.translate && swiper.translate * multiplier || 0;
|
|
3002
|
+
}
|
|
3003
|
+
|
|
3004
|
+
const params = swiper.params;
|
|
3005
|
+
const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
|
3006
|
+
let {
|
|
3007
|
+
progress,
|
|
3008
|
+
isBeginning,
|
|
3009
|
+
isEnd
|
|
3010
|
+
} = swiper;
|
|
3011
|
+
const wasBeginning = isBeginning;
|
|
3012
|
+
const wasEnd = isEnd;
|
|
3013
|
+
|
|
3014
|
+
if (translatesDiff === 0) {
|
|
3015
|
+
progress = 0;
|
|
3016
|
+
isBeginning = true;
|
|
3017
|
+
isEnd = true;
|
|
3018
|
+
} else {
|
|
3019
|
+
progress = (translate - swiper.minTranslate()) / translatesDiff;
|
|
3020
|
+
isBeginning = progress <= 0;
|
|
3021
|
+
isEnd = progress >= 1;
|
|
3022
|
+
}
|
|
3023
|
+
|
|
3024
|
+
Object.assign(swiper, {
|
|
3025
|
+
progress,
|
|
3026
|
+
isBeginning,
|
|
3027
|
+
isEnd
|
|
3028
|
+
});
|
|
3029
|
+
if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate);
|
|
3030
|
+
|
|
3031
|
+
if (isBeginning && !wasBeginning) {
|
|
3032
|
+
swiper.emit('reachBeginning toEdge');
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
if (isEnd && !wasEnd) {
|
|
3036
|
+
swiper.emit('reachEnd toEdge');
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
if (wasBeginning && !isBeginning || wasEnd && !isEnd) {
|
|
3040
|
+
swiper.emit('fromEdge');
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3043
|
+
swiper.emit('progress', progress);
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
function updateSlidesClasses() {
|
|
3047
|
+
const swiper = this;
|
|
3048
|
+
const {
|
|
3049
|
+
slides,
|
|
3050
|
+
params,
|
|
3051
|
+
$wrapperEl,
|
|
3052
|
+
activeIndex,
|
|
3053
|
+
realIndex
|
|
3054
|
+
} = swiper;
|
|
3055
|
+
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
3056
|
+
slides.removeClass(`${params.slideActiveClass} ${params.slideNextClass} ${params.slidePrevClass} ${params.slideDuplicateActiveClass} ${params.slideDuplicateNextClass} ${params.slideDuplicatePrevClass}`);
|
|
3057
|
+
let activeSlide;
|
|
3058
|
+
|
|
3059
|
+
if (isVirtual) {
|
|
3060
|
+
activeSlide = swiper.$wrapperEl.find(`.${params.slideClass}[data-swiper-slide-index="${activeIndex}"]`);
|
|
3061
|
+
} else {
|
|
3062
|
+
activeSlide = slides.eq(activeIndex);
|
|
3063
|
+
} // Active classes
|
|
3064
|
+
|
|
3065
|
+
|
|
3066
|
+
activeSlide.addClass(params.slideActiveClass);
|
|
3067
|
+
|
|
3068
|
+
if (params.loop) {
|
|
3069
|
+
// Duplicate to all looped slides
|
|
3070
|
+
if (activeSlide.hasClass(params.slideDuplicateClass)) {
|
|
3071
|
+
$wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${realIndex}"]`).addClass(params.slideDuplicateActiveClass);
|
|
3072
|
+
} else {
|
|
3073
|
+
$wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${realIndex}"]`).addClass(params.slideDuplicateActiveClass);
|
|
3074
|
+
}
|
|
3075
|
+
} // Next Slide
|
|
3076
|
+
|
|
3077
|
+
|
|
3078
|
+
let nextSlide = activeSlide.nextAll(`.${params.slideClass}`).eq(0).addClass(params.slideNextClass);
|
|
3079
|
+
|
|
3080
|
+
if (params.loop && nextSlide.length === 0) {
|
|
3081
|
+
nextSlide = slides.eq(0);
|
|
3082
|
+
nextSlide.addClass(params.slideNextClass);
|
|
3083
|
+
} // Prev Slide
|
|
3084
|
+
|
|
3085
|
+
|
|
3086
|
+
let prevSlide = activeSlide.prevAll(`.${params.slideClass}`).eq(0).addClass(params.slidePrevClass);
|
|
3087
|
+
|
|
3088
|
+
if (params.loop && prevSlide.length === 0) {
|
|
3089
|
+
prevSlide = slides.eq(-1);
|
|
3090
|
+
prevSlide.addClass(params.slidePrevClass);
|
|
3091
|
+
}
|
|
3092
|
+
|
|
3093
|
+
if (params.loop) {
|
|
3094
|
+
// Duplicate to all looped slides
|
|
3095
|
+
if (nextSlide.hasClass(params.slideDuplicateClass)) {
|
|
3096
|
+
$wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${nextSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicateNextClass);
|
|
3097
|
+
} else {
|
|
3098
|
+
$wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${nextSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicateNextClass);
|
|
3099
|
+
}
|
|
3100
|
+
|
|
3101
|
+
if (prevSlide.hasClass(params.slideDuplicateClass)) {
|
|
3102
|
+
$wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${prevSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicatePrevClass);
|
|
3103
|
+
} else {
|
|
3104
|
+
$wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${prevSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicatePrevClass);
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
swiper.emitSlidesClasses();
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
function updateActiveIndex(newActiveIndex) {
|
|
3112
|
+
const swiper = this;
|
|
3113
|
+
const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
|
|
3114
|
+
const {
|
|
3115
|
+
slidesGrid,
|
|
3116
|
+
snapGrid,
|
|
3117
|
+
params,
|
|
3118
|
+
activeIndex: previousIndex,
|
|
3119
|
+
realIndex: previousRealIndex,
|
|
3120
|
+
snapIndex: previousSnapIndex
|
|
3121
|
+
} = swiper;
|
|
3122
|
+
let activeIndex = newActiveIndex;
|
|
3123
|
+
let snapIndex;
|
|
3124
|
+
|
|
3125
|
+
if (typeof activeIndex === 'undefined') {
|
|
3126
|
+
for (let i = 0; i < slidesGrid.length; i += 1) {
|
|
3127
|
+
if (typeof slidesGrid[i + 1] !== 'undefined') {
|
|
3128
|
+
if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) {
|
|
3129
|
+
activeIndex = i;
|
|
3130
|
+
} else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) {
|
|
3131
|
+
activeIndex = i + 1;
|
|
3132
|
+
}
|
|
3133
|
+
} else if (translate >= slidesGrid[i]) {
|
|
3134
|
+
activeIndex = i;
|
|
3135
|
+
}
|
|
3136
|
+
} // Normalize slideIndex
|
|
3137
|
+
|
|
3138
|
+
|
|
3139
|
+
if (params.normalizeSlideIndex) {
|
|
3140
|
+
if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
|
|
3144
|
+
if (snapGrid.indexOf(translate) >= 0) {
|
|
3145
|
+
snapIndex = snapGrid.indexOf(translate);
|
|
3146
|
+
} else {
|
|
3147
|
+
const skip = Math.min(params.slidesPerGroupSkip, activeIndex);
|
|
3148
|
+
snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
|
|
3149
|
+
}
|
|
3150
|
+
|
|
3151
|
+
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
|
3152
|
+
|
|
3153
|
+
if (activeIndex === previousIndex) {
|
|
3154
|
+
if (snapIndex !== previousSnapIndex) {
|
|
3155
|
+
swiper.snapIndex = snapIndex;
|
|
3156
|
+
swiper.emit('snapIndexChange');
|
|
3157
|
+
}
|
|
3158
|
+
|
|
3159
|
+
return;
|
|
3160
|
+
} // Get real index
|
|
3161
|
+
|
|
3162
|
+
|
|
3163
|
+
const realIndex = parseInt(swiper.slides.eq(activeIndex).attr('data-swiper-slide-index') || activeIndex, 10);
|
|
3164
|
+
Object.assign(swiper, {
|
|
3165
|
+
snapIndex,
|
|
3166
|
+
realIndex,
|
|
3167
|
+
previousIndex,
|
|
3168
|
+
activeIndex
|
|
3169
|
+
});
|
|
3170
|
+
swiper.emit('activeIndexChange');
|
|
3171
|
+
swiper.emit('snapIndexChange');
|
|
3172
|
+
|
|
3173
|
+
if (previousRealIndex !== realIndex) {
|
|
3174
|
+
swiper.emit('realIndexChange');
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3177
|
+
if (swiper.initialized || swiper.params.runCallbacksOnInit) {
|
|
3178
|
+
swiper.emit('slideChange');
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
|
|
3182
|
+
function updateClickedSlide(e) {
|
|
3183
|
+
const swiper = this;
|
|
3184
|
+
const params = swiper.params;
|
|
3185
|
+
const slide = dom7.$(e).closest(`.${params.slideClass}`)[0];
|
|
3186
|
+
let slideFound = false;
|
|
3187
|
+
let slideIndex;
|
|
3188
|
+
|
|
3189
|
+
if (slide) {
|
|
3190
|
+
for (let i = 0; i < swiper.slides.length; i += 1) {
|
|
3191
|
+
if (swiper.slides[i] === slide) {
|
|
3192
|
+
slideFound = true;
|
|
3193
|
+
slideIndex = i;
|
|
3194
|
+
break;
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
if (slide && slideFound) {
|
|
3200
|
+
swiper.clickedSlide = slide;
|
|
3201
|
+
|
|
3202
|
+
if (swiper.virtual && swiper.params.virtual.enabled) {
|
|
3203
|
+
swiper.clickedIndex = parseInt(dom7.$(slide).attr('data-swiper-slide-index'), 10);
|
|
3204
|
+
} else {
|
|
3205
|
+
swiper.clickedIndex = slideIndex;
|
|
3206
|
+
}
|
|
3207
|
+
} else {
|
|
3208
|
+
swiper.clickedSlide = undefined;
|
|
3209
|
+
swiper.clickedIndex = undefined;
|
|
3210
|
+
return;
|
|
3211
|
+
}
|
|
3212
|
+
|
|
3213
|
+
if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) {
|
|
3214
|
+
swiper.slideToClickedSlide();
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
var update = {
|
|
3219
|
+
updateSize,
|
|
3220
|
+
updateSlides,
|
|
3221
|
+
updateAutoHeight,
|
|
3222
|
+
updateSlidesOffset,
|
|
3223
|
+
updateSlidesProgress,
|
|
3224
|
+
updateProgress,
|
|
3225
|
+
updateSlidesClasses,
|
|
3226
|
+
updateActiveIndex,
|
|
3227
|
+
updateClickedSlide
|
|
3228
|
+
};
|
|
3229
|
+
|
|
3230
|
+
function getSwiperTranslate(axis = this.isHorizontal() ? 'x' : 'y') {
|
|
3231
|
+
const swiper = this;
|
|
3232
|
+
const {
|
|
3233
|
+
params,
|
|
3234
|
+
rtlTranslate: rtl,
|
|
3235
|
+
translate,
|
|
3236
|
+
$wrapperEl
|
|
3237
|
+
} = swiper;
|
|
3238
|
+
|
|
3239
|
+
if (params.virtualTranslate) {
|
|
3240
|
+
return rtl ? -translate : translate;
|
|
3241
|
+
}
|
|
3242
|
+
|
|
3243
|
+
if (params.cssMode) {
|
|
3244
|
+
return translate;
|
|
3245
|
+
}
|
|
3246
|
+
|
|
3247
|
+
let currentTranslate = getTranslate($wrapperEl[0], axis);
|
|
3248
|
+
if (rtl) currentTranslate = -currentTranslate;
|
|
3249
|
+
return currentTranslate || 0;
|
|
3250
|
+
}
|
|
3251
|
+
|
|
3252
|
+
function setTranslate(translate, byController) {
|
|
3253
|
+
const swiper = this;
|
|
3254
|
+
const {
|
|
3255
|
+
rtlTranslate: rtl,
|
|
3256
|
+
params,
|
|
3257
|
+
$wrapperEl,
|
|
3258
|
+
wrapperEl,
|
|
3259
|
+
progress
|
|
3260
|
+
} = swiper;
|
|
3261
|
+
let x = 0;
|
|
3262
|
+
let y = 0;
|
|
3263
|
+
const z = 0;
|
|
3264
|
+
|
|
3265
|
+
if (swiper.isHorizontal()) {
|
|
3266
|
+
x = rtl ? -translate : translate;
|
|
3267
|
+
} else {
|
|
3268
|
+
y = translate;
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
if (params.roundLengths) {
|
|
3272
|
+
x = Math.floor(x);
|
|
3273
|
+
y = Math.floor(y);
|
|
3274
|
+
}
|
|
3275
|
+
|
|
3276
|
+
if (params.cssMode) {
|
|
3277
|
+
wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
|
|
3278
|
+
} else if (!params.virtualTranslate) {
|
|
3279
|
+
$wrapperEl.transform(`translate3d(${x}px, ${y}px, ${z}px)`);
|
|
3280
|
+
}
|
|
3281
|
+
|
|
3282
|
+
swiper.previousTranslate = swiper.translate;
|
|
3283
|
+
swiper.translate = swiper.isHorizontal() ? x : y; // Check if we need to update progress
|
|
3284
|
+
|
|
3285
|
+
let newProgress;
|
|
3286
|
+
const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
|
3287
|
+
|
|
3288
|
+
if (translatesDiff === 0) {
|
|
3289
|
+
newProgress = 0;
|
|
3290
|
+
} else {
|
|
3291
|
+
newProgress = (translate - swiper.minTranslate()) / translatesDiff;
|
|
3292
|
+
}
|
|
3293
|
+
|
|
3294
|
+
if (newProgress !== progress) {
|
|
3295
|
+
swiper.updateProgress(translate);
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3298
|
+
swiper.emit('setTranslate', swiper.translate, byController);
|
|
3299
|
+
}
|
|
3300
|
+
|
|
3301
|
+
function minTranslate() {
|
|
3302
|
+
return -this.snapGrid[0];
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3305
|
+
function maxTranslate() {
|
|
3306
|
+
return -this.snapGrid[this.snapGrid.length - 1];
|
|
3307
|
+
}
|
|
3308
|
+
|
|
3309
|
+
function translateTo(translate = 0, speed = this.params.speed, runCallbacks = true, translateBounds = true, internal) {
|
|
3310
|
+
const swiper = this;
|
|
3311
|
+
const {
|
|
3312
|
+
params,
|
|
3313
|
+
wrapperEl
|
|
3314
|
+
} = swiper;
|
|
3315
|
+
|
|
3316
|
+
if (swiper.animating && params.preventInteractionOnTransition) {
|
|
3317
|
+
return false;
|
|
3318
|
+
}
|
|
3319
|
+
|
|
3320
|
+
const minTranslate = swiper.minTranslate();
|
|
3321
|
+
const maxTranslate = swiper.maxTranslate();
|
|
3322
|
+
let newTranslate;
|
|
3323
|
+
if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate; // Update progress
|
|
3324
|
+
|
|
3325
|
+
swiper.updateProgress(newTranslate);
|
|
3326
|
+
|
|
3327
|
+
if (params.cssMode) {
|
|
3328
|
+
const isH = swiper.isHorizontal();
|
|
3329
|
+
|
|
3330
|
+
if (speed === 0) {
|
|
3331
|
+
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate;
|
|
3332
|
+
} else {
|
|
3333
|
+
if (!swiper.support.smoothScroll) {
|
|
3334
|
+
animateCSSModeScroll({
|
|
3335
|
+
swiper,
|
|
3336
|
+
targetPosition: -newTranslate,
|
|
3337
|
+
side: isH ? 'left' : 'top'
|
|
3338
|
+
});
|
|
3339
|
+
return true;
|
|
3340
|
+
}
|
|
3341
|
+
|
|
3342
|
+
wrapperEl.scrollTo({
|
|
3343
|
+
[isH ? 'left' : 'top']: -newTranslate,
|
|
3344
|
+
behavior: 'smooth'
|
|
3345
|
+
});
|
|
3346
|
+
}
|
|
3347
|
+
|
|
3348
|
+
return true;
|
|
3349
|
+
}
|
|
3350
|
+
|
|
3351
|
+
if (speed === 0) {
|
|
3352
|
+
swiper.setTransition(0);
|
|
3353
|
+
swiper.setTranslate(newTranslate);
|
|
3354
|
+
|
|
3355
|
+
if (runCallbacks) {
|
|
3356
|
+
swiper.emit('beforeTransitionStart', speed, internal);
|
|
3357
|
+
swiper.emit('transitionEnd');
|
|
3358
|
+
}
|
|
3359
|
+
} else {
|
|
3360
|
+
swiper.setTransition(speed);
|
|
3361
|
+
swiper.setTranslate(newTranslate);
|
|
3362
|
+
|
|
3363
|
+
if (runCallbacks) {
|
|
3364
|
+
swiper.emit('beforeTransitionStart', speed, internal);
|
|
3365
|
+
swiper.emit('transitionStart');
|
|
3366
|
+
}
|
|
3367
|
+
|
|
3368
|
+
if (!swiper.animating) {
|
|
3369
|
+
swiper.animating = true;
|
|
3370
|
+
|
|
3371
|
+
if (!swiper.onTranslateToWrapperTransitionEnd) {
|
|
3372
|
+
swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) {
|
|
3373
|
+
if (!swiper || swiper.destroyed) return;
|
|
3374
|
+
if (e.target !== this) return;
|
|
3375
|
+
swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
|
|
3376
|
+
swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd);
|
|
3377
|
+
swiper.onTranslateToWrapperTransitionEnd = null;
|
|
3378
|
+
delete swiper.onTranslateToWrapperTransitionEnd;
|
|
3379
|
+
|
|
3380
|
+
if (runCallbacks) {
|
|
3381
|
+
swiper.emit('transitionEnd');
|
|
3382
|
+
}
|
|
3383
|
+
};
|
|
3384
|
+
}
|
|
3385
|
+
|
|
3386
|
+
swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
|
|
3387
|
+
swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd);
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3390
|
+
|
|
3391
|
+
return true;
|
|
3392
|
+
}
|
|
3393
|
+
|
|
3394
|
+
var translate = {
|
|
3395
|
+
getTranslate: getSwiperTranslate,
|
|
3396
|
+
setTranslate,
|
|
3397
|
+
minTranslate,
|
|
3398
|
+
maxTranslate,
|
|
3399
|
+
translateTo
|
|
3400
|
+
};
|
|
3401
|
+
|
|
3402
|
+
function setTransition(duration, byController) {
|
|
3403
|
+
const swiper = this;
|
|
3404
|
+
|
|
3405
|
+
if (!swiper.params.cssMode) {
|
|
3406
|
+
swiper.$wrapperEl.transition(duration);
|
|
3407
|
+
}
|
|
3408
|
+
|
|
3409
|
+
swiper.emit('setTransition', duration, byController);
|
|
3410
|
+
}
|
|
3411
|
+
|
|
3412
|
+
function transitionEmit({
|
|
3413
|
+
swiper,
|
|
3414
|
+
runCallbacks,
|
|
3415
|
+
direction,
|
|
3416
|
+
step
|
|
3417
|
+
}) {
|
|
3418
|
+
const {
|
|
3419
|
+
activeIndex,
|
|
3420
|
+
previousIndex
|
|
3421
|
+
} = swiper;
|
|
3422
|
+
let dir = direction;
|
|
3423
|
+
|
|
3424
|
+
if (!dir) {
|
|
3425
|
+
if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset';
|
|
3426
|
+
}
|
|
3427
|
+
|
|
3428
|
+
swiper.emit(`transition${step}`);
|
|
3429
|
+
|
|
3430
|
+
if (runCallbacks && activeIndex !== previousIndex) {
|
|
3431
|
+
if (dir === 'reset') {
|
|
3432
|
+
swiper.emit(`slideResetTransition${step}`);
|
|
3433
|
+
return;
|
|
3434
|
+
}
|
|
3435
|
+
|
|
3436
|
+
swiper.emit(`slideChangeTransition${step}`);
|
|
3437
|
+
|
|
3438
|
+
if (dir === 'next') {
|
|
3439
|
+
swiper.emit(`slideNextTransition${step}`);
|
|
3440
|
+
} else {
|
|
3441
|
+
swiper.emit(`slidePrevTransition${step}`);
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
|
|
3446
|
+
function transitionStart(runCallbacks = true, direction) {
|
|
3447
|
+
const swiper = this;
|
|
3448
|
+
const {
|
|
3449
|
+
params
|
|
3450
|
+
} = swiper;
|
|
3451
|
+
if (params.cssMode) return;
|
|
3452
|
+
|
|
3453
|
+
if (params.autoHeight) {
|
|
3454
|
+
swiper.updateAutoHeight();
|
|
3455
|
+
}
|
|
3456
|
+
|
|
3457
|
+
transitionEmit({
|
|
3458
|
+
swiper,
|
|
3459
|
+
runCallbacks,
|
|
3460
|
+
direction,
|
|
3461
|
+
step: 'Start'
|
|
3462
|
+
});
|
|
3463
|
+
}
|
|
3464
|
+
|
|
3465
|
+
function transitionEnd(runCallbacks = true, direction) {
|
|
3466
|
+
const swiper = this;
|
|
3467
|
+
const {
|
|
3468
|
+
params
|
|
3469
|
+
} = swiper;
|
|
3470
|
+
swiper.animating = false;
|
|
3471
|
+
if (params.cssMode) return;
|
|
3472
|
+
swiper.setTransition(0);
|
|
3473
|
+
transitionEmit({
|
|
3474
|
+
swiper,
|
|
3475
|
+
runCallbacks,
|
|
3476
|
+
direction,
|
|
3477
|
+
step: 'End'
|
|
3478
|
+
});
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3481
|
+
var transition = {
|
|
3482
|
+
setTransition,
|
|
3483
|
+
transitionStart,
|
|
3484
|
+
transitionEnd
|
|
3485
|
+
};
|
|
3486
|
+
|
|
3487
|
+
function slideTo(index = 0, speed = this.params.speed, runCallbacks = true, internal, initial) {
|
|
3488
|
+
if (typeof index !== 'number' && typeof index !== 'string') {
|
|
3489
|
+
throw new Error(`The 'index' argument cannot have type other than 'number' or 'string'. [${typeof index}] given.`);
|
|
3490
|
+
}
|
|
3491
|
+
|
|
3492
|
+
if (typeof index === 'string') {
|
|
3493
|
+
/**
|
|
3494
|
+
* The `index` argument converted from `string` to `number`.
|
|
3495
|
+
* @type {number}
|
|
3496
|
+
*/
|
|
3497
|
+
const indexAsNumber = parseInt(index, 10);
|
|
3498
|
+
/**
|
|
3499
|
+
* Determines whether the `index` argument is a valid `number`
|
|
3500
|
+
* after being converted from the `string` type.
|
|
3501
|
+
* @type {boolean}
|
|
3502
|
+
*/
|
|
3503
|
+
|
|
3504
|
+
const isValidNumber = isFinite(indexAsNumber);
|
|
3505
|
+
|
|
3506
|
+
if (!isValidNumber) {
|
|
3507
|
+
throw new Error(`The passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`);
|
|
3508
|
+
} // Knowing that the converted `index` is a valid number,
|
|
3509
|
+
// we can update the original argument's value.
|
|
3510
|
+
|
|
3511
|
+
|
|
3512
|
+
index = indexAsNumber;
|
|
3513
|
+
}
|
|
3514
|
+
|
|
3515
|
+
const swiper = this;
|
|
3516
|
+
let slideIndex = index;
|
|
3517
|
+
if (slideIndex < 0) slideIndex = 0;
|
|
3518
|
+
const {
|
|
3519
|
+
params,
|
|
3520
|
+
snapGrid,
|
|
3521
|
+
slidesGrid,
|
|
3522
|
+
previousIndex,
|
|
3523
|
+
activeIndex,
|
|
3524
|
+
rtlTranslate: rtl,
|
|
3525
|
+
wrapperEl,
|
|
3526
|
+
enabled
|
|
3527
|
+
} = swiper;
|
|
3528
|
+
|
|
3529
|
+
if (swiper.animating && params.preventInteractionOnTransition || !enabled && !internal && !initial) {
|
|
3530
|
+
return false;
|
|
3531
|
+
}
|
|
3532
|
+
|
|
3533
|
+
const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
|
|
3534
|
+
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
|
3535
|
+
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
|
3536
|
+
const translate = -snapGrid[snapIndex]; // Normalize slideIndex
|
|
3537
|
+
|
|
3538
|
+
if (params.normalizeSlideIndex) {
|
|
3539
|
+
for (let i = 0; i < slidesGrid.length; i += 1) {
|
|
3540
|
+
const normalizedTranslate = -Math.floor(translate * 100);
|
|
3541
|
+
const normalizedGrid = Math.floor(slidesGrid[i] * 100);
|
|
3542
|
+
const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100);
|
|
3543
|
+
|
|
3544
|
+
if (typeof slidesGrid[i + 1] !== 'undefined') {
|
|
3545
|
+
if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGrid) / 2) {
|
|
3546
|
+
slideIndex = i;
|
|
3547
|
+
} else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) {
|
|
3548
|
+
slideIndex = i + 1;
|
|
3549
|
+
}
|
|
3550
|
+
} else if (normalizedTranslate >= normalizedGrid) {
|
|
3551
|
+
slideIndex = i;
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
} // Directions locks
|
|
3555
|
+
|
|
3556
|
+
|
|
3557
|
+
if (swiper.initialized && slideIndex !== activeIndex) {
|
|
3558
|
+
if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) {
|
|
3559
|
+
return false;
|
|
3560
|
+
}
|
|
3561
|
+
|
|
3562
|
+
if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
|
|
3563
|
+
if ((activeIndex || 0) !== slideIndex) return false;
|
|
3564
|
+
}
|
|
3565
|
+
}
|
|
3566
|
+
|
|
3567
|
+
if (slideIndex !== (previousIndex || 0) && runCallbacks) {
|
|
3568
|
+
swiper.emit('beforeSlideChangeStart');
|
|
3569
|
+
} // Update progress
|
|
3570
|
+
|
|
3571
|
+
|
|
3572
|
+
swiper.updateProgress(translate);
|
|
3573
|
+
let direction;
|
|
3574
|
+
if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset'; // Update Index
|
|
3575
|
+
|
|
3576
|
+
if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
|
|
3577
|
+
swiper.updateActiveIndex(slideIndex); // Update Height
|
|
3578
|
+
|
|
3579
|
+
if (params.autoHeight) {
|
|
3580
|
+
swiper.updateAutoHeight();
|
|
3581
|
+
}
|
|
3582
|
+
|
|
3583
|
+
swiper.updateSlidesClasses();
|
|
3584
|
+
|
|
3585
|
+
if (params.effect !== 'slide') {
|
|
3586
|
+
swiper.setTranslate(translate);
|
|
3587
|
+
}
|
|
3588
|
+
|
|
3589
|
+
if (direction !== 'reset') {
|
|
3590
|
+
swiper.transitionStart(runCallbacks, direction);
|
|
3591
|
+
swiper.transitionEnd(runCallbacks, direction);
|
|
3592
|
+
}
|
|
3593
|
+
|
|
3594
|
+
return false;
|
|
3595
|
+
}
|
|
3596
|
+
|
|
3597
|
+
if (params.cssMode) {
|
|
3598
|
+
const isH = swiper.isHorizontal();
|
|
3599
|
+
const t = rtl ? translate : -translate;
|
|
3600
|
+
|
|
3601
|
+
if (speed === 0) {
|
|
3602
|
+
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
3603
|
+
|
|
3604
|
+
if (isVirtual) {
|
|
3605
|
+
swiper.wrapperEl.style.scrollSnapType = 'none';
|
|
3606
|
+
swiper._immediateVirtual = true;
|
|
3607
|
+
}
|
|
3608
|
+
|
|
3609
|
+
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
3610
|
+
|
|
3611
|
+
if (isVirtual) {
|
|
3612
|
+
requestAnimationFrame(() => {
|
|
3613
|
+
swiper.wrapperEl.style.scrollSnapType = '';
|
|
3614
|
+
swiper._swiperImmediateVirtual = false;
|
|
3615
|
+
});
|
|
3616
|
+
}
|
|
3617
|
+
} else {
|
|
3618
|
+
if (!swiper.support.smoothScroll) {
|
|
3619
|
+
animateCSSModeScroll({
|
|
3620
|
+
swiper,
|
|
3621
|
+
targetPosition: t,
|
|
3622
|
+
side: isH ? 'left' : 'top'
|
|
3623
|
+
});
|
|
3624
|
+
return true;
|
|
3625
|
+
}
|
|
3626
|
+
|
|
3627
|
+
wrapperEl.scrollTo({
|
|
3628
|
+
[isH ? 'left' : 'top']: t,
|
|
3629
|
+
behavior: 'smooth'
|
|
3630
|
+
});
|
|
3631
|
+
}
|
|
3632
|
+
|
|
3633
|
+
return true;
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
swiper.setTransition(speed);
|
|
3637
|
+
swiper.setTranslate(translate);
|
|
3638
|
+
swiper.updateActiveIndex(slideIndex);
|
|
3639
|
+
swiper.updateSlidesClasses();
|
|
3640
|
+
swiper.emit('beforeTransitionStart', speed, internal);
|
|
3641
|
+
swiper.transitionStart(runCallbacks, direction);
|
|
3642
|
+
|
|
3643
|
+
if (speed === 0) {
|
|
3644
|
+
swiper.transitionEnd(runCallbacks, direction);
|
|
3645
|
+
} else if (!swiper.animating) {
|
|
3646
|
+
swiper.animating = true;
|
|
3647
|
+
|
|
3648
|
+
if (!swiper.onSlideToWrapperTransitionEnd) {
|
|
3649
|
+
swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) {
|
|
3650
|
+
if (!swiper || swiper.destroyed) return;
|
|
3651
|
+
if (e.target !== this) return;
|
|
3652
|
+
swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
|
|
3653
|
+
swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd);
|
|
3654
|
+
swiper.onSlideToWrapperTransitionEnd = null;
|
|
3655
|
+
delete swiper.onSlideToWrapperTransitionEnd;
|
|
3656
|
+
swiper.transitionEnd(runCallbacks, direction);
|
|
3657
|
+
};
|
|
3658
|
+
}
|
|
3659
|
+
|
|
3660
|
+
swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
|
|
3661
|
+
swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd);
|
|
3662
|
+
}
|
|
3663
|
+
|
|
3664
|
+
return true;
|
|
3665
|
+
}
|
|
3666
|
+
|
|
3667
|
+
function slideToLoop(index = 0, speed = this.params.speed, runCallbacks = true, internal) {
|
|
3668
|
+
if (typeof index === 'string') {
|
|
3669
|
+
/**
|
|
3670
|
+
* The `index` argument converted from `string` to `number`.
|
|
3671
|
+
* @type {number}
|
|
3672
|
+
*/
|
|
3673
|
+
const indexAsNumber = parseInt(index, 10);
|
|
3674
|
+
/**
|
|
3675
|
+
* Determines whether the `index` argument is a valid `number`
|
|
3676
|
+
* after being converted from the `string` type.
|
|
3677
|
+
* @type {boolean}
|
|
3678
|
+
*/
|
|
3679
|
+
|
|
3680
|
+
const isValidNumber = isFinite(indexAsNumber);
|
|
3681
|
+
|
|
3682
|
+
if (!isValidNumber) {
|
|
3683
|
+
throw new Error(`The passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`);
|
|
3684
|
+
} // Knowing that the converted `index` is a valid number,
|
|
3685
|
+
// we can update the original argument's value.
|
|
3686
|
+
|
|
3687
|
+
|
|
3688
|
+
index = indexAsNumber;
|
|
3689
|
+
}
|
|
3690
|
+
|
|
3691
|
+
const swiper = this;
|
|
3692
|
+
let newIndex = index;
|
|
3693
|
+
|
|
3694
|
+
if (swiper.params.loop) {
|
|
3695
|
+
newIndex += swiper.loopedSlides;
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3698
|
+
return swiper.slideTo(newIndex, speed, runCallbacks, internal);
|
|
3699
|
+
}
|
|
3700
|
+
|
|
3701
|
+
/* eslint no-unused-vars: "off" */
|
|
3702
|
+
function slideNext(speed = this.params.speed, runCallbacks = true, internal) {
|
|
3703
|
+
const swiper = this;
|
|
3704
|
+
const {
|
|
3705
|
+
animating,
|
|
3706
|
+
enabled,
|
|
3707
|
+
params
|
|
3708
|
+
} = swiper;
|
|
3709
|
+
if (!enabled) return swiper;
|
|
3710
|
+
let perGroup = params.slidesPerGroup;
|
|
3711
|
+
|
|
3712
|
+
if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
|
|
3713
|
+
perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
|
|
3714
|
+
}
|
|
3715
|
+
|
|
3716
|
+
const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
|
|
3717
|
+
|
|
3718
|
+
if (params.loop) {
|
|
3719
|
+
if (animating && params.loopPreventsSlide) return false;
|
|
3720
|
+
swiper.loopFix(); // eslint-disable-next-line
|
|
3721
|
+
|
|
3722
|
+
swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
|
|
3723
|
+
}
|
|
3724
|
+
|
|
3725
|
+
if (params.rewind && swiper.isEnd) {
|
|
3726
|
+
return swiper.slideTo(0, speed, runCallbacks, internal);
|
|
3727
|
+
}
|
|
3728
|
+
|
|
3729
|
+
return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
|
|
3730
|
+
}
|
|
3731
|
+
|
|
3732
|
+
/* eslint no-unused-vars: "off" */
|
|
3733
|
+
function slidePrev(speed = this.params.speed, runCallbacks = true, internal) {
|
|
3734
|
+
const swiper = this;
|
|
3735
|
+
const {
|
|
3736
|
+
params,
|
|
3737
|
+
animating,
|
|
3738
|
+
snapGrid,
|
|
3739
|
+
slidesGrid,
|
|
3740
|
+
rtlTranslate,
|
|
3741
|
+
enabled
|
|
3742
|
+
} = swiper;
|
|
3743
|
+
if (!enabled) return swiper;
|
|
3744
|
+
|
|
3745
|
+
if (params.loop) {
|
|
3746
|
+
if (animating && params.loopPreventsSlide) return false;
|
|
3747
|
+
swiper.loopFix(); // eslint-disable-next-line
|
|
3748
|
+
|
|
3749
|
+
swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3752
|
+
const translate = rtlTranslate ? swiper.translate : -swiper.translate;
|
|
3753
|
+
|
|
3754
|
+
function normalize(val) {
|
|
3755
|
+
if (val < 0) return -Math.floor(Math.abs(val));
|
|
3756
|
+
return Math.floor(val);
|
|
3757
|
+
}
|
|
3758
|
+
|
|
3759
|
+
const normalizedTranslate = normalize(translate);
|
|
3760
|
+
const normalizedSnapGrid = snapGrid.map(val => normalize(val));
|
|
3761
|
+
let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
|
3762
|
+
|
|
3763
|
+
if (typeof prevSnap === 'undefined' && params.cssMode) {
|
|
3764
|
+
let prevSnapIndex;
|
|
3765
|
+
snapGrid.forEach((snap, snapIndex) => {
|
|
3766
|
+
if (normalizedTranslate >= snap) {
|
|
3767
|
+
// prevSnap = snap;
|
|
3768
|
+
prevSnapIndex = snapIndex;
|
|
3769
|
+
}
|
|
3770
|
+
});
|
|
3771
|
+
|
|
3772
|
+
if (typeof prevSnapIndex !== 'undefined') {
|
|
3773
|
+
prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
|
|
3777
|
+
let prevIndex = 0;
|
|
3778
|
+
|
|
3779
|
+
if (typeof prevSnap !== 'undefined') {
|
|
3780
|
+
prevIndex = slidesGrid.indexOf(prevSnap);
|
|
3781
|
+
if (prevIndex < 0) prevIndex = swiper.activeIndex - 1;
|
|
3782
|
+
|
|
3783
|
+
if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
|
|
3784
|
+
prevIndex = prevIndex - swiper.slidesPerViewDynamic('previous', true) + 1;
|
|
3785
|
+
prevIndex = Math.max(prevIndex, 0);
|
|
3786
|
+
}
|
|
3787
|
+
}
|
|
3788
|
+
|
|
3789
|
+
if (params.rewind && swiper.isBeginning) {
|
|
3790
|
+
const lastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
|
|
3791
|
+
return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
|
|
3792
|
+
}
|
|
3793
|
+
|
|
3794
|
+
return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
|
|
3795
|
+
}
|
|
3796
|
+
|
|
3797
|
+
/* eslint no-unused-vars: "off" */
|
|
3798
|
+
function slideReset(speed = this.params.speed, runCallbacks = true, internal) {
|
|
3799
|
+
const swiper = this;
|
|
3800
|
+
return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
|
|
3801
|
+
}
|
|
3802
|
+
|
|
3803
|
+
/* eslint no-unused-vars: "off" */
|
|
3804
|
+
function slideToClosest(speed = this.params.speed, runCallbacks = true, internal, threshold = 0.5) {
|
|
3805
|
+
const swiper = this;
|
|
3806
|
+
let index = swiper.activeIndex;
|
|
3807
|
+
const skip = Math.min(swiper.params.slidesPerGroupSkip, index);
|
|
3808
|
+
const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
|
|
3809
|
+
const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
|
|
3810
|
+
|
|
3811
|
+
if (translate >= swiper.snapGrid[snapIndex]) {
|
|
3812
|
+
// The current translate is on or after the current snap index, so the choice
|
|
3813
|
+
// is between the current index and the one after it.
|
|
3814
|
+
const currentSnap = swiper.snapGrid[snapIndex];
|
|
3815
|
+
const nextSnap = swiper.snapGrid[snapIndex + 1];
|
|
3816
|
+
|
|
3817
|
+
if (translate - currentSnap > (nextSnap - currentSnap) * threshold) {
|
|
3818
|
+
index += swiper.params.slidesPerGroup;
|
|
3819
|
+
}
|
|
3820
|
+
} else {
|
|
3821
|
+
// The current translate is before the current snap index, so the choice
|
|
3822
|
+
// is between the current index and the one before it.
|
|
3823
|
+
const prevSnap = swiper.snapGrid[snapIndex - 1];
|
|
3824
|
+
const currentSnap = swiper.snapGrid[snapIndex];
|
|
3825
|
+
|
|
3826
|
+
if (translate - prevSnap <= (currentSnap - prevSnap) * threshold) {
|
|
3827
|
+
index -= swiper.params.slidesPerGroup;
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
|
|
3831
|
+
index = Math.max(index, 0);
|
|
3832
|
+
index = Math.min(index, swiper.slidesGrid.length - 1);
|
|
3833
|
+
return swiper.slideTo(index, speed, runCallbacks, internal);
|
|
3834
|
+
}
|
|
3835
|
+
|
|
3836
|
+
function slideToClickedSlide() {
|
|
3837
|
+
const swiper = this;
|
|
3838
|
+
const {
|
|
3839
|
+
params,
|
|
3840
|
+
$wrapperEl
|
|
3841
|
+
} = swiper;
|
|
3842
|
+
const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
|
3843
|
+
let slideToIndex = swiper.clickedIndex;
|
|
3844
|
+
let realIndex;
|
|
3845
|
+
|
|
3846
|
+
if (params.loop) {
|
|
3847
|
+
if (swiper.animating) return;
|
|
3848
|
+
realIndex = parseInt(dom7.$(swiper.clickedSlide).attr('data-swiper-slide-index'), 10);
|
|
3849
|
+
|
|
3850
|
+
if (params.centeredSlides) {
|
|
3851
|
+
if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2) {
|
|
3852
|
+
swiper.loopFix();
|
|
3853
|
+
slideToIndex = $wrapperEl.children(`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`).eq(0).index();
|
|
3854
|
+
nextTick(() => {
|
|
3855
|
+
swiper.slideTo(slideToIndex);
|
|
3856
|
+
});
|
|
3857
|
+
} else {
|
|
3858
|
+
swiper.slideTo(slideToIndex);
|
|
3859
|
+
}
|
|
3860
|
+
} else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
|
3861
|
+
swiper.loopFix();
|
|
3862
|
+
slideToIndex = $wrapperEl.children(`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`).eq(0).index();
|
|
3863
|
+
nextTick(() => {
|
|
3864
|
+
swiper.slideTo(slideToIndex);
|
|
3865
|
+
});
|
|
3866
|
+
} else {
|
|
3867
|
+
swiper.slideTo(slideToIndex);
|
|
3868
|
+
}
|
|
3869
|
+
} else {
|
|
3870
|
+
swiper.slideTo(slideToIndex);
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3873
|
+
|
|
3874
|
+
var slide = {
|
|
3875
|
+
slideTo,
|
|
3876
|
+
slideToLoop,
|
|
3877
|
+
slideNext,
|
|
3878
|
+
slidePrev,
|
|
3879
|
+
slideReset,
|
|
3880
|
+
slideToClosest,
|
|
3881
|
+
slideToClickedSlide
|
|
3882
|
+
};
|
|
3883
|
+
|
|
3884
|
+
function loopCreate() {
|
|
3885
|
+
const swiper = this;
|
|
3886
|
+
const document = ssrWindow.getDocument();
|
|
3887
|
+
const {
|
|
3888
|
+
params,
|
|
3889
|
+
$wrapperEl
|
|
3890
|
+
} = swiper; // Remove duplicated slides
|
|
3891
|
+
|
|
3892
|
+
const $selector = $wrapperEl.children().length > 0 ? dom7.$($wrapperEl.children()[0].parentNode) : $wrapperEl;
|
|
3893
|
+
$selector.children(`.${params.slideClass}.${params.slideDuplicateClass}`).remove();
|
|
3894
|
+
let slides = $selector.children(`.${params.slideClass}`);
|
|
3895
|
+
|
|
3896
|
+
if (params.loopFillGroupWithBlank) {
|
|
3897
|
+
const blankSlidesNum = params.slidesPerGroup - slides.length % params.slidesPerGroup;
|
|
3898
|
+
|
|
3899
|
+
if (blankSlidesNum !== params.slidesPerGroup) {
|
|
3900
|
+
for (let i = 0; i < blankSlidesNum; i += 1) {
|
|
3901
|
+
const blankNode = dom7.$(document.createElement('div')).addClass(`${params.slideClass} ${params.slideBlankClass}`);
|
|
3902
|
+
$selector.append(blankNode);
|
|
3903
|
+
}
|
|
3904
|
+
|
|
3905
|
+
slides = $selector.children(`.${params.slideClass}`);
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3908
|
+
|
|
3909
|
+
if (params.slidesPerView === 'auto' && !params.loopedSlides) params.loopedSlides = slides.length;
|
|
3910
|
+
swiper.loopedSlides = Math.ceil(parseFloat(params.loopedSlides || params.slidesPerView, 10));
|
|
3911
|
+
swiper.loopedSlides += params.loopAdditionalSlides;
|
|
3912
|
+
|
|
3913
|
+
if (swiper.loopedSlides > slides.length && swiper.params.loopedSlidesLimit) {
|
|
3914
|
+
swiper.loopedSlides = slides.length;
|
|
3915
|
+
}
|
|
3916
|
+
|
|
3917
|
+
const prependSlides = [];
|
|
3918
|
+
const appendSlides = [];
|
|
3919
|
+
slides.each((el, index) => {
|
|
3920
|
+
const slide = dom7.$(el);
|
|
3921
|
+
slide.attr('data-swiper-slide-index', index);
|
|
3922
|
+
});
|
|
3923
|
+
|
|
3924
|
+
for (let i = 0; i < swiper.loopedSlides; i += 1) {
|
|
3925
|
+
const index = i - Math.floor(i / slides.length) * slides.length;
|
|
3926
|
+
appendSlides.push(slides.eq(index)[0]);
|
|
3927
|
+
prependSlides.unshift(slides.eq(slides.length - index - 1)[0]);
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
for (let i = 0; i < appendSlides.length; i += 1) {
|
|
3931
|
+
$selector.append(dom7.$(appendSlides[i].cloneNode(true)).addClass(params.slideDuplicateClass));
|
|
3932
|
+
}
|
|
3933
|
+
|
|
3934
|
+
for (let i = prependSlides.length - 1; i >= 0; i -= 1) {
|
|
3935
|
+
$selector.prepend(dom7.$(prependSlides[i].cloneNode(true)).addClass(params.slideDuplicateClass));
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
|
|
3939
|
+
function loopFix() {
|
|
3940
|
+
const swiper = this;
|
|
3941
|
+
swiper.emit('beforeLoopFix');
|
|
3942
|
+
const {
|
|
3943
|
+
activeIndex,
|
|
3944
|
+
slides,
|
|
3945
|
+
loopedSlides,
|
|
3946
|
+
allowSlidePrev,
|
|
3947
|
+
allowSlideNext,
|
|
3948
|
+
snapGrid,
|
|
3949
|
+
rtlTranslate: rtl
|
|
3950
|
+
} = swiper;
|
|
3951
|
+
let newIndex;
|
|
3952
|
+
swiper.allowSlidePrev = true;
|
|
3953
|
+
swiper.allowSlideNext = true;
|
|
3954
|
+
const snapTranslate = -snapGrid[activeIndex];
|
|
3955
|
+
const diff = snapTranslate - swiper.getTranslate(); // Fix For Negative Oversliding
|
|
3956
|
+
|
|
3957
|
+
if (activeIndex < loopedSlides) {
|
|
3958
|
+
newIndex = slides.length - loopedSlides * 3 + activeIndex;
|
|
3959
|
+
newIndex += loopedSlides;
|
|
3960
|
+
const slideChanged = swiper.slideTo(newIndex, 0, false, true);
|
|
3961
|
+
|
|
3962
|
+
if (slideChanged && diff !== 0) {
|
|
3963
|
+
swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
|
|
3964
|
+
}
|
|
3965
|
+
} else if (activeIndex >= slides.length - loopedSlides) {
|
|
3966
|
+
// Fix For Positive Oversliding
|
|
3967
|
+
newIndex = -slides.length + activeIndex + loopedSlides;
|
|
3968
|
+
newIndex += loopedSlides;
|
|
3969
|
+
const slideChanged = swiper.slideTo(newIndex, 0, false, true);
|
|
3970
|
+
|
|
3971
|
+
if (slideChanged && diff !== 0) {
|
|
3972
|
+
swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
|
|
3973
|
+
}
|
|
3974
|
+
}
|
|
3975
|
+
|
|
3976
|
+
swiper.allowSlidePrev = allowSlidePrev;
|
|
3977
|
+
swiper.allowSlideNext = allowSlideNext;
|
|
3978
|
+
swiper.emit('loopFix');
|
|
3979
|
+
}
|
|
3980
|
+
|
|
3981
|
+
function loopDestroy() {
|
|
3982
|
+
const swiper = this;
|
|
3983
|
+
const {
|
|
3984
|
+
$wrapperEl,
|
|
3985
|
+
params,
|
|
3986
|
+
slides
|
|
3987
|
+
} = swiper;
|
|
3988
|
+
$wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass},.${params.slideClass}.${params.slideBlankClass}`).remove();
|
|
3989
|
+
slides.removeAttr('data-swiper-slide-index');
|
|
3990
|
+
}
|
|
3991
|
+
|
|
3992
|
+
var loop = {
|
|
3993
|
+
loopCreate,
|
|
3994
|
+
loopFix,
|
|
3995
|
+
loopDestroy
|
|
3996
|
+
};
|
|
3997
|
+
|
|
3998
|
+
function setGrabCursor(moving) {
|
|
3999
|
+
const swiper = this;
|
|
4000
|
+
if (swiper.support.touch || !swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return;
|
|
4001
|
+
const el = swiper.params.touchEventsTarget === 'container' ? swiper.el : swiper.wrapperEl;
|
|
4002
|
+
el.style.cursor = 'move';
|
|
4003
|
+
el.style.cursor = moving ? 'grabbing' : 'grab';
|
|
4004
|
+
}
|
|
4005
|
+
|
|
4006
|
+
function unsetGrabCursor() {
|
|
4007
|
+
const swiper = this;
|
|
4008
|
+
|
|
4009
|
+
if (swiper.support.touch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) {
|
|
4010
|
+
return;
|
|
4011
|
+
}
|
|
4012
|
+
|
|
4013
|
+
swiper[swiper.params.touchEventsTarget === 'container' ? 'el' : 'wrapperEl'].style.cursor = '';
|
|
4014
|
+
}
|
|
4015
|
+
|
|
4016
|
+
var grabCursor = {
|
|
4017
|
+
setGrabCursor,
|
|
4018
|
+
unsetGrabCursor
|
|
4019
|
+
};
|
|
4020
|
+
|
|
4021
|
+
function closestElement(selector, base = this) {
|
|
4022
|
+
function __closestFrom(el) {
|
|
4023
|
+
if (!el || el === ssrWindow.getDocument() || el === ssrWindow.getWindow()) return null;
|
|
4024
|
+
if (el.assignedSlot) el = el.assignedSlot;
|
|
4025
|
+
const found = el.closest(selector);
|
|
4026
|
+
|
|
4027
|
+
if (!found && !el.getRootNode) {
|
|
4028
|
+
return null;
|
|
4029
|
+
}
|
|
4030
|
+
|
|
4031
|
+
return found || __closestFrom(el.getRootNode().host);
|
|
4032
|
+
}
|
|
4033
|
+
|
|
4034
|
+
return __closestFrom(base);
|
|
4035
|
+
}
|
|
4036
|
+
|
|
4037
|
+
function onTouchStart(event) {
|
|
4038
|
+
const swiper = this;
|
|
4039
|
+
const document = ssrWindow.getDocument();
|
|
4040
|
+
const window = ssrWindow.getWindow();
|
|
4041
|
+
const data = swiper.touchEventsData;
|
|
4042
|
+
const {
|
|
4043
|
+
params,
|
|
4044
|
+
touches,
|
|
4045
|
+
enabled
|
|
4046
|
+
} = swiper;
|
|
4047
|
+
if (!enabled) return;
|
|
4048
|
+
|
|
4049
|
+
if (swiper.animating && params.preventInteractionOnTransition) {
|
|
4050
|
+
return;
|
|
4051
|
+
}
|
|
4052
|
+
|
|
4053
|
+
if (!swiper.animating && params.cssMode && params.loop) {
|
|
4054
|
+
swiper.loopFix();
|
|
4055
|
+
}
|
|
4056
|
+
|
|
4057
|
+
let e = event;
|
|
4058
|
+
if (e.originalEvent) e = e.originalEvent;
|
|
4059
|
+
let $targetEl = dom7.$(e.target);
|
|
4060
|
+
|
|
4061
|
+
if (params.touchEventsTarget === 'wrapper') {
|
|
4062
|
+
if (!$targetEl.closest(swiper.wrapperEl).length) return;
|
|
4063
|
+
}
|
|
4064
|
+
|
|
4065
|
+
data.isTouchEvent = e.type === 'touchstart';
|
|
4066
|
+
if (!data.isTouchEvent && 'which' in e && e.which === 3) return;
|
|
4067
|
+
if (!data.isTouchEvent && 'button' in e && e.button > 0) return;
|
|
4068
|
+
if (data.isTouched && data.isMoved) return; // change target el for shadow root component
|
|
4069
|
+
|
|
4070
|
+
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== ''; // eslint-disable-next-line
|
|
4071
|
+
|
|
4072
|
+
const eventPath = event.composedPath ? event.composedPath() : event.path;
|
|
4073
|
+
|
|
4074
|
+
if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) {
|
|
4075
|
+
$targetEl = dom7.$(eventPath[0]);
|
|
4076
|
+
}
|
|
4077
|
+
|
|
4078
|
+
const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
|
|
4079
|
+
const isTargetShadow = !!(e.target && e.target.shadowRoot); // use closestElement for shadow root element to get the actual closest for nested shadow root element
|
|
4080
|
+
|
|
4081
|
+
if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, $targetEl[0]) : $targetEl.closest(noSwipingSelector)[0])) {
|
|
4082
|
+
swiper.allowClick = true;
|
|
4083
|
+
return;
|
|
4084
|
+
}
|
|
4085
|
+
|
|
4086
|
+
if (params.swipeHandler) {
|
|
4087
|
+
if (!$targetEl.closest(params.swipeHandler)[0]) return;
|
|
4088
|
+
}
|
|
4089
|
+
|
|
4090
|
+
touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
|
|
4091
|
+
touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
|
|
4092
|
+
const startX = touches.currentX;
|
|
4093
|
+
const startY = touches.currentY; // Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
|
|
4094
|
+
|
|
4095
|
+
const edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection;
|
|
4096
|
+
const edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold;
|
|
4097
|
+
|
|
4098
|
+
if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) {
|
|
4099
|
+
if (edgeSwipeDetection === 'prevent') {
|
|
4100
|
+
event.preventDefault();
|
|
4101
|
+
} else {
|
|
4102
|
+
return;
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
|
|
4106
|
+
Object.assign(data, {
|
|
4107
|
+
isTouched: true,
|
|
4108
|
+
isMoved: false,
|
|
4109
|
+
allowTouchCallbacks: true,
|
|
4110
|
+
isScrolling: undefined,
|
|
4111
|
+
startMoving: undefined
|
|
4112
|
+
});
|
|
4113
|
+
touches.startX = startX;
|
|
4114
|
+
touches.startY = startY;
|
|
4115
|
+
data.touchStartTime = now();
|
|
4116
|
+
swiper.allowClick = true;
|
|
4117
|
+
swiper.updateSize();
|
|
4118
|
+
swiper.swipeDirection = undefined;
|
|
4119
|
+
if (params.threshold > 0) data.allowThresholdMove = false;
|
|
4120
|
+
|
|
4121
|
+
if (e.type !== 'touchstart') {
|
|
4122
|
+
let preventDefault = true;
|
|
4123
|
+
|
|
4124
|
+
if ($targetEl.is(data.focusableElements)) {
|
|
4125
|
+
preventDefault = false;
|
|
4126
|
+
|
|
4127
|
+
if ($targetEl[0].nodeName === 'SELECT') {
|
|
4128
|
+
data.isTouched = false;
|
|
4129
|
+
}
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
if (document.activeElement && dom7.$(document.activeElement).is(data.focusableElements) && document.activeElement !== $targetEl[0]) {
|
|
4133
|
+
document.activeElement.blur();
|
|
4134
|
+
}
|
|
4135
|
+
|
|
4136
|
+
const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
|
|
4137
|
+
|
|
4138
|
+
if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !$targetEl[0].isContentEditable) {
|
|
4139
|
+
e.preventDefault();
|
|
4140
|
+
}
|
|
4141
|
+
}
|
|
4142
|
+
|
|
4143
|
+
if (swiper.params.freeMode && swiper.params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
|
|
4144
|
+
swiper.freeMode.onTouchStart();
|
|
4145
|
+
}
|
|
4146
|
+
|
|
4147
|
+
swiper.emit('touchStart', e);
|
|
4148
|
+
}
|
|
4149
|
+
|
|
4150
|
+
function onTouchMove(event) {
|
|
4151
|
+
const document = ssrWindow.getDocument();
|
|
4152
|
+
const swiper = this;
|
|
4153
|
+
const data = swiper.touchEventsData;
|
|
4154
|
+
const {
|
|
4155
|
+
params,
|
|
4156
|
+
touches,
|
|
4157
|
+
rtlTranslate: rtl,
|
|
4158
|
+
enabled
|
|
4159
|
+
} = swiper;
|
|
4160
|
+
if (!enabled) return;
|
|
4161
|
+
let e = event;
|
|
4162
|
+
if (e.originalEvent) e = e.originalEvent;
|
|
4163
|
+
|
|
4164
|
+
if (!data.isTouched) {
|
|
4165
|
+
if (data.startMoving && data.isScrolling) {
|
|
4166
|
+
swiper.emit('touchMoveOpposite', e);
|
|
4167
|
+
}
|
|
4168
|
+
|
|
4169
|
+
return;
|
|
4170
|
+
}
|
|
4171
|
+
|
|
4172
|
+
if (data.isTouchEvent && e.type !== 'touchmove') return;
|
|
4173
|
+
const targetTouch = e.type === 'touchmove' && e.targetTouches && (e.targetTouches[0] || e.changedTouches[0]);
|
|
4174
|
+
const pageX = e.type === 'touchmove' ? targetTouch.pageX : e.pageX;
|
|
4175
|
+
const pageY = e.type === 'touchmove' ? targetTouch.pageY : e.pageY;
|
|
4176
|
+
|
|
4177
|
+
if (e.preventedByNestedSwiper) {
|
|
4178
|
+
touches.startX = pageX;
|
|
4179
|
+
touches.startY = pageY;
|
|
4180
|
+
return;
|
|
4181
|
+
}
|
|
4182
|
+
|
|
4183
|
+
if (!swiper.allowTouchMove) {
|
|
4184
|
+
if (!dom7.$(e.target).is(data.focusableElements)) {
|
|
4185
|
+
swiper.allowClick = false;
|
|
4186
|
+
}
|
|
4187
|
+
|
|
4188
|
+
if (data.isTouched) {
|
|
4189
|
+
Object.assign(touches, {
|
|
4190
|
+
startX: pageX,
|
|
4191
|
+
startY: pageY,
|
|
4192
|
+
currentX: pageX,
|
|
4193
|
+
currentY: pageY
|
|
4194
|
+
});
|
|
4195
|
+
data.touchStartTime = now();
|
|
4196
|
+
}
|
|
4197
|
+
|
|
4198
|
+
return;
|
|
4199
|
+
}
|
|
4200
|
+
|
|
4201
|
+
if (data.isTouchEvent && params.touchReleaseOnEdges && !params.loop) {
|
|
4202
|
+
if (swiper.isVertical()) {
|
|
4203
|
+
// Vertical
|
|
4204
|
+
if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
|
|
4205
|
+
data.isTouched = false;
|
|
4206
|
+
data.isMoved = false;
|
|
4207
|
+
return;
|
|
4208
|
+
}
|
|
4209
|
+
} else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate()) {
|
|
4210
|
+
return;
|
|
4211
|
+
}
|
|
4212
|
+
}
|
|
4213
|
+
|
|
4214
|
+
if (data.isTouchEvent && document.activeElement) {
|
|
4215
|
+
if (e.target === document.activeElement && dom7.$(e.target).is(data.focusableElements)) {
|
|
4216
|
+
data.isMoved = true;
|
|
4217
|
+
swiper.allowClick = false;
|
|
4218
|
+
return;
|
|
4219
|
+
}
|
|
4220
|
+
}
|
|
4221
|
+
|
|
4222
|
+
if (data.allowTouchCallbacks) {
|
|
4223
|
+
swiper.emit('touchMove', e);
|
|
4224
|
+
}
|
|
4225
|
+
|
|
4226
|
+
if (e.targetTouches && e.targetTouches.length > 1) return;
|
|
4227
|
+
touches.currentX = pageX;
|
|
4228
|
+
touches.currentY = pageY;
|
|
4229
|
+
const diffX = touches.currentX - touches.startX;
|
|
4230
|
+
const diffY = touches.currentY - touches.startY;
|
|
4231
|
+
if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return;
|
|
4232
|
+
|
|
4233
|
+
if (typeof data.isScrolling === 'undefined') {
|
|
4234
|
+
let touchAngle;
|
|
4235
|
+
|
|
4236
|
+
if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) {
|
|
4237
|
+
data.isScrolling = false;
|
|
4238
|
+
} else {
|
|
4239
|
+
// eslint-disable-next-line
|
|
4240
|
+
if (diffX * diffX + diffY * diffY >= 25) {
|
|
4241
|
+
touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
|
|
4242
|
+
data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle;
|
|
4243
|
+
}
|
|
4244
|
+
}
|
|
4245
|
+
}
|
|
4246
|
+
|
|
4247
|
+
if (data.isScrolling) {
|
|
4248
|
+
swiper.emit('touchMoveOpposite', e);
|
|
4249
|
+
}
|
|
4250
|
+
|
|
4251
|
+
if (typeof data.startMoving === 'undefined') {
|
|
4252
|
+
if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
|
|
4253
|
+
data.startMoving = true;
|
|
4254
|
+
}
|
|
4255
|
+
}
|
|
4256
|
+
|
|
4257
|
+
if (data.isScrolling) {
|
|
4258
|
+
data.isTouched = false;
|
|
4259
|
+
return;
|
|
4260
|
+
}
|
|
4261
|
+
|
|
4262
|
+
if (!data.startMoving) {
|
|
4263
|
+
return;
|
|
4264
|
+
}
|
|
4265
|
+
|
|
4266
|
+
swiper.allowClick = false;
|
|
4267
|
+
|
|
4268
|
+
if (!params.cssMode && e.cancelable) {
|
|
4269
|
+
e.preventDefault();
|
|
4270
|
+
}
|
|
4271
|
+
|
|
4272
|
+
if (params.touchMoveStopPropagation && !params.nested) {
|
|
4273
|
+
e.stopPropagation();
|
|
4274
|
+
}
|
|
4275
|
+
|
|
4276
|
+
if (!data.isMoved) {
|
|
4277
|
+
if (params.loop && !params.cssMode) {
|
|
4278
|
+
swiper.loopFix();
|
|
4279
|
+
}
|
|
4280
|
+
|
|
4281
|
+
data.startTranslate = swiper.getTranslate();
|
|
4282
|
+
swiper.setTransition(0);
|
|
4283
|
+
|
|
4284
|
+
if (swiper.animating) {
|
|
4285
|
+
swiper.$wrapperEl.trigger('webkitTransitionEnd transitionend');
|
|
4286
|
+
}
|
|
4287
|
+
|
|
4288
|
+
data.allowMomentumBounce = false; // Grab Cursor
|
|
4289
|
+
|
|
4290
|
+
if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
4291
|
+
swiper.setGrabCursor(true);
|
|
4292
|
+
}
|
|
4293
|
+
|
|
4294
|
+
swiper.emit('sliderFirstMove', e);
|
|
4295
|
+
}
|
|
4296
|
+
|
|
4297
|
+
swiper.emit('sliderMove', e);
|
|
4298
|
+
data.isMoved = true;
|
|
4299
|
+
let diff = swiper.isHorizontal() ? diffX : diffY;
|
|
4300
|
+
touches.diff = diff;
|
|
4301
|
+
diff *= params.touchRatio;
|
|
4302
|
+
if (rtl) diff = -diff;
|
|
4303
|
+
swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
|
|
4304
|
+
data.currentTranslate = diff + data.startTranslate;
|
|
4305
|
+
let disableParentSwiper = true;
|
|
4306
|
+
let resistanceRatio = params.resistanceRatio;
|
|
4307
|
+
|
|
4308
|
+
if (params.touchReleaseOnEdges) {
|
|
4309
|
+
resistanceRatio = 0;
|
|
4310
|
+
}
|
|
4311
|
+
|
|
4312
|
+
if (diff > 0 && data.currentTranslate > swiper.minTranslate()) {
|
|
4313
|
+
disableParentSwiper = false;
|
|
4314
|
+
if (params.resistance) data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data.startTranslate + diff) ** resistanceRatio;
|
|
4315
|
+
} else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) {
|
|
4316
|
+
disableParentSwiper = false;
|
|
4317
|
+
if (params.resistance) data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data.startTranslate - diff) ** resistanceRatio;
|
|
4318
|
+
}
|
|
4319
|
+
|
|
4320
|
+
if (disableParentSwiper) {
|
|
4321
|
+
e.preventedByNestedSwiper = true;
|
|
4322
|
+
} // Directions locks
|
|
4323
|
+
|
|
4324
|
+
|
|
4325
|
+
if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) {
|
|
4326
|
+
data.currentTranslate = data.startTranslate;
|
|
4327
|
+
}
|
|
4328
|
+
|
|
4329
|
+
if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) {
|
|
4330
|
+
data.currentTranslate = data.startTranslate;
|
|
4331
|
+
}
|
|
4332
|
+
|
|
4333
|
+
if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
|
4334
|
+
data.currentTranslate = data.startTranslate;
|
|
4335
|
+
} // Threshold
|
|
4336
|
+
|
|
4337
|
+
|
|
4338
|
+
if (params.threshold > 0) {
|
|
4339
|
+
if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
|
4340
|
+
if (!data.allowThresholdMove) {
|
|
4341
|
+
data.allowThresholdMove = true;
|
|
4342
|
+
touches.startX = touches.currentX;
|
|
4343
|
+
touches.startY = touches.currentY;
|
|
4344
|
+
data.currentTranslate = data.startTranslate;
|
|
4345
|
+
touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY;
|
|
4346
|
+
return;
|
|
4347
|
+
}
|
|
4348
|
+
} else {
|
|
4349
|
+
data.currentTranslate = data.startTranslate;
|
|
4350
|
+
return;
|
|
4351
|
+
}
|
|
4352
|
+
}
|
|
4353
|
+
|
|
4354
|
+
if (!params.followFinger || params.cssMode) return; // Update active index in free mode
|
|
4355
|
+
|
|
4356
|
+
if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) {
|
|
4357
|
+
swiper.updateActiveIndex();
|
|
4358
|
+
swiper.updateSlidesClasses();
|
|
4359
|
+
}
|
|
4360
|
+
|
|
4361
|
+
if (swiper.params.freeMode && params.freeMode.enabled && swiper.freeMode) {
|
|
4362
|
+
swiper.freeMode.onTouchMove();
|
|
4363
|
+
} // Update progress
|
|
4364
|
+
|
|
4365
|
+
|
|
4366
|
+
swiper.updateProgress(data.currentTranslate); // Update translate
|
|
4367
|
+
|
|
4368
|
+
swiper.setTranslate(data.currentTranslate);
|
|
4369
|
+
}
|
|
4370
|
+
|
|
4371
|
+
function onTouchEnd(event) {
|
|
4372
|
+
const swiper = this;
|
|
4373
|
+
const data = swiper.touchEventsData;
|
|
4374
|
+
const {
|
|
4375
|
+
params,
|
|
4376
|
+
touches,
|
|
4377
|
+
rtlTranslate: rtl,
|
|
4378
|
+
slidesGrid,
|
|
4379
|
+
enabled
|
|
4380
|
+
} = swiper;
|
|
4381
|
+
if (!enabled) return;
|
|
4382
|
+
let e = event;
|
|
4383
|
+
if (e.originalEvent) e = e.originalEvent;
|
|
4384
|
+
|
|
4385
|
+
if (data.allowTouchCallbacks) {
|
|
4386
|
+
swiper.emit('touchEnd', e);
|
|
4387
|
+
}
|
|
4388
|
+
|
|
4389
|
+
data.allowTouchCallbacks = false;
|
|
4390
|
+
|
|
4391
|
+
if (!data.isTouched) {
|
|
4392
|
+
if (data.isMoved && params.grabCursor) {
|
|
4393
|
+
swiper.setGrabCursor(false);
|
|
4394
|
+
}
|
|
4395
|
+
|
|
4396
|
+
data.isMoved = false;
|
|
4397
|
+
data.startMoving = false;
|
|
4398
|
+
return;
|
|
4399
|
+
} // Return Grab Cursor
|
|
4400
|
+
|
|
4401
|
+
|
|
4402
|
+
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
4403
|
+
swiper.setGrabCursor(false);
|
|
4404
|
+
} // Time diff
|
|
4405
|
+
|
|
4406
|
+
|
|
4407
|
+
const touchEndTime = now();
|
|
4408
|
+
const timeDiff = touchEndTime - data.touchStartTime; // Tap, doubleTap, Click
|
|
4409
|
+
|
|
4410
|
+
if (swiper.allowClick) {
|
|
4411
|
+
const pathTree = e.path || e.composedPath && e.composedPath();
|
|
4412
|
+
swiper.updateClickedSlide(pathTree && pathTree[0] || e.target);
|
|
4413
|
+
swiper.emit('tap click', e);
|
|
4414
|
+
|
|
4415
|
+
if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
|
|
4416
|
+
swiper.emit('doubleTap doubleClick', e);
|
|
4417
|
+
}
|
|
4418
|
+
}
|
|
4419
|
+
|
|
4420
|
+
data.lastClickTime = now();
|
|
4421
|
+
nextTick(() => {
|
|
4422
|
+
if (!swiper.destroyed) swiper.allowClick = true;
|
|
4423
|
+
});
|
|
4424
|
+
|
|
4425
|
+
if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) {
|
|
4426
|
+
data.isTouched = false;
|
|
4427
|
+
data.isMoved = false;
|
|
4428
|
+
data.startMoving = false;
|
|
4429
|
+
return;
|
|
4430
|
+
}
|
|
4431
|
+
|
|
4432
|
+
data.isTouched = false;
|
|
4433
|
+
data.isMoved = false;
|
|
4434
|
+
data.startMoving = false;
|
|
4435
|
+
let currentPos;
|
|
4436
|
+
|
|
4437
|
+
if (params.followFinger) {
|
|
4438
|
+
currentPos = rtl ? swiper.translate : -swiper.translate;
|
|
4439
|
+
} else {
|
|
4440
|
+
currentPos = -data.currentTranslate;
|
|
4441
|
+
}
|
|
4442
|
+
|
|
4443
|
+
if (params.cssMode) {
|
|
4444
|
+
return;
|
|
4445
|
+
}
|
|
4446
|
+
|
|
4447
|
+
if (swiper.params.freeMode && params.freeMode.enabled) {
|
|
4448
|
+
swiper.freeMode.onTouchEnd({
|
|
4449
|
+
currentPos
|
|
4450
|
+
});
|
|
4451
|
+
return;
|
|
4452
|
+
} // Find current slide
|
|
4453
|
+
|
|
4454
|
+
|
|
4455
|
+
let stopIndex = 0;
|
|
4456
|
+
let groupSize = swiper.slidesSizesGrid[0];
|
|
4457
|
+
|
|
4458
|
+
for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
|
|
4459
|
+
const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
|
4460
|
+
|
|
4461
|
+
if (typeof slidesGrid[i + increment] !== 'undefined') {
|
|
4462
|
+
if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) {
|
|
4463
|
+
stopIndex = i;
|
|
4464
|
+
groupSize = slidesGrid[i + increment] - slidesGrid[i];
|
|
4465
|
+
}
|
|
4466
|
+
} else if (currentPos >= slidesGrid[i]) {
|
|
4467
|
+
stopIndex = i;
|
|
4468
|
+
groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
|
|
4469
|
+
}
|
|
4470
|
+
}
|
|
4471
|
+
|
|
4472
|
+
let rewindFirstIndex = null;
|
|
4473
|
+
let rewindLastIndex = null;
|
|
4474
|
+
|
|
4475
|
+
if (params.rewind) {
|
|
4476
|
+
if (swiper.isBeginning) {
|
|
4477
|
+
rewindLastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
|
|
4478
|
+
} else if (swiper.isEnd) {
|
|
4479
|
+
rewindFirstIndex = 0;
|
|
4480
|
+
}
|
|
4481
|
+
} // Find current slide size
|
|
4482
|
+
|
|
4483
|
+
|
|
4484
|
+
const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
|
4485
|
+
const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
|
4486
|
+
|
|
4487
|
+
if (timeDiff > params.longSwipesMs) {
|
|
4488
|
+
// Long touches
|
|
4489
|
+
if (!params.longSwipes) {
|
|
4490
|
+
swiper.slideTo(swiper.activeIndex);
|
|
4491
|
+
return;
|
|
4492
|
+
}
|
|
4493
|
+
|
|
4494
|
+
if (swiper.swipeDirection === 'next') {
|
|
4495
|
+
if (ratio >= params.longSwipesRatio) swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);else swiper.slideTo(stopIndex);
|
|
4496
|
+
}
|
|
4497
|
+
|
|
4498
|
+
if (swiper.swipeDirection === 'prev') {
|
|
4499
|
+
if (ratio > 1 - params.longSwipesRatio) {
|
|
4500
|
+
swiper.slideTo(stopIndex + increment);
|
|
4501
|
+
} else if (rewindLastIndex !== null && ratio < 0 && Math.abs(ratio) > params.longSwipesRatio) {
|
|
4502
|
+
swiper.slideTo(rewindLastIndex);
|
|
4503
|
+
} else {
|
|
4504
|
+
swiper.slideTo(stopIndex);
|
|
4505
|
+
}
|
|
4506
|
+
}
|
|
4507
|
+
} else {
|
|
4508
|
+
// Short swipes
|
|
4509
|
+
if (!params.shortSwipes) {
|
|
4510
|
+
swiper.slideTo(swiper.activeIndex);
|
|
4511
|
+
return;
|
|
4512
|
+
}
|
|
4513
|
+
|
|
4514
|
+
const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl);
|
|
4515
|
+
|
|
4516
|
+
if (!isNavButtonTarget) {
|
|
4517
|
+
if (swiper.swipeDirection === 'next') {
|
|
4518
|
+
swiper.slideTo(rewindFirstIndex !== null ? rewindFirstIndex : stopIndex + increment);
|
|
4519
|
+
}
|
|
4520
|
+
|
|
4521
|
+
if (swiper.swipeDirection === 'prev') {
|
|
4522
|
+
swiper.slideTo(rewindLastIndex !== null ? rewindLastIndex : stopIndex);
|
|
4523
|
+
}
|
|
4524
|
+
} else if (e.target === swiper.navigation.nextEl) {
|
|
4525
|
+
swiper.slideTo(stopIndex + increment);
|
|
4526
|
+
} else {
|
|
4527
|
+
swiper.slideTo(stopIndex);
|
|
4528
|
+
}
|
|
4529
|
+
}
|
|
4530
|
+
}
|
|
4531
|
+
|
|
4532
|
+
function onResize() {
|
|
4533
|
+
const swiper = this;
|
|
4534
|
+
const {
|
|
4535
|
+
params,
|
|
4536
|
+
el
|
|
4537
|
+
} = swiper;
|
|
4538
|
+
if (el && el.offsetWidth === 0) return; // Breakpoints
|
|
4539
|
+
|
|
4540
|
+
if (params.breakpoints) {
|
|
4541
|
+
swiper.setBreakpoint();
|
|
4542
|
+
} // Save locks
|
|
4543
|
+
|
|
4544
|
+
|
|
4545
|
+
const {
|
|
4546
|
+
allowSlideNext,
|
|
4547
|
+
allowSlidePrev,
|
|
4548
|
+
snapGrid
|
|
4549
|
+
} = swiper; // Disable locks on resize
|
|
4550
|
+
|
|
4551
|
+
swiper.allowSlideNext = true;
|
|
4552
|
+
swiper.allowSlidePrev = true;
|
|
4553
|
+
swiper.updateSize();
|
|
4554
|
+
swiper.updateSlides();
|
|
4555
|
+
swiper.updateSlidesClasses();
|
|
4556
|
+
|
|
4557
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
|
|
4558
|
+
swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
4559
|
+
} else {
|
|
4560
|
+
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4561
|
+
}
|
|
4562
|
+
|
|
4563
|
+
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
|
4564
|
+
swiper.autoplay.run();
|
|
4565
|
+
} // Return locks after resize
|
|
4566
|
+
|
|
4567
|
+
|
|
4568
|
+
swiper.allowSlidePrev = allowSlidePrev;
|
|
4569
|
+
swiper.allowSlideNext = allowSlideNext;
|
|
4570
|
+
|
|
4571
|
+
if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
4572
|
+
swiper.checkOverflow();
|
|
4573
|
+
}
|
|
4574
|
+
}
|
|
4575
|
+
|
|
4576
|
+
function onClick(e) {
|
|
4577
|
+
const swiper = this;
|
|
4578
|
+
if (!swiper.enabled) return;
|
|
4579
|
+
|
|
4580
|
+
if (!swiper.allowClick) {
|
|
4581
|
+
if (swiper.params.preventClicks) e.preventDefault();
|
|
4582
|
+
|
|
4583
|
+
if (swiper.params.preventClicksPropagation && swiper.animating) {
|
|
4584
|
+
e.stopPropagation();
|
|
4585
|
+
e.stopImmediatePropagation();
|
|
4586
|
+
}
|
|
4587
|
+
}
|
|
4588
|
+
}
|
|
4589
|
+
|
|
4590
|
+
function onScroll() {
|
|
4591
|
+
const swiper = this;
|
|
4592
|
+
const {
|
|
4593
|
+
wrapperEl,
|
|
4594
|
+
rtlTranslate,
|
|
4595
|
+
enabled
|
|
4596
|
+
} = swiper;
|
|
4597
|
+
if (!enabled) return;
|
|
4598
|
+
swiper.previousTranslate = swiper.translate;
|
|
4599
|
+
|
|
4600
|
+
if (swiper.isHorizontal()) {
|
|
4601
|
+
swiper.translate = -wrapperEl.scrollLeft;
|
|
4602
|
+
} else {
|
|
4603
|
+
swiper.translate = -wrapperEl.scrollTop;
|
|
4604
|
+
} // eslint-disable-next-line
|
|
4605
|
+
|
|
4606
|
+
|
|
4607
|
+
if (swiper.translate === 0) swiper.translate = 0;
|
|
4608
|
+
swiper.updateActiveIndex();
|
|
4609
|
+
swiper.updateSlidesClasses();
|
|
4610
|
+
let newProgress;
|
|
4611
|
+
const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
|
4612
|
+
|
|
4613
|
+
if (translatesDiff === 0) {
|
|
4614
|
+
newProgress = 0;
|
|
4615
|
+
} else {
|
|
4616
|
+
newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff;
|
|
4617
|
+
}
|
|
4618
|
+
|
|
4619
|
+
if (newProgress !== swiper.progress) {
|
|
4620
|
+
swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate);
|
|
4621
|
+
}
|
|
4622
|
+
|
|
4623
|
+
swiper.emit('setTranslate', swiper.translate, false);
|
|
4624
|
+
}
|
|
4625
|
+
|
|
4626
|
+
let dummyEventAttached = false;
|
|
4627
|
+
|
|
4628
|
+
function dummyEventListener() {}
|
|
4629
|
+
|
|
4630
|
+
const events = (swiper, method) => {
|
|
4631
|
+
const document = ssrWindow.getDocument();
|
|
4632
|
+
const {
|
|
4633
|
+
params,
|
|
4634
|
+
touchEvents,
|
|
4635
|
+
el,
|
|
4636
|
+
wrapperEl,
|
|
4637
|
+
device,
|
|
4638
|
+
support
|
|
4639
|
+
} = swiper;
|
|
4640
|
+
const capture = !!params.nested;
|
|
4641
|
+
const domMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
|
|
4642
|
+
const swiperMethod = method; // Touch Events
|
|
4643
|
+
|
|
4644
|
+
if (!support.touch) {
|
|
4645
|
+
el[domMethod](touchEvents.start, swiper.onTouchStart, false);
|
|
4646
|
+
document[domMethod](touchEvents.move, swiper.onTouchMove, capture);
|
|
4647
|
+
document[domMethod](touchEvents.end, swiper.onTouchEnd, false);
|
|
4648
|
+
} else {
|
|
4649
|
+
const passiveListener = touchEvents.start === 'touchstart' && support.passiveListener && params.passiveListeners ? {
|
|
4650
|
+
passive: true,
|
|
4651
|
+
capture: false
|
|
4652
|
+
} : false;
|
|
4653
|
+
el[domMethod](touchEvents.start, swiper.onTouchStart, passiveListener);
|
|
4654
|
+
el[domMethod](touchEvents.move, swiper.onTouchMove, support.passiveListener ? {
|
|
4655
|
+
passive: false,
|
|
4656
|
+
capture
|
|
4657
|
+
} : capture);
|
|
4658
|
+
el[domMethod](touchEvents.end, swiper.onTouchEnd, passiveListener);
|
|
4659
|
+
|
|
4660
|
+
if (touchEvents.cancel) {
|
|
4661
|
+
el[domMethod](touchEvents.cancel, swiper.onTouchEnd, passiveListener);
|
|
4662
|
+
}
|
|
4663
|
+
} // Prevent Links Clicks
|
|
4664
|
+
|
|
4665
|
+
|
|
4666
|
+
if (params.preventClicks || params.preventClicksPropagation) {
|
|
4667
|
+
el[domMethod]('click', swiper.onClick, true);
|
|
4668
|
+
}
|
|
4669
|
+
|
|
4670
|
+
if (params.cssMode) {
|
|
4671
|
+
wrapperEl[domMethod]('scroll', swiper.onScroll);
|
|
4672
|
+
} // Resize handler
|
|
4673
|
+
|
|
4674
|
+
|
|
4675
|
+
if (params.updateOnWindowResize) {
|
|
4676
|
+
swiper[swiperMethod](device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true);
|
|
4677
|
+
} else {
|
|
4678
|
+
swiper[swiperMethod]('observerUpdate', onResize, true);
|
|
4679
|
+
}
|
|
4680
|
+
};
|
|
4681
|
+
|
|
4682
|
+
function attachEvents() {
|
|
4683
|
+
const swiper = this;
|
|
4684
|
+
const document = ssrWindow.getDocument();
|
|
4685
|
+
const {
|
|
4686
|
+
params,
|
|
4687
|
+
support
|
|
4688
|
+
} = swiper;
|
|
4689
|
+
swiper.onTouchStart = onTouchStart.bind(swiper);
|
|
4690
|
+
swiper.onTouchMove = onTouchMove.bind(swiper);
|
|
4691
|
+
swiper.onTouchEnd = onTouchEnd.bind(swiper);
|
|
4692
|
+
|
|
4693
|
+
if (params.cssMode) {
|
|
4694
|
+
swiper.onScroll = onScroll.bind(swiper);
|
|
4695
|
+
}
|
|
4696
|
+
|
|
4697
|
+
swiper.onClick = onClick.bind(swiper);
|
|
4698
|
+
|
|
4699
|
+
if (support.touch && !dummyEventAttached) {
|
|
4700
|
+
document.addEventListener('touchstart', dummyEventListener);
|
|
4701
|
+
dummyEventAttached = true;
|
|
4702
|
+
}
|
|
4703
|
+
|
|
4704
|
+
events(swiper, 'on');
|
|
4705
|
+
}
|
|
4706
|
+
|
|
4707
|
+
function detachEvents() {
|
|
4708
|
+
const swiper = this;
|
|
4709
|
+
events(swiper, 'off');
|
|
4710
|
+
}
|
|
4711
|
+
|
|
4712
|
+
var events$1 = {
|
|
4713
|
+
attachEvents,
|
|
4714
|
+
detachEvents
|
|
4715
|
+
};
|
|
4716
|
+
|
|
4717
|
+
const isGridEnabled = (swiper, params) => {
|
|
4718
|
+
return swiper.grid && params.grid && params.grid.rows > 1;
|
|
4719
|
+
};
|
|
4720
|
+
|
|
4721
|
+
function setBreakpoint() {
|
|
4722
|
+
const swiper = this;
|
|
4723
|
+
const {
|
|
4724
|
+
activeIndex,
|
|
4725
|
+
initialized,
|
|
4726
|
+
loopedSlides = 0,
|
|
4727
|
+
params,
|
|
4728
|
+
$el
|
|
4729
|
+
} = swiper;
|
|
4730
|
+
const breakpoints = params.breakpoints;
|
|
4731
|
+
if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return; // Get breakpoint for window width and update parameters
|
|
4732
|
+
|
|
4733
|
+
const breakpoint = swiper.getBreakpoint(breakpoints, swiper.params.breakpointsBase, swiper.el);
|
|
4734
|
+
if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
|
|
4735
|
+
const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
|
|
4736
|
+
const breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
|
4737
|
+
const wasMultiRow = isGridEnabled(swiper, params);
|
|
4738
|
+
const isMultiRow = isGridEnabled(swiper, breakpointParams);
|
|
4739
|
+
const wasEnabled = params.enabled;
|
|
4740
|
+
|
|
4741
|
+
if (wasMultiRow && !isMultiRow) {
|
|
4742
|
+
$el.removeClass(`${params.containerModifierClass}grid ${params.containerModifierClass}grid-column`);
|
|
4743
|
+
swiper.emitContainerClasses();
|
|
4744
|
+
} else if (!wasMultiRow && isMultiRow) {
|
|
4745
|
+
$el.addClass(`${params.containerModifierClass}grid`);
|
|
4746
|
+
|
|
4747
|
+
if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
|
|
4748
|
+
$el.addClass(`${params.containerModifierClass}grid-column`);
|
|
4749
|
+
}
|
|
4750
|
+
|
|
4751
|
+
swiper.emitContainerClasses();
|
|
4752
|
+
} // Toggle navigation, pagination, scrollbar
|
|
4753
|
+
|
|
4754
|
+
|
|
4755
|
+
['navigation', 'pagination', 'scrollbar'].forEach(prop => {
|
|
4756
|
+
const wasModuleEnabled = params[prop] && params[prop].enabled;
|
|
4757
|
+
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
4758
|
+
|
|
4759
|
+
if (wasModuleEnabled && !isModuleEnabled) {
|
|
4760
|
+
swiper[prop].disable();
|
|
4761
|
+
}
|
|
4762
|
+
|
|
4763
|
+
if (!wasModuleEnabled && isModuleEnabled) {
|
|
4764
|
+
swiper[prop].enable();
|
|
4765
|
+
}
|
|
4766
|
+
});
|
|
4767
|
+
const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
|
|
4768
|
+
const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
|
|
4769
|
+
|
|
4770
|
+
if (directionChanged && initialized) {
|
|
4771
|
+
swiper.changeDirection();
|
|
4772
|
+
}
|
|
4773
|
+
|
|
4774
|
+
extend(swiper.params, breakpointParams);
|
|
4775
|
+
const isEnabled = swiper.params.enabled;
|
|
4776
|
+
Object.assign(swiper, {
|
|
4777
|
+
allowTouchMove: swiper.params.allowTouchMove,
|
|
4778
|
+
allowSlideNext: swiper.params.allowSlideNext,
|
|
4779
|
+
allowSlidePrev: swiper.params.allowSlidePrev
|
|
4780
|
+
});
|
|
4781
|
+
|
|
4782
|
+
if (wasEnabled && !isEnabled) {
|
|
4783
|
+
swiper.disable();
|
|
4784
|
+
} else if (!wasEnabled && isEnabled) {
|
|
4785
|
+
swiper.enable();
|
|
4786
|
+
}
|
|
4787
|
+
|
|
4788
|
+
swiper.currentBreakpoint = breakpoint;
|
|
4789
|
+
swiper.emit('_beforeBreakpoint', breakpointParams);
|
|
4790
|
+
|
|
4791
|
+
if (needsReLoop && initialized) {
|
|
4792
|
+
swiper.loopDestroy();
|
|
4793
|
+
swiper.loopCreate();
|
|
4794
|
+
swiper.updateSlides();
|
|
4795
|
+
swiper.slideTo(activeIndex - loopedSlides + swiper.loopedSlides, 0, false);
|
|
4796
|
+
}
|
|
4797
|
+
|
|
4798
|
+
swiper.emit('breakpoint', breakpointParams);
|
|
4799
|
+
}
|
|
4800
|
+
|
|
4801
|
+
function getBreakpoint(breakpoints, base = 'window', containerEl) {
|
|
4802
|
+
if (!breakpoints || base === 'container' && !containerEl) return undefined;
|
|
4803
|
+
let breakpoint = false;
|
|
4804
|
+
const window = ssrWindow.getWindow();
|
|
4805
|
+
const currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight;
|
|
4806
|
+
const points = Object.keys(breakpoints).map(point => {
|
|
4807
|
+
if (typeof point === 'string' && point.indexOf('@') === 0) {
|
|
4808
|
+
const minRatio = parseFloat(point.substr(1));
|
|
4809
|
+
const value = currentHeight * minRatio;
|
|
4810
|
+
return {
|
|
4811
|
+
value,
|
|
4812
|
+
point
|
|
4813
|
+
};
|
|
4814
|
+
}
|
|
4815
|
+
|
|
4816
|
+
return {
|
|
4817
|
+
value: point,
|
|
4818
|
+
point
|
|
4819
|
+
};
|
|
4820
|
+
});
|
|
4821
|
+
points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10));
|
|
4822
|
+
|
|
4823
|
+
for (let i = 0; i < points.length; i += 1) {
|
|
4824
|
+
const {
|
|
4825
|
+
point,
|
|
4826
|
+
value
|
|
4827
|
+
} = points[i];
|
|
4828
|
+
|
|
4829
|
+
if (base === 'window') {
|
|
4830
|
+
if (window.matchMedia(`(min-width: ${value}px)`).matches) {
|
|
4831
|
+
breakpoint = point;
|
|
4832
|
+
}
|
|
4833
|
+
} else if (value <= containerEl.clientWidth) {
|
|
4834
|
+
breakpoint = point;
|
|
4835
|
+
}
|
|
4836
|
+
}
|
|
4837
|
+
|
|
4838
|
+
return breakpoint || 'max';
|
|
4839
|
+
}
|
|
4840
|
+
|
|
4841
|
+
var breakpoints = {
|
|
4842
|
+
setBreakpoint,
|
|
4843
|
+
getBreakpoint
|
|
4844
|
+
};
|
|
4845
|
+
|
|
4846
|
+
function prepareClasses(entries, prefix) {
|
|
4847
|
+
const resultClasses = [];
|
|
4848
|
+
entries.forEach(item => {
|
|
4849
|
+
if (typeof item === 'object') {
|
|
4850
|
+
Object.keys(item).forEach(classNames => {
|
|
4851
|
+
if (item[classNames]) {
|
|
4852
|
+
resultClasses.push(prefix + classNames);
|
|
4853
|
+
}
|
|
4854
|
+
});
|
|
4855
|
+
} else if (typeof item === 'string') {
|
|
4856
|
+
resultClasses.push(prefix + item);
|
|
4857
|
+
}
|
|
4858
|
+
});
|
|
4859
|
+
return resultClasses;
|
|
4860
|
+
}
|
|
4861
|
+
|
|
4862
|
+
function addClasses() {
|
|
4863
|
+
const swiper = this;
|
|
4864
|
+
const {
|
|
4865
|
+
classNames,
|
|
4866
|
+
params,
|
|
4867
|
+
rtl,
|
|
4868
|
+
$el,
|
|
4869
|
+
device,
|
|
4870
|
+
support
|
|
4871
|
+
} = swiper; // prettier-ignore
|
|
4872
|
+
|
|
4873
|
+
const suffixes = prepareClasses(['initialized', params.direction, {
|
|
4874
|
+
'pointer-events': !support.touch
|
|
4875
|
+
}, {
|
|
4876
|
+
'free-mode': swiper.params.freeMode && params.freeMode.enabled
|
|
4877
|
+
}, {
|
|
4878
|
+
'autoheight': params.autoHeight
|
|
4879
|
+
}, {
|
|
4880
|
+
'rtl': rtl
|
|
4881
|
+
}, {
|
|
4882
|
+
'grid': params.grid && params.grid.rows > 1
|
|
4883
|
+
}, {
|
|
4884
|
+
'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
|
|
4885
|
+
}, {
|
|
4886
|
+
'android': device.android
|
|
4887
|
+
}, {
|
|
4888
|
+
'ios': device.ios
|
|
4889
|
+
}, {
|
|
4890
|
+
'css-mode': params.cssMode
|
|
4891
|
+
}, {
|
|
4892
|
+
'centered': params.cssMode && params.centeredSlides
|
|
4893
|
+
}, {
|
|
4894
|
+
'watch-progress': params.watchSlidesProgress
|
|
4895
|
+
}], params.containerModifierClass);
|
|
4896
|
+
classNames.push(...suffixes);
|
|
4897
|
+
$el.addClass([...classNames].join(' '));
|
|
4898
|
+
swiper.emitContainerClasses();
|
|
4899
|
+
}
|
|
4900
|
+
|
|
4901
|
+
function removeClasses() {
|
|
4902
|
+
const swiper = this;
|
|
4903
|
+
const {
|
|
4904
|
+
$el,
|
|
4905
|
+
classNames
|
|
4906
|
+
} = swiper;
|
|
4907
|
+
$el.removeClass(classNames.join(' '));
|
|
4908
|
+
swiper.emitContainerClasses();
|
|
4909
|
+
}
|
|
4910
|
+
|
|
4911
|
+
var classes = {
|
|
4912
|
+
addClasses,
|
|
4913
|
+
removeClasses
|
|
4914
|
+
};
|
|
4915
|
+
|
|
4916
|
+
function loadImage(imageEl, src, srcset, sizes, checkForComplete, callback) {
|
|
4917
|
+
const window = ssrWindow.getWindow();
|
|
4918
|
+
let image;
|
|
4919
|
+
|
|
4920
|
+
function onReady() {
|
|
4921
|
+
if (callback) callback();
|
|
4922
|
+
}
|
|
4923
|
+
|
|
4924
|
+
const isPicture = dom7.$(imageEl).parent('picture')[0];
|
|
4925
|
+
|
|
4926
|
+
if (!isPicture && (!imageEl.complete || !checkForComplete)) {
|
|
4927
|
+
if (src) {
|
|
4928
|
+
image = new window.Image();
|
|
4929
|
+
image.onload = onReady;
|
|
4930
|
+
image.onerror = onReady;
|
|
4931
|
+
|
|
4932
|
+
if (sizes) {
|
|
4933
|
+
image.sizes = sizes;
|
|
4934
|
+
}
|
|
4935
|
+
|
|
4936
|
+
if (srcset) {
|
|
4937
|
+
image.srcset = srcset;
|
|
4938
|
+
}
|
|
4939
|
+
|
|
4940
|
+
if (src) {
|
|
4941
|
+
image.src = src;
|
|
4942
|
+
}
|
|
4943
|
+
} else {
|
|
4944
|
+
onReady();
|
|
4945
|
+
}
|
|
4946
|
+
} else {
|
|
4947
|
+
// image already loaded...
|
|
4948
|
+
onReady();
|
|
4949
|
+
}
|
|
4950
|
+
}
|
|
4951
|
+
|
|
4952
|
+
function preloadImages() {
|
|
4953
|
+
const swiper = this;
|
|
4954
|
+
swiper.imagesToLoad = swiper.$el.find('img');
|
|
4955
|
+
|
|
4956
|
+
function onReady() {
|
|
4957
|
+
if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper.destroyed) return;
|
|
4958
|
+
if (swiper.imagesLoaded !== undefined) swiper.imagesLoaded += 1;
|
|
4959
|
+
|
|
4960
|
+
if (swiper.imagesLoaded === swiper.imagesToLoad.length) {
|
|
4961
|
+
if (swiper.params.updateOnImagesReady) swiper.update();
|
|
4962
|
+
swiper.emit('imagesReady');
|
|
4963
|
+
}
|
|
4964
|
+
}
|
|
4965
|
+
|
|
4966
|
+
for (let i = 0; i < swiper.imagesToLoad.length; i += 1) {
|
|
4967
|
+
const imageEl = swiper.imagesToLoad[i];
|
|
4968
|
+
swiper.loadImage(imageEl, imageEl.currentSrc || imageEl.getAttribute('src'), imageEl.srcset || imageEl.getAttribute('srcset'), imageEl.sizes || imageEl.getAttribute('sizes'), true, onReady);
|
|
4969
|
+
}
|
|
4970
|
+
}
|
|
4971
|
+
|
|
4972
|
+
var images = {
|
|
4973
|
+
loadImage,
|
|
4974
|
+
preloadImages
|
|
4975
|
+
};
|
|
4976
|
+
|
|
4977
|
+
function checkOverflow() {
|
|
4978
|
+
const swiper = this;
|
|
4979
|
+
const {
|
|
4980
|
+
isLocked: wasLocked,
|
|
4981
|
+
params
|
|
4982
|
+
} = swiper;
|
|
4983
|
+
const {
|
|
4984
|
+
slidesOffsetBefore
|
|
4985
|
+
} = params;
|
|
4986
|
+
|
|
4987
|
+
if (slidesOffsetBefore) {
|
|
4988
|
+
const lastSlideIndex = swiper.slides.length - 1;
|
|
4989
|
+
const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] + slidesOffsetBefore * 2;
|
|
4990
|
+
swiper.isLocked = swiper.size > lastSlideRightEdge;
|
|
4991
|
+
} else {
|
|
4992
|
+
swiper.isLocked = swiper.snapGrid.length === 1;
|
|
4993
|
+
}
|
|
4994
|
+
|
|
4995
|
+
if (params.allowSlideNext === true) {
|
|
4996
|
+
swiper.allowSlideNext = !swiper.isLocked;
|
|
4997
|
+
}
|
|
4998
|
+
|
|
4999
|
+
if (params.allowSlidePrev === true) {
|
|
5000
|
+
swiper.allowSlidePrev = !swiper.isLocked;
|
|
5001
|
+
}
|
|
5002
|
+
|
|
5003
|
+
if (wasLocked && wasLocked !== swiper.isLocked) {
|
|
5004
|
+
swiper.isEnd = false;
|
|
5005
|
+
}
|
|
5006
|
+
|
|
5007
|
+
if (wasLocked !== swiper.isLocked) {
|
|
5008
|
+
swiper.emit(swiper.isLocked ? 'lock' : 'unlock');
|
|
5009
|
+
}
|
|
5010
|
+
}
|
|
5011
|
+
|
|
5012
|
+
var checkOverflow$1 = {
|
|
5013
|
+
checkOverflow
|
|
5014
|
+
};
|
|
5015
|
+
|
|
5016
|
+
var defaults = {
|
|
5017
|
+
init: true,
|
|
5018
|
+
direction: 'horizontal',
|
|
5019
|
+
touchEventsTarget: 'wrapper',
|
|
5020
|
+
initialSlide: 0,
|
|
5021
|
+
speed: 300,
|
|
5022
|
+
cssMode: false,
|
|
5023
|
+
updateOnWindowResize: true,
|
|
5024
|
+
resizeObserver: true,
|
|
5025
|
+
nested: false,
|
|
5026
|
+
createElements: false,
|
|
5027
|
+
enabled: true,
|
|
5028
|
+
focusableElements: 'input, select, option, textarea, button, video, label',
|
|
5029
|
+
// Overrides
|
|
5030
|
+
width: null,
|
|
5031
|
+
height: null,
|
|
5032
|
+
//
|
|
5033
|
+
preventInteractionOnTransition: false,
|
|
5034
|
+
// ssr
|
|
5035
|
+
userAgent: null,
|
|
5036
|
+
url: null,
|
|
5037
|
+
// To support iOS's swipe-to-go-back gesture (when being used in-app).
|
|
5038
|
+
edgeSwipeDetection: false,
|
|
5039
|
+
edgeSwipeThreshold: 20,
|
|
5040
|
+
// Autoheight
|
|
5041
|
+
autoHeight: false,
|
|
5042
|
+
// Set wrapper width
|
|
5043
|
+
setWrapperSize: false,
|
|
5044
|
+
// Virtual Translate
|
|
5045
|
+
virtualTranslate: false,
|
|
5046
|
+
// Effects
|
|
5047
|
+
effect: 'slide',
|
|
5048
|
+
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
|
|
5049
|
+
// Breakpoints
|
|
5050
|
+
breakpoints: undefined,
|
|
5051
|
+
breakpointsBase: 'window',
|
|
5052
|
+
// Slides grid
|
|
5053
|
+
spaceBetween: 0,
|
|
5054
|
+
slidesPerView: 1,
|
|
5055
|
+
slidesPerGroup: 1,
|
|
5056
|
+
slidesPerGroupSkip: 0,
|
|
5057
|
+
slidesPerGroupAuto: false,
|
|
5058
|
+
centeredSlides: false,
|
|
5059
|
+
centeredSlidesBounds: false,
|
|
5060
|
+
slidesOffsetBefore: 0,
|
|
5061
|
+
// in px
|
|
5062
|
+
slidesOffsetAfter: 0,
|
|
5063
|
+
// in px
|
|
5064
|
+
normalizeSlideIndex: true,
|
|
5065
|
+
centerInsufficientSlides: false,
|
|
5066
|
+
// Disable swiper and hide navigation when container not overflow
|
|
5067
|
+
watchOverflow: true,
|
|
5068
|
+
// Round length
|
|
5069
|
+
roundLengths: false,
|
|
5070
|
+
// Touches
|
|
5071
|
+
touchRatio: 1,
|
|
5072
|
+
touchAngle: 45,
|
|
5073
|
+
simulateTouch: true,
|
|
5074
|
+
shortSwipes: true,
|
|
5075
|
+
longSwipes: true,
|
|
5076
|
+
longSwipesRatio: 0.5,
|
|
5077
|
+
longSwipesMs: 300,
|
|
5078
|
+
followFinger: true,
|
|
5079
|
+
allowTouchMove: true,
|
|
5080
|
+
threshold: 0,
|
|
5081
|
+
touchMoveStopPropagation: false,
|
|
5082
|
+
touchStartPreventDefault: true,
|
|
5083
|
+
touchStartForcePreventDefault: false,
|
|
5084
|
+
touchReleaseOnEdges: false,
|
|
5085
|
+
// Unique Navigation Elements
|
|
5086
|
+
uniqueNavElements: true,
|
|
5087
|
+
// Resistance
|
|
5088
|
+
resistance: true,
|
|
5089
|
+
resistanceRatio: 0.85,
|
|
5090
|
+
// Progress
|
|
5091
|
+
watchSlidesProgress: false,
|
|
5092
|
+
// Cursor
|
|
5093
|
+
grabCursor: false,
|
|
5094
|
+
// Clicks
|
|
5095
|
+
preventClicks: true,
|
|
5096
|
+
preventClicksPropagation: true,
|
|
5097
|
+
slideToClickedSlide: false,
|
|
5098
|
+
// Images
|
|
5099
|
+
preloadImages: true,
|
|
5100
|
+
updateOnImagesReady: true,
|
|
5101
|
+
// loop
|
|
5102
|
+
loop: false,
|
|
5103
|
+
loopAdditionalSlides: 0,
|
|
5104
|
+
loopedSlides: null,
|
|
5105
|
+
loopedSlidesLimit: true,
|
|
5106
|
+
loopFillGroupWithBlank: false,
|
|
5107
|
+
loopPreventsSlide: true,
|
|
5108
|
+
// rewind
|
|
5109
|
+
rewind: false,
|
|
5110
|
+
// Swiping/no swiping
|
|
5111
|
+
allowSlidePrev: true,
|
|
5112
|
+
allowSlideNext: true,
|
|
5113
|
+
swipeHandler: null,
|
|
5114
|
+
// '.swipe-handler',
|
|
5115
|
+
noSwiping: true,
|
|
5116
|
+
noSwipingClass: 'swiper-no-swiping',
|
|
5117
|
+
noSwipingSelector: null,
|
|
5118
|
+
// Passive Listeners
|
|
5119
|
+
passiveListeners: true,
|
|
5120
|
+
maxBackfaceHiddenSlides: 10,
|
|
5121
|
+
// NS
|
|
5122
|
+
containerModifierClass: 'swiper-',
|
|
5123
|
+
// NEW
|
|
5124
|
+
slideClass: 'swiper-slide',
|
|
5125
|
+
slideBlankClass: 'swiper-slide-invisible-blank',
|
|
5126
|
+
slideActiveClass: 'swiper-slide-active',
|
|
5127
|
+
slideDuplicateActiveClass: 'swiper-slide-duplicate-active',
|
|
5128
|
+
slideVisibleClass: 'swiper-slide-visible',
|
|
5129
|
+
slideDuplicateClass: 'swiper-slide-duplicate',
|
|
5130
|
+
slideNextClass: 'swiper-slide-next',
|
|
5131
|
+
slideDuplicateNextClass: 'swiper-slide-duplicate-next',
|
|
5132
|
+
slidePrevClass: 'swiper-slide-prev',
|
|
5133
|
+
slideDuplicatePrevClass: 'swiper-slide-duplicate-prev',
|
|
5134
|
+
wrapperClass: 'swiper-wrapper',
|
|
5135
|
+
// Callbacks
|
|
5136
|
+
runCallbacksOnInit: true,
|
|
5137
|
+
// Internals
|
|
5138
|
+
_emitClasses: false
|
|
5139
|
+
};
|
|
5140
|
+
|
|
5141
|
+
function moduleExtendParams(params, allModulesParams) {
|
|
5142
|
+
return function extendParams(obj = {}) {
|
|
5143
|
+
const moduleParamName = Object.keys(obj)[0];
|
|
5144
|
+
const moduleParams = obj[moduleParamName];
|
|
5145
|
+
|
|
5146
|
+
if (typeof moduleParams !== 'object' || moduleParams === null) {
|
|
5147
|
+
extend(allModulesParams, obj);
|
|
5148
|
+
return;
|
|
5149
|
+
}
|
|
5150
|
+
|
|
5151
|
+
if (['navigation', 'pagination', 'scrollbar'].indexOf(moduleParamName) >= 0 && params[moduleParamName] === true) {
|
|
5152
|
+
params[moduleParamName] = {
|
|
5153
|
+
auto: true
|
|
5154
|
+
};
|
|
5155
|
+
}
|
|
5156
|
+
|
|
5157
|
+
if (!(moduleParamName in params && 'enabled' in moduleParams)) {
|
|
5158
|
+
extend(allModulesParams, obj);
|
|
5159
|
+
return;
|
|
5160
|
+
}
|
|
5161
|
+
|
|
5162
|
+
if (params[moduleParamName] === true) {
|
|
5163
|
+
params[moduleParamName] = {
|
|
5164
|
+
enabled: true
|
|
5165
|
+
};
|
|
5166
|
+
}
|
|
5167
|
+
|
|
5168
|
+
if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) {
|
|
5169
|
+
params[moduleParamName].enabled = true;
|
|
5170
|
+
}
|
|
5171
|
+
|
|
5172
|
+
if (!params[moduleParamName]) params[moduleParamName] = {
|
|
5173
|
+
enabled: false
|
|
5174
|
+
};
|
|
5175
|
+
extend(allModulesParams, obj);
|
|
5176
|
+
};
|
|
5177
|
+
}
|
|
5178
|
+
|
|
5179
|
+
/* eslint no-param-reassign: "off" */
|
|
5180
|
+
const prototypes = {
|
|
5181
|
+
eventsEmitter,
|
|
5182
|
+
update,
|
|
5183
|
+
translate,
|
|
5184
|
+
transition,
|
|
5185
|
+
slide,
|
|
5186
|
+
loop,
|
|
5187
|
+
grabCursor,
|
|
5188
|
+
events: events$1,
|
|
5189
|
+
breakpoints,
|
|
5190
|
+
checkOverflow: checkOverflow$1,
|
|
5191
|
+
classes,
|
|
5192
|
+
images
|
|
5193
|
+
};
|
|
5194
|
+
const extendedDefaults = {};
|
|
5195
|
+
|
|
5196
|
+
class Swiper {
|
|
5197
|
+
constructor(...args) {
|
|
5198
|
+
let el;
|
|
5199
|
+
let params;
|
|
5200
|
+
|
|
5201
|
+
if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object') {
|
|
5202
|
+
params = args[0];
|
|
5203
|
+
} else {
|
|
5204
|
+
[el, params] = args;
|
|
5205
|
+
}
|
|
5206
|
+
|
|
5207
|
+
if (!params) params = {};
|
|
5208
|
+
params = extend({}, params);
|
|
5209
|
+
if (el && !params.el) params.el = el;
|
|
5210
|
+
|
|
5211
|
+
if (params.el && dom7.$(params.el).length > 1) {
|
|
5212
|
+
const swipers = [];
|
|
5213
|
+
dom7.$(params.el).each(containerEl => {
|
|
5214
|
+
const newParams = extend({}, params, {
|
|
5215
|
+
el: containerEl
|
|
5216
|
+
});
|
|
5217
|
+
swipers.push(new Swiper(newParams));
|
|
5218
|
+
}); // eslint-disable-next-line no-constructor-return
|
|
5219
|
+
|
|
5220
|
+
return swipers;
|
|
5221
|
+
} // Swiper Instance
|
|
5222
|
+
|
|
5223
|
+
|
|
5224
|
+
const swiper = this;
|
|
5225
|
+
swiper.__swiper__ = true;
|
|
5226
|
+
swiper.support = getSupport();
|
|
5227
|
+
swiper.device = getDevice({
|
|
5228
|
+
userAgent: params.userAgent
|
|
5229
|
+
});
|
|
5230
|
+
swiper.browser = getBrowser();
|
|
5231
|
+
swiper.eventsListeners = {};
|
|
5232
|
+
swiper.eventsAnyListeners = [];
|
|
5233
|
+
swiper.modules = [...swiper.__modules__];
|
|
5234
|
+
|
|
5235
|
+
if (params.modules && Array.isArray(params.modules)) {
|
|
5236
|
+
swiper.modules.push(...params.modules);
|
|
5237
|
+
}
|
|
5238
|
+
|
|
5239
|
+
const allModulesParams = {};
|
|
5240
|
+
swiper.modules.forEach(mod => {
|
|
5241
|
+
mod({
|
|
5242
|
+
swiper,
|
|
5243
|
+
extendParams: moduleExtendParams(params, allModulesParams),
|
|
5244
|
+
on: swiper.on.bind(swiper),
|
|
5245
|
+
once: swiper.once.bind(swiper),
|
|
5246
|
+
off: swiper.off.bind(swiper),
|
|
5247
|
+
emit: swiper.emit.bind(swiper)
|
|
5248
|
+
});
|
|
5249
|
+
}); // Extend defaults with modules params
|
|
5250
|
+
|
|
5251
|
+
const swiperParams = extend({}, defaults, allModulesParams); // Extend defaults with passed params
|
|
5252
|
+
|
|
5253
|
+
swiper.params = extend({}, swiperParams, extendedDefaults, params);
|
|
5254
|
+
swiper.originalParams = extend({}, swiper.params);
|
|
5255
|
+
swiper.passedParams = extend({}, params); // add event listeners
|
|
5256
|
+
|
|
5257
|
+
if (swiper.params && swiper.params.on) {
|
|
5258
|
+
Object.keys(swiper.params.on).forEach(eventName => {
|
|
5259
|
+
swiper.on(eventName, swiper.params.on[eventName]);
|
|
5260
|
+
});
|
|
5261
|
+
}
|
|
5262
|
+
|
|
5263
|
+
if (swiper.params && swiper.params.onAny) {
|
|
5264
|
+
swiper.onAny(swiper.params.onAny);
|
|
5265
|
+
} // Save Dom lib
|
|
5266
|
+
|
|
5267
|
+
|
|
5268
|
+
swiper.$ = dom7.$; // Extend Swiper
|
|
5269
|
+
|
|
5270
|
+
Object.assign(swiper, {
|
|
5271
|
+
enabled: swiper.params.enabled,
|
|
5272
|
+
el,
|
|
5273
|
+
// Classes
|
|
5274
|
+
classNames: [],
|
|
5275
|
+
// Slides
|
|
5276
|
+
slides: dom7.$(),
|
|
5277
|
+
slidesGrid: [],
|
|
5278
|
+
snapGrid: [],
|
|
5279
|
+
slidesSizesGrid: [],
|
|
5280
|
+
|
|
5281
|
+
// isDirection
|
|
5282
|
+
isHorizontal() {
|
|
5283
|
+
return swiper.params.direction === 'horizontal';
|
|
5284
|
+
},
|
|
5285
|
+
|
|
5286
|
+
isVertical() {
|
|
5287
|
+
return swiper.params.direction === 'vertical';
|
|
5288
|
+
},
|
|
5289
|
+
|
|
5290
|
+
// Indexes
|
|
5291
|
+
activeIndex: 0,
|
|
5292
|
+
realIndex: 0,
|
|
5293
|
+
//
|
|
5294
|
+
isBeginning: true,
|
|
5295
|
+
isEnd: false,
|
|
5296
|
+
// Props
|
|
5297
|
+
translate: 0,
|
|
5298
|
+
previousTranslate: 0,
|
|
5299
|
+
progress: 0,
|
|
5300
|
+
velocity: 0,
|
|
5301
|
+
animating: false,
|
|
5302
|
+
// Locks
|
|
5303
|
+
allowSlideNext: swiper.params.allowSlideNext,
|
|
5304
|
+
allowSlidePrev: swiper.params.allowSlidePrev,
|
|
5305
|
+
// Touch Events
|
|
5306
|
+
touchEvents: function touchEvents() {
|
|
5307
|
+
const touch = ['touchstart', 'touchmove', 'touchend', 'touchcancel'];
|
|
5308
|
+
const desktop = ['pointerdown', 'pointermove', 'pointerup'];
|
|
5309
|
+
swiper.touchEventsTouch = {
|
|
5310
|
+
start: touch[0],
|
|
5311
|
+
move: touch[1],
|
|
5312
|
+
end: touch[2],
|
|
5313
|
+
cancel: touch[3]
|
|
5314
|
+
};
|
|
5315
|
+
swiper.touchEventsDesktop = {
|
|
5316
|
+
start: desktop[0],
|
|
5317
|
+
move: desktop[1],
|
|
5318
|
+
end: desktop[2]
|
|
5319
|
+
};
|
|
5320
|
+
return swiper.support.touch || !swiper.params.simulateTouch ? swiper.touchEventsTouch : swiper.touchEventsDesktop;
|
|
5321
|
+
}(),
|
|
5322
|
+
touchEventsData: {
|
|
5323
|
+
isTouched: undefined,
|
|
5324
|
+
isMoved: undefined,
|
|
5325
|
+
allowTouchCallbacks: undefined,
|
|
5326
|
+
touchStartTime: undefined,
|
|
5327
|
+
isScrolling: undefined,
|
|
5328
|
+
currentTranslate: undefined,
|
|
5329
|
+
startTranslate: undefined,
|
|
5330
|
+
allowThresholdMove: undefined,
|
|
5331
|
+
// Form elements to match
|
|
5332
|
+
focusableElements: swiper.params.focusableElements,
|
|
5333
|
+
// Last click time
|
|
5334
|
+
lastClickTime: now(),
|
|
5335
|
+
clickTimeout: undefined,
|
|
5336
|
+
// Velocities
|
|
5337
|
+
velocities: [],
|
|
5338
|
+
allowMomentumBounce: undefined,
|
|
5339
|
+
isTouchEvent: undefined,
|
|
5340
|
+
startMoving: undefined
|
|
5341
|
+
},
|
|
5342
|
+
// Clicks
|
|
5343
|
+
allowClick: true,
|
|
5344
|
+
// Touches
|
|
5345
|
+
allowTouchMove: swiper.params.allowTouchMove,
|
|
5346
|
+
touches: {
|
|
5347
|
+
startX: 0,
|
|
5348
|
+
startY: 0,
|
|
5349
|
+
currentX: 0,
|
|
5350
|
+
currentY: 0,
|
|
5351
|
+
diff: 0
|
|
5352
|
+
},
|
|
5353
|
+
// Images
|
|
5354
|
+
imagesToLoad: [],
|
|
5355
|
+
imagesLoaded: 0
|
|
5356
|
+
});
|
|
5357
|
+
swiper.emit('_swiper'); // Init
|
|
5358
|
+
|
|
5359
|
+
if (swiper.params.init) {
|
|
5360
|
+
swiper.init();
|
|
5361
|
+
} // Return app instance
|
|
5362
|
+
// eslint-disable-next-line no-constructor-return
|
|
5363
|
+
|
|
5364
|
+
|
|
5365
|
+
return swiper;
|
|
5366
|
+
}
|
|
5367
|
+
|
|
5368
|
+
enable() {
|
|
5369
|
+
const swiper = this;
|
|
5370
|
+
if (swiper.enabled) return;
|
|
5371
|
+
swiper.enabled = true;
|
|
5372
|
+
|
|
5373
|
+
if (swiper.params.grabCursor) {
|
|
5374
|
+
swiper.setGrabCursor();
|
|
5375
|
+
}
|
|
5376
|
+
|
|
5377
|
+
swiper.emit('enable');
|
|
5378
|
+
}
|
|
5379
|
+
|
|
5380
|
+
disable() {
|
|
5381
|
+
const swiper = this;
|
|
5382
|
+
if (!swiper.enabled) return;
|
|
5383
|
+
swiper.enabled = false;
|
|
5384
|
+
|
|
5385
|
+
if (swiper.params.grabCursor) {
|
|
5386
|
+
swiper.unsetGrabCursor();
|
|
5387
|
+
}
|
|
5388
|
+
|
|
5389
|
+
swiper.emit('disable');
|
|
5390
|
+
}
|
|
5391
|
+
|
|
5392
|
+
setProgress(progress, speed) {
|
|
5393
|
+
const swiper = this;
|
|
5394
|
+
progress = Math.min(Math.max(progress, 0), 1);
|
|
5395
|
+
const min = swiper.minTranslate();
|
|
5396
|
+
const max = swiper.maxTranslate();
|
|
5397
|
+
const current = (max - min) * progress + min;
|
|
5398
|
+
swiper.translateTo(current, typeof speed === 'undefined' ? 0 : speed);
|
|
5399
|
+
swiper.updateActiveIndex();
|
|
5400
|
+
swiper.updateSlidesClasses();
|
|
5401
|
+
}
|
|
5402
|
+
|
|
5403
|
+
emitContainerClasses() {
|
|
5404
|
+
const swiper = this;
|
|
5405
|
+
if (!swiper.params._emitClasses || !swiper.el) return;
|
|
5406
|
+
const cls = swiper.el.className.split(' ').filter(className => {
|
|
5407
|
+
return className.indexOf('swiper') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0;
|
|
5408
|
+
});
|
|
5409
|
+
swiper.emit('_containerClasses', cls.join(' '));
|
|
5410
|
+
}
|
|
5411
|
+
|
|
5412
|
+
getSlideClasses(slideEl) {
|
|
5413
|
+
const swiper = this;
|
|
5414
|
+
if (swiper.destroyed) return '';
|
|
5415
|
+
return slideEl.className.split(' ').filter(className => {
|
|
5416
|
+
return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0;
|
|
5417
|
+
}).join(' ');
|
|
5418
|
+
}
|
|
5419
|
+
|
|
5420
|
+
emitSlidesClasses() {
|
|
5421
|
+
const swiper = this;
|
|
5422
|
+
if (!swiper.params._emitClasses || !swiper.el) return;
|
|
5423
|
+
const updates = [];
|
|
5424
|
+
swiper.slides.each(slideEl => {
|
|
5425
|
+
const classNames = swiper.getSlideClasses(slideEl);
|
|
5426
|
+
updates.push({
|
|
5427
|
+
slideEl,
|
|
5428
|
+
classNames
|
|
5429
|
+
});
|
|
5430
|
+
swiper.emit('_slideClass', slideEl, classNames);
|
|
5431
|
+
});
|
|
5432
|
+
swiper.emit('_slideClasses', updates);
|
|
5433
|
+
}
|
|
5434
|
+
|
|
5435
|
+
slidesPerViewDynamic(view = 'current', exact = false) {
|
|
5436
|
+
const swiper = this;
|
|
5437
|
+
const {
|
|
5438
|
+
params,
|
|
5439
|
+
slides,
|
|
5440
|
+
slidesGrid,
|
|
5441
|
+
slidesSizesGrid,
|
|
5442
|
+
size: swiperSize,
|
|
5443
|
+
activeIndex
|
|
5444
|
+
} = swiper;
|
|
5445
|
+
let spv = 1;
|
|
5446
|
+
|
|
5447
|
+
if (params.centeredSlides) {
|
|
5448
|
+
let slideSize = slides[activeIndex].swiperSlideSize;
|
|
5449
|
+
let breakLoop;
|
|
5450
|
+
|
|
5451
|
+
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
|
5452
|
+
if (slides[i] && !breakLoop) {
|
|
5453
|
+
slideSize += slides[i].swiperSlideSize;
|
|
5454
|
+
spv += 1;
|
|
5455
|
+
if (slideSize > swiperSize) breakLoop = true;
|
|
5456
|
+
}
|
|
5457
|
+
}
|
|
5458
|
+
|
|
5459
|
+
for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
|
5460
|
+
if (slides[i] && !breakLoop) {
|
|
5461
|
+
slideSize += slides[i].swiperSlideSize;
|
|
5462
|
+
spv += 1;
|
|
5463
|
+
if (slideSize > swiperSize) breakLoop = true;
|
|
5464
|
+
}
|
|
5465
|
+
}
|
|
5466
|
+
} else {
|
|
5467
|
+
// eslint-disable-next-line
|
|
5468
|
+
if (view === 'current') {
|
|
5469
|
+
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
|
5470
|
+
const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
|
|
5471
|
+
|
|
5472
|
+
if (slideInView) {
|
|
5473
|
+
spv += 1;
|
|
5474
|
+
}
|
|
5475
|
+
}
|
|
5476
|
+
} else {
|
|
5477
|
+
// previous
|
|
5478
|
+
for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
|
5479
|
+
const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
|
|
5480
|
+
|
|
5481
|
+
if (slideInView) {
|
|
5482
|
+
spv += 1;
|
|
5483
|
+
}
|
|
5484
|
+
}
|
|
5485
|
+
}
|
|
5486
|
+
}
|
|
5487
|
+
|
|
5488
|
+
return spv;
|
|
5489
|
+
}
|
|
5490
|
+
|
|
5491
|
+
update() {
|
|
5492
|
+
const swiper = this;
|
|
5493
|
+
if (!swiper || swiper.destroyed) return;
|
|
5494
|
+
const {
|
|
5495
|
+
snapGrid,
|
|
5496
|
+
params
|
|
5497
|
+
} = swiper; // Breakpoints
|
|
5498
|
+
|
|
5499
|
+
if (params.breakpoints) {
|
|
5500
|
+
swiper.setBreakpoint();
|
|
5501
|
+
}
|
|
5502
|
+
|
|
5503
|
+
swiper.updateSize();
|
|
5504
|
+
swiper.updateSlides();
|
|
5505
|
+
swiper.updateProgress();
|
|
5506
|
+
swiper.updateSlidesClasses();
|
|
5507
|
+
|
|
5508
|
+
function setTranslate() {
|
|
5509
|
+
const translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate;
|
|
5510
|
+
const newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate());
|
|
5511
|
+
swiper.setTranslate(newTranslate);
|
|
5512
|
+
swiper.updateActiveIndex();
|
|
5513
|
+
swiper.updateSlidesClasses();
|
|
5514
|
+
}
|
|
5515
|
+
|
|
5516
|
+
let translated;
|
|
5517
|
+
|
|
5518
|
+
if (swiper.params.freeMode && swiper.params.freeMode.enabled) {
|
|
5519
|
+
setTranslate();
|
|
5520
|
+
|
|
5521
|
+
if (swiper.params.autoHeight) {
|
|
5522
|
+
swiper.updateAutoHeight();
|
|
5523
|
+
}
|
|
5524
|
+
} else {
|
|
5525
|
+
if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) {
|
|
5526
|
+
translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
5527
|
+
} else {
|
|
5528
|
+
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
5529
|
+
}
|
|
5530
|
+
|
|
5531
|
+
if (!translated) {
|
|
5532
|
+
setTranslate();
|
|
5533
|
+
}
|
|
5534
|
+
}
|
|
5535
|
+
|
|
5536
|
+
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
5537
|
+
swiper.checkOverflow();
|
|
5538
|
+
}
|
|
5539
|
+
|
|
5540
|
+
swiper.emit('update');
|
|
5541
|
+
}
|
|
5542
|
+
|
|
5543
|
+
changeDirection(newDirection, needUpdate = true) {
|
|
5544
|
+
const swiper = this;
|
|
5545
|
+
const currentDirection = swiper.params.direction;
|
|
5546
|
+
|
|
5547
|
+
if (!newDirection) {
|
|
5548
|
+
// eslint-disable-next-line
|
|
5549
|
+
newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
|
5550
|
+
}
|
|
5551
|
+
|
|
5552
|
+
if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
|
5553
|
+
return swiper;
|
|
5554
|
+
}
|
|
5555
|
+
|
|
5556
|
+
swiper.$el.removeClass(`${swiper.params.containerModifierClass}${currentDirection}`).addClass(`${swiper.params.containerModifierClass}${newDirection}`);
|
|
5557
|
+
swiper.emitContainerClasses();
|
|
5558
|
+
swiper.params.direction = newDirection;
|
|
5559
|
+
swiper.slides.each(slideEl => {
|
|
5560
|
+
if (newDirection === 'vertical') {
|
|
5561
|
+
slideEl.style.width = '';
|
|
5562
|
+
} else {
|
|
5563
|
+
slideEl.style.height = '';
|
|
5564
|
+
}
|
|
5565
|
+
});
|
|
5566
|
+
swiper.emit('changeDirection');
|
|
5567
|
+
if (needUpdate) swiper.update();
|
|
5568
|
+
return swiper;
|
|
5569
|
+
}
|
|
5570
|
+
|
|
5571
|
+
changeLanguageDirection(direction) {
|
|
5572
|
+
const swiper = this;
|
|
5573
|
+
if (swiper.rtl && direction === 'rtl' || !swiper.rtl && direction === 'ltr') return;
|
|
5574
|
+
swiper.rtl = direction === 'rtl';
|
|
5575
|
+
swiper.rtlTranslate = swiper.params.direction === 'horizontal' && swiper.rtl;
|
|
5576
|
+
|
|
5577
|
+
if (swiper.rtl) {
|
|
5578
|
+
swiper.$el.addClass(`${swiper.params.containerModifierClass}rtl`);
|
|
5579
|
+
swiper.el.dir = 'rtl';
|
|
5580
|
+
} else {
|
|
5581
|
+
swiper.$el.removeClass(`${swiper.params.containerModifierClass}rtl`);
|
|
5582
|
+
swiper.el.dir = 'ltr';
|
|
5583
|
+
}
|
|
5584
|
+
|
|
5585
|
+
swiper.update();
|
|
5586
|
+
}
|
|
5587
|
+
|
|
5588
|
+
mount(el) {
|
|
5589
|
+
const swiper = this;
|
|
5590
|
+
if (swiper.mounted) return true; // Find el
|
|
5591
|
+
|
|
5592
|
+
const $el = dom7.$(el || swiper.params.el);
|
|
5593
|
+
el = $el[0];
|
|
5594
|
+
|
|
5595
|
+
if (!el) {
|
|
5596
|
+
return false;
|
|
5597
|
+
}
|
|
5598
|
+
|
|
5599
|
+
el.swiper = swiper;
|
|
5600
|
+
|
|
5601
|
+
const getWrapperSelector = () => {
|
|
5602
|
+
return `.${(swiper.params.wrapperClass || '').trim().split(' ').join('.')}`;
|
|
5603
|
+
};
|
|
5604
|
+
|
|
5605
|
+
const getWrapper = () => {
|
|
5606
|
+
if (el && el.shadowRoot && el.shadowRoot.querySelector) {
|
|
5607
|
+
const res = dom7.$(el.shadowRoot.querySelector(getWrapperSelector())); // Children needs to return slot items
|
|
5608
|
+
|
|
5609
|
+
res.children = options => $el.children(options);
|
|
5610
|
+
|
|
5611
|
+
return res;
|
|
5612
|
+
}
|
|
5613
|
+
|
|
5614
|
+
if (!$el.children) {
|
|
5615
|
+
return dom7.$($el).children(getWrapperSelector());
|
|
5616
|
+
}
|
|
5617
|
+
|
|
5618
|
+
return $el.children(getWrapperSelector());
|
|
5619
|
+
}; // Find Wrapper
|
|
5620
|
+
|
|
5621
|
+
|
|
5622
|
+
let $wrapperEl = getWrapper();
|
|
5623
|
+
|
|
5624
|
+
if ($wrapperEl.length === 0 && swiper.params.createElements) {
|
|
5625
|
+
const document = ssrWindow.getDocument();
|
|
5626
|
+
const wrapper = document.createElement('div');
|
|
5627
|
+
$wrapperEl = dom7.$(wrapper);
|
|
5628
|
+
wrapper.className = swiper.params.wrapperClass;
|
|
5629
|
+
$el.append(wrapper);
|
|
5630
|
+
$el.children(`.${swiper.params.slideClass}`).each(slideEl => {
|
|
5631
|
+
$wrapperEl.append(slideEl);
|
|
5632
|
+
});
|
|
5633
|
+
}
|
|
5634
|
+
|
|
5635
|
+
Object.assign(swiper, {
|
|
5636
|
+
$el,
|
|
5637
|
+
el,
|
|
5638
|
+
$wrapperEl,
|
|
5639
|
+
wrapperEl: $wrapperEl[0],
|
|
5640
|
+
mounted: true,
|
|
5641
|
+
// RTL
|
|
5642
|
+
rtl: el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl',
|
|
5643
|
+
rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'),
|
|
5644
|
+
wrongRTL: $wrapperEl.css('display') === '-webkit-box'
|
|
5645
|
+
});
|
|
5646
|
+
return true;
|
|
5647
|
+
}
|
|
5648
|
+
|
|
5649
|
+
init(el) {
|
|
5650
|
+
const swiper = this;
|
|
5651
|
+
if (swiper.initialized) return swiper;
|
|
5652
|
+
const mounted = swiper.mount(el);
|
|
5653
|
+
if (mounted === false) return swiper;
|
|
5654
|
+
swiper.emit('beforeInit'); // Set breakpoint
|
|
5655
|
+
|
|
5656
|
+
if (swiper.params.breakpoints) {
|
|
5657
|
+
swiper.setBreakpoint();
|
|
5658
|
+
} // Add Classes
|
|
5659
|
+
|
|
5660
|
+
|
|
5661
|
+
swiper.addClasses(); // Create loop
|
|
5662
|
+
|
|
5663
|
+
if (swiper.params.loop) {
|
|
5664
|
+
swiper.loopCreate();
|
|
5665
|
+
} // Update size
|
|
5666
|
+
|
|
5667
|
+
|
|
5668
|
+
swiper.updateSize(); // Update slides
|
|
5669
|
+
|
|
5670
|
+
swiper.updateSlides();
|
|
5671
|
+
|
|
5672
|
+
if (swiper.params.watchOverflow) {
|
|
5673
|
+
swiper.checkOverflow();
|
|
5674
|
+
} // Set Grab Cursor
|
|
5675
|
+
|
|
5676
|
+
|
|
5677
|
+
if (swiper.params.grabCursor && swiper.enabled) {
|
|
5678
|
+
swiper.setGrabCursor();
|
|
5679
|
+
}
|
|
5680
|
+
|
|
5681
|
+
if (swiper.params.preloadImages) {
|
|
5682
|
+
swiper.preloadImages();
|
|
5683
|
+
} // Slide To Initial Slide
|
|
5684
|
+
|
|
5685
|
+
|
|
5686
|
+
if (swiper.params.loop) {
|
|
5687
|
+
swiper.slideTo(swiper.params.initialSlide + swiper.loopedSlides, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
5688
|
+
} else {
|
|
5689
|
+
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
5690
|
+
} // Attach events
|
|
5691
|
+
|
|
5692
|
+
|
|
5693
|
+
swiper.attachEvents(); // Init Flag
|
|
5694
|
+
|
|
5695
|
+
swiper.initialized = true; // Emit
|
|
5696
|
+
|
|
5697
|
+
swiper.emit('init');
|
|
5698
|
+
swiper.emit('afterInit');
|
|
5699
|
+
return swiper;
|
|
5700
|
+
}
|
|
5701
|
+
|
|
5702
|
+
destroy(deleteInstance = true, cleanStyles = true) {
|
|
5703
|
+
const swiper = this;
|
|
5704
|
+
const {
|
|
5705
|
+
params,
|
|
5706
|
+
$el,
|
|
5707
|
+
$wrapperEl,
|
|
5708
|
+
slides
|
|
5709
|
+
} = swiper;
|
|
5710
|
+
|
|
5711
|
+
if (typeof swiper.params === 'undefined' || swiper.destroyed) {
|
|
5712
|
+
return null;
|
|
5713
|
+
}
|
|
5714
|
+
|
|
5715
|
+
swiper.emit('beforeDestroy'); // Init Flag
|
|
5716
|
+
|
|
5717
|
+
swiper.initialized = false; // Detach events
|
|
5718
|
+
|
|
5719
|
+
swiper.detachEvents(); // Destroy loop
|
|
5720
|
+
|
|
5721
|
+
if (params.loop) {
|
|
5722
|
+
swiper.loopDestroy();
|
|
5723
|
+
} // Cleanup styles
|
|
5724
|
+
|
|
5725
|
+
|
|
5726
|
+
if (cleanStyles) {
|
|
5727
|
+
swiper.removeClasses();
|
|
5728
|
+
$el.removeAttr('style');
|
|
5729
|
+
$wrapperEl.removeAttr('style');
|
|
5730
|
+
|
|
5731
|
+
if (slides && slides.length) {
|
|
5732
|
+
slides.removeClass([params.slideVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass].join(' ')).removeAttr('style').removeAttr('data-swiper-slide-index');
|
|
5733
|
+
}
|
|
5734
|
+
}
|
|
5735
|
+
|
|
5736
|
+
swiper.emit('destroy'); // Detach emitter events
|
|
5737
|
+
|
|
5738
|
+
Object.keys(swiper.eventsListeners).forEach(eventName => {
|
|
5739
|
+
swiper.off(eventName);
|
|
5740
|
+
});
|
|
5741
|
+
|
|
5742
|
+
if (deleteInstance !== false) {
|
|
5743
|
+
swiper.$el[0].swiper = null;
|
|
5744
|
+
deleteProps(swiper);
|
|
5745
|
+
}
|
|
5746
|
+
|
|
5747
|
+
swiper.destroyed = true;
|
|
5748
|
+
return null;
|
|
5749
|
+
}
|
|
5750
|
+
|
|
5751
|
+
static extendDefaults(newDefaults) {
|
|
5752
|
+
extend(extendedDefaults, newDefaults);
|
|
5753
|
+
}
|
|
5754
|
+
|
|
5755
|
+
static get extendedDefaults() {
|
|
5756
|
+
return extendedDefaults;
|
|
5757
|
+
}
|
|
5758
|
+
|
|
5759
|
+
static get defaults() {
|
|
5760
|
+
return defaults;
|
|
5761
|
+
}
|
|
5762
|
+
|
|
5763
|
+
static installModule(mod) {
|
|
5764
|
+
if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = [];
|
|
5765
|
+
const modules = Swiper.prototype.__modules__;
|
|
5766
|
+
|
|
5767
|
+
if (typeof mod === 'function' && modules.indexOf(mod) < 0) {
|
|
5768
|
+
modules.push(mod);
|
|
5769
|
+
}
|
|
5770
|
+
}
|
|
5771
|
+
|
|
5772
|
+
static use(module) {
|
|
5773
|
+
if (Array.isArray(module)) {
|
|
5774
|
+
module.forEach(m => Swiper.installModule(m));
|
|
5775
|
+
return Swiper;
|
|
5776
|
+
}
|
|
5777
|
+
|
|
5778
|
+
Swiper.installModule(module);
|
|
5779
|
+
return Swiper;
|
|
5780
|
+
}
|
|
5781
|
+
|
|
5782
|
+
}
|
|
5783
|
+
|
|
5784
|
+
Object.keys(prototypes).forEach(prototypeGroup => {
|
|
5785
|
+
Object.keys(prototypes[prototypeGroup]).forEach(protoMethod => {
|
|
5786
|
+
Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod];
|
|
5787
|
+
});
|
|
5788
|
+
});
|
|
5789
|
+
Swiper.use([Resize, Observer]);
|
|
5790
|
+
|
|
5791
|
+
/* eslint no-underscore-dangle: "off" */
|
|
5792
|
+
function Autoplay({
|
|
5793
|
+
swiper,
|
|
5794
|
+
extendParams,
|
|
5795
|
+
on,
|
|
5796
|
+
emit
|
|
5797
|
+
}) {
|
|
5798
|
+
let timeout;
|
|
5799
|
+
swiper.autoplay = {
|
|
5800
|
+
running: false,
|
|
5801
|
+
paused: false
|
|
5802
|
+
};
|
|
5803
|
+
extendParams({
|
|
5804
|
+
autoplay: {
|
|
5805
|
+
enabled: false,
|
|
5806
|
+
delay: 3000,
|
|
5807
|
+
waitForTransition: true,
|
|
5808
|
+
disableOnInteraction: true,
|
|
5809
|
+
stopOnLastSlide: false,
|
|
5810
|
+
reverseDirection: false,
|
|
5811
|
+
pauseOnMouseEnter: false
|
|
5812
|
+
}
|
|
5813
|
+
});
|
|
5814
|
+
|
|
5815
|
+
function run() {
|
|
5816
|
+
if (!swiper.size) {
|
|
5817
|
+
swiper.autoplay.running = false;
|
|
5818
|
+
swiper.autoplay.paused = false;
|
|
5819
|
+
return;
|
|
5820
|
+
}
|
|
5821
|
+
|
|
5822
|
+
const $activeSlideEl = swiper.slides.eq(swiper.activeIndex);
|
|
5823
|
+
let delay = swiper.params.autoplay.delay;
|
|
5824
|
+
|
|
5825
|
+
if ($activeSlideEl.attr('data-swiper-autoplay')) {
|
|
5826
|
+
delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay;
|
|
5827
|
+
}
|
|
5828
|
+
|
|
5829
|
+
clearTimeout(timeout);
|
|
5830
|
+
timeout = nextTick(() => {
|
|
5831
|
+
let autoplayResult;
|
|
5832
|
+
|
|
5833
|
+
if (swiper.params.autoplay.reverseDirection) {
|
|
5834
|
+
if (swiper.params.loop) {
|
|
5835
|
+
swiper.loopFix();
|
|
5836
|
+
autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
|
|
5837
|
+
emit('autoplay');
|
|
5838
|
+
} else if (!swiper.isBeginning) {
|
|
5839
|
+
autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
|
|
5840
|
+
emit('autoplay');
|
|
5841
|
+
} else if (!swiper.params.autoplay.stopOnLastSlide) {
|
|
5842
|
+
autoplayResult = swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true);
|
|
5843
|
+
emit('autoplay');
|
|
5844
|
+
} else {
|
|
5845
|
+
stop();
|
|
5846
|
+
}
|
|
5847
|
+
} else if (swiper.params.loop) {
|
|
5848
|
+
swiper.loopFix();
|
|
5849
|
+
autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
|
|
5850
|
+
emit('autoplay');
|
|
5851
|
+
} else if (!swiper.isEnd) {
|
|
5852
|
+
autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
|
|
5853
|
+
emit('autoplay');
|
|
5854
|
+
} else if (!swiper.params.autoplay.stopOnLastSlide) {
|
|
5855
|
+
autoplayResult = swiper.slideTo(0, swiper.params.speed, true, true);
|
|
5856
|
+
emit('autoplay');
|
|
5857
|
+
} else {
|
|
5858
|
+
stop();
|
|
5859
|
+
}
|
|
5860
|
+
|
|
5861
|
+
if (swiper.params.cssMode && swiper.autoplay.running) run();else if (autoplayResult === false) {
|
|
5862
|
+
run();
|
|
5863
|
+
}
|
|
5864
|
+
}, delay);
|
|
5865
|
+
}
|
|
5866
|
+
|
|
5867
|
+
function start() {
|
|
5868
|
+
if (typeof timeout !== 'undefined') return false;
|
|
5869
|
+
if (swiper.autoplay.running) return false;
|
|
5870
|
+
swiper.autoplay.running = true;
|
|
5871
|
+
emit('autoplayStart');
|
|
5872
|
+
run();
|
|
5873
|
+
return true;
|
|
5874
|
+
}
|
|
5875
|
+
|
|
5876
|
+
function stop() {
|
|
5877
|
+
if (!swiper.autoplay.running) return false;
|
|
5878
|
+
if (typeof timeout === 'undefined') return false;
|
|
5879
|
+
|
|
5880
|
+
if (timeout) {
|
|
5881
|
+
clearTimeout(timeout);
|
|
5882
|
+
timeout = undefined;
|
|
5883
|
+
}
|
|
5884
|
+
|
|
5885
|
+
swiper.autoplay.running = false;
|
|
5886
|
+
emit('autoplayStop');
|
|
5887
|
+
return true;
|
|
5888
|
+
}
|
|
5889
|
+
|
|
5890
|
+
function pause(speed) {
|
|
5891
|
+
if (!swiper.autoplay.running) return;
|
|
5892
|
+
if (swiper.autoplay.paused) return;
|
|
5893
|
+
if (timeout) clearTimeout(timeout);
|
|
5894
|
+
swiper.autoplay.paused = true;
|
|
5895
|
+
|
|
5896
|
+
if (speed === 0 || !swiper.params.autoplay.waitForTransition) {
|
|
5897
|
+
swiper.autoplay.paused = false;
|
|
5898
|
+
run();
|
|
5899
|
+
} else {
|
|
5900
|
+
['transitionend', 'webkitTransitionEnd'].forEach(event => {
|
|
5901
|
+
swiper.$wrapperEl[0].addEventListener(event, onTransitionEnd);
|
|
5902
|
+
});
|
|
5903
|
+
}
|
|
5904
|
+
}
|
|
5905
|
+
|
|
5906
|
+
function onVisibilityChange() {
|
|
5907
|
+
const document = ssrWindow.getDocument();
|
|
5908
|
+
|
|
5909
|
+
if (document.visibilityState === 'hidden' && swiper.autoplay.running) {
|
|
5910
|
+
pause();
|
|
5911
|
+
}
|
|
5912
|
+
|
|
5913
|
+
if (document.visibilityState === 'visible' && swiper.autoplay.paused) {
|
|
5914
|
+
run();
|
|
5915
|
+
swiper.autoplay.paused = false;
|
|
5916
|
+
}
|
|
5917
|
+
}
|
|
5918
|
+
|
|
5919
|
+
function onTransitionEnd(e) {
|
|
5920
|
+
if (!swiper || swiper.destroyed || !swiper.$wrapperEl) return;
|
|
5921
|
+
if (e.target !== swiper.$wrapperEl[0]) return;
|
|
5922
|
+
['transitionend', 'webkitTransitionEnd'].forEach(event => {
|
|
5923
|
+
swiper.$wrapperEl[0].removeEventListener(event, onTransitionEnd);
|
|
5924
|
+
});
|
|
5925
|
+
swiper.autoplay.paused = false;
|
|
5926
|
+
|
|
5927
|
+
if (!swiper.autoplay.running) {
|
|
5928
|
+
stop();
|
|
5929
|
+
} else {
|
|
5930
|
+
run();
|
|
5931
|
+
}
|
|
5932
|
+
}
|
|
5933
|
+
|
|
5934
|
+
function onMouseEnter() {
|
|
5935
|
+
if (swiper.params.autoplay.disableOnInteraction) {
|
|
5936
|
+
stop();
|
|
5937
|
+
} else {
|
|
5938
|
+
emit('autoplayPause');
|
|
5939
|
+
pause();
|
|
5940
|
+
}
|
|
5941
|
+
|
|
5942
|
+
['transitionend', 'webkitTransitionEnd'].forEach(event => {
|
|
5943
|
+
swiper.$wrapperEl[0].removeEventListener(event, onTransitionEnd);
|
|
5944
|
+
});
|
|
5945
|
+
}
|
|
5946
|
+
|
|
5947
|
+
function onMouseLeave() {
|
|
5948
|
+
if (swiper.params.autoplay.disableOnInteraction) {
|
|
5949
|
+
return;
|
|
5950
|
+
}
|
|
5951
|
+
|
|
5952
|
+
swiper.autoplay.paused = false;
|
|
5953
|
+
emit('autoplayResume');
|
|
5954
|
+
run();
|
|
5955
|
+
}
|
|
5956
|
+
|
|
5957
|
+
function attachMouseEvents() {
|
|
5958
|
+
if (swiper.params.autoplay.pauseOnMouseEnter) {
|
|
5959
|
+
swiper.$el.on('mouseenter', onMouseEnter);
|
|
5960
|
+
swiper.$el.on('mouseleave', onMouseLeave);
|
|
5961
|
+
}
|
|
5962
|
+
}
|
|
5963
|
+
|
|
5964
|
+
function detachMouseEvents() {
|
|
5965
|
+
swiper.$el.off('mouseenter', onMouseEnter);
|
|
5966
|
+
swiper.$el.off('mouseleave', onMouseLeave);
|
|
5967
|
+
}
|
|
5968
|
+
|
|
5969
|
+
on('init', () => {
|
|
5970
|
+
if (swiper.params.autoplay.enabled) {
|
|
5971
|
+
start();
|
|
5972
|
+
const document = ssrWindow.getDocument();
|
|
5973
|
+
document.addEventListener('visibilitychange', onVisibilityChange);
|
|
5974
|
+
attachMouseEvents();
|
|
5975
|
+
}
|
|
5976
|
+
});
|
|
5977
|
+
on('beforeTransitionStart', (_s, speed, internal) => {
|
|
5978
|
+
if (swiper.autoplay.running) {
|
|
5979
|
+
if (internal || !swiper.params.autoplay.disableOnInteraction) {
|
|
5980
|
+
swiper.autoplay.pause(speed);
|
|
5981
|
+
} else {
|
|
5982
|
+
stop();
|
|
5983
|
+
}
|
|
5984
|
+
}
|
|
5985
|
+
});
|
|
5986
|
+
on('sliderFirstMove', () => {
|
|
5987
|
+
if (swiper.autoplay.running) {
|
|
5988
|
+
if (swiper.params.autoplay.disableOnInteraction) {
|
|
5989
|
+
stop();
|
|
5990
|
+
} else {
|
|
5991
|
+
pause();
|
|
5992
|
+
}
|
|
5993
|
+
}
|
|
5994
|
+
});
|
|
5995
|
+
on('touchEnd', () => {
|
|
5996
|
+
if (swiper.params.cssMode && swiper.autoplay.paused && !swiper.params.autoplay.disableOnInteraction) {
|
|
5997
|
+
run();
|
|
5998
|
+
}
|
|
5999
|
+
});
|
|
6000
|
+
on('destroy', () => {
|
|
6001
|
+
detachMouseEvents();
|
|
6002
|
+
|
|
6003
|
+
if (swiper.autoplay.running) {
|
|
6004
|
+
stop();
|
|
6005
|
+
}
|
|
6006
|
+
|
|
6007
|
+
const document = ssrWindow.getDocument();
|
|
6008
|
+
document.removeEventListener('visibilitychange', onVisibilityChange);
|
|
6009
|
+
});
|
|
6010
|
+
Object.assign(swiper.autoplay, {
|
|
6011
|
+
pause,
|
|
6012
|
+
run,
|
|
6013
|
+
start,
|
|
6014
|
+
stop
|
|
6015
|
+
});
|
|
6016
|
+
}
|
|
6017
|
+
|
|
1916
6018
|
/* src/PanoTagPlugin/Components/Common/MediaItem.svelte generated by Svelte v3.50.1 */
|
|
1917
6019
|
|
|
1918
6020
|
function add_css$e(target) {
|
|
@@ -2192,7 +6294,7 @@ function create_if_block$a(ctx) {
|
|
|
2192
6294
|
internal.add_render_callback(() => {
|
|
2193
6295
|
if (div_outro) div_outro.end(1);
|
|
2194
6296
|
|
|
2195
|
-
div_intro = internal.create_in_transition(div, transition.fly, /*animation*/ ctx[5]
|
|
6297
|
+
div_intro = internal.create_in_transition(div, transition$1.fly, /*animation*/ ctx[5]
|
|
2196
6298
|
? {
|
|
2197
6299
|
y: 4,
|
|
2198
6300
|
duration: /*duration*/ ctx[3],
|
|
@@ -2212,7 +6314,7 @@ function create_if_block$a(ctx) {
|
|
|
2212
6314
|
if (div_intro) div_intro.invalidate();
|
|
2213
6315
|
|
|
2214
6316
|
if (local) {
|
|
2215
|
-
div_outro = internal.create_out_transition(div, transition.fly, /*animation*/ ctx[5]
|
|
6317
|
+
div_outro = internal.create_out_transition(div, transition$1.fly, /*animation*/ ctx[5]
|
|
2216
6318
|
? {
|
|
2217
6319
|
y: 4,
|
|
2218
6320
|
duration: /*duration*/ ctx[3],
|
|
@@ -2275,13 +6377,13 @@ function create_else_block$1(ctx) {
|
|
|
2275
6377
|
|
|
2276
6378
|
// (31:4) {#if carouselEnabled}
|
|
2277
6379
|
function create_if_block_1$6(ctx) {
|
|
2278
|
-
let swiper
|
|
6380
|
+
let swiper;
|
|
2279
6381
|
let current;
|
|
2280
6382
|
|
|
2281
|
-
swiper
|
|
6383
|
+
swiper = new svelte$1.Swiper({
|
|
2282
6384
|
props: {
|
|
2283
6385
|
style: "height: 100%",
|
|
2284
|
-
modules: [
|
|
6386
|
+
modules: [Autoplay],
|
|
2285
6387
|
spaceBetween: 30,
|
|
2286
6388
|
autoplay: /*autoplay*/ ctx[10]
|
|
2287
6389
|
? noTypecheck({
|
|
@@ -2296,14 +6398,14 @@ function create_if_block_1$6(ctx) {
|
|
|
2296
6398
|
}
|
|
2297
6399
|
});
|
|
2298
6400
|
|
|
2299
|
-
swiper
|
|
6401
|
+
swiper.$on("slideChange", /*slideChange_handler*/ ctx[13]);
|
|
2300
6402
|
|
|
2301
6403
|
return {
|
|
2302
6404
|
c() {
|
|
2303
|
-
internal.create_component(swiper
|
|
6405
|
+
internal.create_component(swiper.$$.fragment);
|
|
2304
6406
|
},
|
|
2305
6407
|
m(target, anchor) {
|
|
2306
|
-
internal.mount_component(swiper
|
|
6408
|
+
internal.mount_component(swiper, target, anchor);
|
|
2307
6409
|
current = true;
|
|
2308
6410
|
},
|
|
2309
6411
|
p(ctx, dirty) {
|
|
@@ -2321,19 +6423,19 @@ function create_if_block_1$6(ctx) {
|
|
|
2321
6423
|
swiper_changes.$$scope = { dirty, ctx };
|
|
2322
6424
|
}
|
|
2323
6425
|
|
|
2324
|
-
swiper
|
|
6426
|
+
swiper.$set(swiper_changes);
|
|
2325
6427
|
},
|
|
2326
6428
|
i(local) {
|
|
2327
6429
|
if (current) return;
|
|
2328
|
-
internal.transition_in(swiper
|
|
6430
|
+
internal.transition_in(swiper.$$.fragment, local);
|
|
2329
6431
|
current = true;
|
|
2330
6432
|
},
|
|
2331
6433
|
o(local) {
|
|
2332
|
-
internal.transition_out(swiper
|
|
6434
|
+
internal.transition_out(swiper.$$.fragment, local);
|
|
2333
6435
|
current = false;
|
|
2334
6436
|
},
|
|
2335
6437
|
d(detaching) {
|
|
2336
|
-
internal.destroy_component(swiper
|
|
6438
|
+
internal.destroy_component(swiper, detaching);
|
|
2337
6439
|
}
|
|
2338
6440
|
};
|
|
2339
6441
|
}
|
|
@@ -3743,7 +7845,7 @@ function create_if_block$7(ctx) {
|
|
|
3743
7845
|
internal.add_render_callback(() => {
|
|
3744
7846
|
if (div1_outro) div1_outro.end(1);
|
|
3745
7847
|
|
|
3746
|
-
div1_intro = internal.create_in_transition(div1, transition.fade, {
|
|
7848
|
+
div1_intro = internal.create_in_transition(div1, transition$1.fade, {
|
|
3747
7849
|
duration: /*duration*/ ctx[2],
|
|
3748
7850
|
delay: /*inDelay*/ ctx[0],
|
|
3749
7851
|
easing: easing.cubicInOut
|
|
@@ -3760,7 +7862,7 @@ function create_if_block$7(ctx) {
|
|
|
3760
7862
|
if (div1_intro) div1_intro.invalidate();
|
|
3761
7863
|
|
|
3762
7864
|
if (local) {
|
|
3763
|
-
div1_outro = internal.create_out_transition(div1, transition.fade, {
|
|
7865
|
+
div1_outro = internal.create_out_transition(div1, transition$1.fade, {
|
|
3764
7866
|
duration: /*duration*/ ctx[2],
|
|
3765
7867
|
delay: /*outDelay*/ ctx[1],
|
|
3766
7868
|
easing: easing.cubicInOut
|