1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,9387 @@ |
1 |
+/** |
|
2 |
+ * Swiper 6.3.3 |
|
3 |
+ * Most modern mobile touch slider and framework with hardware accelerated transitions |
|
4 |
+ * http://swiperjs.com |
|
5 |
+ * |
|
6 |
+ * Copyright 2014-2020 Vladimir Kharlampidi |
|
7 |
+ * |
|
8 |
+ * Released under the MIT License |
|
9 |
+ * |
|
10 |
+ * Released on: October 9, 2020 |
|
11 |
+ */ |
|
12 |
+ |
|
13 |
+function _defineProperties(target, props) { |
|
14 |
+ for (var i = 0; i < props.length; i++) { |
|
15 |
+ var descriptor = props[i]; |
|
16 |
+ descriptor.enumerable = descriptor.enumerable || false; |
|
17 |
+ descriptor.configurable = true; |
|
18 |
+ if ("value" in descriptor) descriptor.writable = true; |
|
19 |
+ Object.defineProperty(target, descriptor.key, descriptor); |
|
20 |
+ } |
|
21 |
+} |
|
22 |
+ |
|
23 |
+function _createClass(Constructor, protoProps, staticProps) { |
|
24 |
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
|
25 |
+ if (staticProps) _defineProperties(Constructor, staticProps); |
|
26 |
+ return Constructor; |
|
27 |
+} |
|
28 |
+ |
|
29 |
+function _extends() { |
|
30 |
+ _extends = Object.assign || function (target) { |
|
31 |
+ for (var i = 1; i < arguments.length; i++) { |
|
32 |
+ var source = arguments[i]; |
|
33 |
+ |
|
34 |
+ for (var key in source) { |
|
35 |
+ if (Object.prototype.hasOwnProperty.call(source, key)) { |
|
36 |
+ target[key] = source[key]; |
|
37 |
+ } |
|
38 |
+ } |
|
39 |
+ } |
|
40 |
+ |
|
41 |
+ return target; |
|
42 |
+ }; |
|
43 |
+ |
|
44 |
+ return _extends.apply(this, arguments); |
|
45 |
+} |
|
46 |
+ |
|
47 |
+/** |
|
48 |
+ * SSR Window 3.0.0-alpha.4 |
|
49 |
+ * Better handling for window object in SSR environment |
|
50 |
+ * https://github.com/nolimits4web/ssr-window |
|
51 |
+ * |
|
52 |
+ * Copyright 2020, Vladimir Kharlampidi |
|
53 |
+ * |
|
54 |
+ * Licensed under MIT |
|
55 |
+ * |
|
56 |
+ * Released on: May 20, 2020 |
|
57 |
+ */ |
|
58 |
+ |
|
59 |
+/* eslint-disable no-param-reassign */ |
|
60 |
+function isObject(obj) { |
|
61 |
+ return obj !== null && typeof obj === 'object' && 'constructor' in obj && obj.constructor === Object; |
|
62 |
+} |
|
63 |
+ |
|
64 |
+function extend(target, src) { |
|
65 |
+ if (target === void 0) { |
|
66 |
+ target = {}; |
|
67 |
+ } |
|
68 |
+ |
|
69 |
+ if (src === void 0) { |
|
70 |
+ src = {}; |
|
71 |
+ } |
|
72 |
+ |
|
73 |
+ Object.keys(src).forEach(function (key) { |
|
74 |
+ if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject(src[key]) && isObject(target[key]) && Object.keys(src[key]).length > 0) { |
|
75 |
+ extend(target[key], src[key]); |
|
76 |
+ } |
|
77 |
+ }); |
|
78 |
+} |
|
79 |
+ |
|
80 |
+var ssrDocument = { |
|
81 |
+ body: {}, |
|
82 |
+ addEventListener: function addEventListener() {}, |
|
83 |
+ removeEventListener: function removeEventListener() {}, |
|
84 |
+ activeElement: { |
|
85 |
+ blur: function blur() {}, |
|
86 |
+ nodeName: '' |
|
87 |
+ }, |
|
88 |
+ querySelector: function querySelector() { |
|
89 |
+ return null; |
|
90 |
+ }, |
|
91 |
+ querySelectorAll: function querySelectorAll() { |
|
92 |
+ return []; |
|
93 |
+ }, |
|
94 |
+ getElementById: function getElementById() { |
|
95 |
+ return null; |
|
96 |
+ }, |
|
97 |
+ createEvent: function createEvent() { |
|
98 |
+ return { |
|
99 |
+ initEvent: function initEvent() {} |
|
100 |
+ }; |
|
101 |
+ }, |
|
102 |
+ createElement: function createElement() { |
|
103 |
+ return { |
|
104 |
+ children: [], |
|
105 |
+ childNodes: [], |
|
106 |
+ style: {}, |
|
107 |
+ setAttribute: function setAttribute() {}, |
|
108 |
+ getElementsByTagName: function getElementsByTagName() { |
|
109 |
+ return []; |
|
110 |
+ } |
|
111 |
+ }; |
|
112 |
+ }, |
|
113 |
+ createElementNS: function createElementNS() { |
|
114 |
+ return {}; |
|
115 |
+ }, |
|
116 |
+ importNode: function importNode() { |
|
117 |
+ return null; |
|
118 |
+ }, |
|
119 |
+ location: { |
|
120 |
+ hash: '', |
|
121 |
+ host: '', |
|
122 |
+ hostname: '', |
|
123 |
+ href: '', |
|
124 |
+ origin: '', |
|
125 |
+ pathname: '', |
|
126 |
+ protocol: '', |
|
127 |
+ search: '' |
|
128 |
+ } |
|
129 |
+}; |
|
130 |
+ |
|
131 |
+function getDocument() { |
|
132 |
+ var doc = typeof document !== 'undefined' ? document : {}; |
|
133 |
+ extend(doc, ssrDocument); |
|
134 |
+ return doc; |
|
135 |
+} |
|
136 |
+ |
|
137 |
+var ssrWindow = { |
|
138 |
+ document: ssrDocument, |
|
139 |
+ navigator: { |
|
140 |
+ userAgent: '' |
|
141 |
+ }, |
|
142 |
+ location: { |
|
143 |
+ hash: '', |
|
144 |
+ host: '', |
|
145 |
+ hostname: '', |
|
146 |
+ href: '', |
|
147 |
+ origin: '', |
|
148 |
+ pathname: '', |
|
149 |
+ protocol: '', |
|
150 |
+ search: '' |
|
151 |
+ }, |
|
152 |
+ history: { |
|
153 |
+ replaceState: function replaceState() {}, |
|
154 |
+ pushState: function pushState() {}, |
|
155 |
+ go: function go() {}, |
|
156 |
+ back: function back() {} |
|
157 |
+ }, |
|
158 |
+ CustomEvent: function CustomEvent() { |
|
159 |
+ return this; |
|
160 |
+ }, |
|
161 |
+ addEventListener: function addEventListener() {}, |
|
162 |
+ removeEventListener: function removeEventListener() {}, |
|
163 |
+ getComputedStyle: function getComputedStyle() { |
|
164 |
+ return { |
|
165 |
+ getPropertyValue: function getPropertyValue() { |
|
166 |
+ return ''; |
|
167 |
+ } |
|
168 |
+ }; |
|
169 |
+ }, |
|
170 |
+ Image: function Image() {}, |
|
171 |
+ Date: function Date() {}, |
|
172 |
+ screen: {}, |
|
173 |
+ setTimeout: function setTimeout() {}, |
|
174 |
+ clearTimeout: function clearTimeout() {}, |
|
175 |
+ matchMedia: function matchMedia() { |
|
176 |
+ return {}; |
|
177 |
+ }, |
|
178 |
+ requestAnimationFrame: function requestAnimationFrame(callback) { |
|
179 |
+ if (typeof setTimeout === 'undefined') { |
|
180 |
+ callback(); |
|
181 |
+ return null; |
|
182 |
+ } |
|
183 |
+ |
|
184 |
+ return setTimeout(callback, 0); |
|
185 |
+ }, |
|
186 |
+ cancelAnimationFrame: function cancelAnimationFrame(id) { |
|
187 |
+ if (typeof setTimeout === 'undefined') { |
|
188 |
+ return; |
|
189 |
+ } |
|
190 |
+ |
|
191 |
+ clearTimeout(id); |
|
192 |
+ } |
|
193 |
+}; |
|
194 |
+ |
|
195 |
+function getWindow() { |
|
196 |
+ var win = typeof window !== 'undefined' ? window : {}; |
|
197 |
+ extend(win, ssrWindow); |
|
198 |
+ return win; |
|
199 |
+} |
|
200 |
+ |
|
201 |
+/** |
|
202 |
+ * Dom7 3.0.0-alpha.7 |
|
203 |
+ * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API |
|
204 |
+ * https://framework7.io/docs/dom7.html |
|
205 |
+ * |
|
206 |
+ * Copyright 2020, Vladimir Kharlampidi |
|
207 |
+ * |
|
208 |
+ * Licensed under MIT |
|
209 |
+ * |
|
210 |
+ * Released on: July 14, 2020 |
|
211 |
+ */ |
|
212 |
+ |
|
213 |
+function _inheritsLoose(subClass, superClass) { |
|
214 |
+ subClass.prototype = Object.create(superClass.prototype); |
|
215 |
+ subClass.prototype.constructor = subClass; |
|
216 |
+ subClass.__proto__ = superClass; |
|
217 |
+} |
|
218 |
+ |
|
219 |
+function _getPrototypeOf(o) { |
|
220 |
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { |
|
221 |
+ return o.__proto__ || Object.getPrototypeOf(o); |
|
222 |
+ }; |
|
223 |
+ return _getPrototypeOf(o); |
|
224 |
+} |
|
225 |
+ |
|
226 |
+function _setPrototypeOf(o, p) { |
|
227 |
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { |
|
228 |
+ o.__proto__ = p; |
|
229 |
+ return o; |
|
230 |
+ }; |
|
231 |
+ |
|
232 |
+ return _setPrototypeOf(o, p); |
|
233 |
+} |
|
234 |
+ |
|
235 |
+function _isNativeReflectConstruct() { |
|
236 |
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false; |
|
237 |
+ if (Reflect.construct.sham) return false; |
|
238 |
+ if (typeof Proxy === "function") return true; |
|
239 |
+ |
|
240 |
+ try { |
|
241 |
+ Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); |
|
242 |
+ return true; |
|
243 |
+ } catch (e) { |
|
244 |
+ return false; |
|
245 |
+ } |
|
246 |
+} |
|
247 |
+ |
|
248 |
+function _construct(Parent, args, Class) { |
|
249 |
+ if (_isNativeReflectConstruct()) { |
|
250 |
+ _construct = Reflect.construct; |
|
251 |
+ } else { |
|
252 |
+ _construct = function _construct(Parent, args, Class) { |
|
253 |
+ var a = [null]; |
|
254 |
+ a.push.apply(a, args); |
|
255 |
+ var Constructor = Function.bind.apply(Parent, a); |
|
256 |
+ var instance = new Constructor(); |
|
257 |
+ if (Class) _setPrototypeOf(instance, Class.prototype); |
|
258 |
+ return instance; |
|
259 |
+ }; |
|
260 |
+ } |
|
261 |
+ |
|
262 |
+ return _construct.apply(null, arguments); |
|
263 |
+} |
|
264 |
+ |
|
265 |
+function _isNativeFunction(fn) { |
|
266 |
+ return Function.toString.call(fn).indexOf("[native code]") !== -1; |
|
267 |
+} |
|
268 |
+ |
|
269 |
+function _wrapNativeSuper(Class) { |
|
270 |
+ var _cache = typeof Map === "function" ? new Map() : undefined; |
|
271 |
+ |
|
272 |
+ _wrapNativeSuper = function _wrapNativeSuper(Class) { |
|
273 |
+ if (Class === null || !_isNativeFunction(Class)) return Class; |
|
274 |
+ |
|
275 |
+ if (typeof Class !== "function") { |
|
276 |
+ throw new TypeError("Super expression must either be null or a function"); |
|
277 |
+ } |
|
278 |
+ |
|
279 |
+ if (typeof _cache !== "undefined") { |
|
280 |
+ if (_cache.has(Class)) return _cache.get(Class); |
|
281 |
+ |
|
282 |
+ _cache.set(Class, Wrapper); |
|
283 |
+ } |
|
284 |
+ |
|
285 |
+ function Wrapper() { |
|
286 |
+ return _construct(Class, arguments, _getPrototypeOf(this).constructor); |
|
287 |
+ } |
|
288 |
+ |
|
289 |
+ Wrapper.prototype = Object.create(Class.prototype, { |
|
290 |
+ constructor: { |
|
291 |
+ value: Wrapper, |
|
292 |
+ enumerable: false, |
|
293 |
+ writable: true, |
|
294 |
+ configurable: true |
|
295 |
+ } |
|
296 |
+ }); |
|
297 |
+ return _setPrototypeOf(Wrapper, Class); |
|
298 |
+ }; |
|
299 |
+ |
|
300 |
+ return _wrapNativeSuper(Class); |
|
301 |
+} |
|
302 |
+ |
|
303 |
+function _assertThisInitialized(self) { |
|
304 |
+ if (self === void 0) { |
|
305 |
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); |
|
306 |
+ } |
|
307 |
+ |
|
308 |
+ return self; |
|
309 |
+} |
|
310 |
+/* eslint-disable no-proto */ |
|
311 |
+ |
|
312 |
+ |
|
313 |
+function makeReactive(obj) { |
|
314 |
+ var proto = obj.__proto__; |
|
315 |
+ Object.defineProperty(obj, '__proto__', { |
|
316 |
+ get: function get() { |
|
317 |
+ return proto; |
|
318 |
+ }, |
|
319 |
+ set: function set(value) { |
|
320 |
+ proto.__proto__ = value; |
|
321 |
+ } |
|
322 |
+ }); |
|
323 |
+} |
|
324 |
+ |
|
325 |
+var Dom7 = /*#__PURE__*/function (_Array) { |
|
326 |
+ _inheritsLoose(Dom7, _Array); |
|
327 |
+ |
|
328 |
+ function Dom7(items) { |
|
329 |
+ var _this; |
|
330 |
+ |
|
331 |
+ _this = _Array.call.apply(_Array, [this].concat(items)) || this; |
|
332 |
+ makeReactive(_assertThisInitialized(_this)); |
|
333 |
+ return _this; |
|
334 |
+ } |
|
335 |
+ |
|
336 |
+ return Dom7; |
|
337 |
+}( /*#__PURE__*/_wrapNativeSuper(Array)); |
|
338 |
+ |
|
339 |
+function arrayFlat(arr) { |
|
340 |
+ if (arr === void 0) { |
|
341 |
+ arr = []; |
|
342 |
+ } |
|
343 |
+ |
|
344 |
+ var res = []; |
|
345 |
+ arr.forEach(function (el) { |
|
346 |
+ if (Array.isArray(el)) { |
|
347 |
+ res.push.apply(res, arrayFlat(el)); |
|
348 |
+ } else { |
|
349 |
+ res.push(el); |
|
350 |
+ } |
|
351 |
+ }); |
|
352 |
+ return res; |
|
353 |
+} |
|
354 |
+ |
|
355 |
+function arrayFilter(arr, callback) { |
|
356 |
+ return Array.prototype.filter.call(arr, callback); |
|
357 |
+} |
|
358 |
+ |
|
359 |
+function arrayUnique(arr) { |
|
360 |
+ var uniqueArray = []; |
|
361 |
+ |
|
362 |
+ for (var i = 0; i < arr.length; i += 1) { |
|
363 |
+ if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]); |
|
364 |
+ } |
|
365 |
+ |
|
366 |
+ return uniqueArray; |
|
367 |
+} |
|
368 |
+ |
|
369 |
+function qsa(selector, context) { |
|
370 |
+ if (typeof selector !== 'string') { |
|
371 |
+ return [selector]; |
|
372 |
+ } |
|
373 |
+ |
|
374 |
+ var a = []; |
|
375 |
+ var res = context.querySelectorAll(selector); |
|
376 |
+ |
|
377 |
+ for (var i = 0; i < res.length; i += 1) { |
|
378 |
+ a.push(res[i]); |
|
379 |
+ } |
|
380 |
+ |
|
381 |
+ return a; |
|
382 |
+} |
|
383 |
+ |
|
384 |
+function $(selector, context) { |
|
385 |
+ var window = getWindow(); |
|
386 |
+ var document = getDocument(); |
|
387 |
+ var arr = []; |
|
388 |
+ |
|
389 |
+ if (!context && selector instanceof Dom7) { |
|
390 |
+ return selector; |
|
391 |
+ } |
|
392 |
+ |
|
393 |
+ if (!selector) { |
|
394 |
+ return new Dom7(arr); |
|
395 |
+ } |
|
396 |
+ |
|
397 |
+ if (typeof selector === 'string') { |
|
398 |
+ var html = selector.trim(); |
|
399 |
+ |
|
400 |
+ if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) { |
|
401 |
+ var toCreate = 'div'; |
|
402 |
+ if (html.indexOf('<li') === 0) toCreate = 'ul'; |
|
403 |
+ if (html.indexOf('<tr') === 0) toCreate = 'tbody'; |
|
404 |
+ if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr'; |
|
405 |
+ if (html.indexOf('<tbody') === 0) toCreate = 'table'; |
|
406 |
+ if (html.indexOf('<option') === 0) toCreate = 'select'; |
|
407 |
+ var tempParent = document.createElement(toCreate); |
|
408 |
+ tempParent.innerHTML = html; |
|
409 |
+ |
|
410 |
+ for (var i = 0; i < tempParent.childNodes.length; i += 1) { |
|
411 |
+ arr.push(tempParent.childNodes[i]); |
|
412 |
+ } |
|
413 |
+ } else { |
|
414 |
+ arr = qsa(selector.trim(), context || document); |
|
415 |
+ } // arr = qsa(selector, document); |
|
416 |
+ |
|
417 |
+ } else if (selector.nodeType || selector === window || selector === document) { |
|
418 |
+ arr.push(selector); |
|
419 |
+ } else if (Array.isArray(selector)) { |
|
420 |
+ if (selector instanceof Dom7) return selector; |
|
421 |
+ arr = selector; |
|
422 |
+ } |
|
423 |
+ |
|
424 |
+ return new Dom7(arrayUnique(arr)); |
|
425 |
+} |
|
426 |
+ |
|
427 |
+$.fn = Dom7.prototype; |
|
428 |
+ |
|
429 |
+function addClass() { |
|
430 |
+ for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) { |
|
431 |
+ classes[_key] = arguments[_key]; |
|
432 |
+ } |
|
433 |
+ |
|
434 |
+ var classNames = arrayFlat(classes.map(function (c) { |
|
435 |
+ return c.split(' '); |
|
436 |
+ })); |
|
437 |
+ this.forEach(function (el) { |
|
438 |
+ var _el$classList; |
|
439 |
+ |
|
440 |
+ (_el$classList = el.classList).add.apply(_el$classList, classNames); |
|
441 |
+ }); |
|
442 |
+ return this; |
|
443 |
+} |
|
444 |
+ |
|
445 |
+function removeClass() { |
|
446 |
+ for (var _len2 = arguments.length, classes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { |
|
447 |
+ classes[_key2] = arguments[_key2]; |
|
448 |
+ } |
|
449 |
+ |
|
450 |
+ var classNames = arrayFlat(classes.map(function (c) { |
|
451 |
+ return c.split(' '); |
|
452 |
+ })); |
|
453 |
+ this.forEach(function (el) { |
|
454 |
+ var _el$classList2; |
|
455 |
+ |
|
456 |
+ (_el$classList2 = el.classList).remove.apply(_el$classList2, classNames); |
|
457 |
+ }); |
|
458 |
+ return this; |
|
459 |
+} |
|
460 |
+ |
|
461 |
+function toggleClass() { |
|
462 |
+ for (var _len3 = arguments.length, classes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { |
|
463 |
+ classes[_key3] = arguments[_key3]; |
|
464 |
+ } |
|
465 |
+ |
|
466 |
+ var classNames = arrayFlat(classes.map(function (c) { |
|
467 |
+ return c.split(' '); |
|
468 |
+ })); |
|
469 |
+ this.forEach(function (el) { |
|
470 |
+ classNames.forEach(function (className) { |
|
471 |
+ el.classList.toggle(className); |
|
472 |
+ }); |
|
473 |
+ }); |
|
474 |
+} |
|
475 |
+ |
|
476 |
+function hasClass() { |
|
477 |
+ for (var _len4 = arguments.length, classes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { |
|
478 |
+ classes[_key4] = arguments[_key4]; |
|
479 |
+ } |
|
480 |
+ |
|
481 |
+ var classNames = arrayFlat(classes.map(function (c) { |
|
482 |
+ return c.split(' '); |
|
483 |
+ })); |
|
484 |
+ return arrayFilter(this, function (el) { |
|
485 |
+ return classNames.filter(function (className) { |
|
486 |
+ return el.classList.contains(className); |
|
487 |
+ }).length > 0; |
|
488 |
+ }).length > 0; |
|
489 |
+} |
|
490 |
+ |
|
491 |
+function attr(attrs, value) { |
|
492 |
+ if (arguments.length === 1 && typeof attrs === 'string') { |
|
493 |
+ // Get attr |
|
494 |
+ if (this[0]) return this[0].getAttribute(attrs); |
|
495 |
+ return undefined; |
|
496 |
+ } // Set attrs |
|
497 |
+ |
|
498 |
+ |
|
499 |
+ for (var i = 0; i < this.length; i += 1) { |
|
500 |
+ if (arguments.length === 2) { |
|
501 |
+ // String |
|
502 |
+ this[i].setAttribute(attrs, value); |
|
503 |
+ } else { |
|
504 |
+ // Object |
|
505 |
+ for (var attrName in attrs) { |
|
506 |
+ this[i][attrName] = attrs[attrName]; |
|
507 |
+ this[i].setAttribute(attrName, attrs[attrName]); |
|
508 |
+ } |
|
509 |
+ } |
|
510 |
+ } |
|
511 |
+ |
|
512 |
+ return this; |
|
513 |
+} |
|
514 |
+ |
|
515 |
+function removeAttr(attr) { |
|
516 |
+ for (var i = 0; i < this.length; i += 1) { |
|
517 |
+ this[i].removeAttribute(attr); |
|
518 |
+ } |
|
519 |
+ |
|
520 |
+ return this; |
|
521 |
+} |
|
522 |
+ |
|
523 |
+function transform(transform) { |
|
524 |
+ for (var i = 0; i < this.length; i += 1) { |
|
525 |
+ this[i].style.transform = transform; |
|
526 |
+ } |
|
527 |
+ |
|
528 |
+ return this; |
|
529 |
+} |
|
530 |
+ |
|
531 |
+function transition(duration) { |
|
532 |
+ for (var i = 0; i < this.length; i += 1) { |
|
533 |
+ this[i].style.transition = typeof duration !== 'string' ? duration + "ms" : duration; |
|
534 |
+ } |
|
535 |
+ |
|
536 |
+ return this; |
|
537 |
+} |
|
538 |
+ |
|
539 |
+function on() { |
|
540 |
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { |
|
541 |
+ args[_key5] = arguments[_key5]; |
|
542 |
+ } |
|
543 |
+ |
|
544 |
+ var eventType = args[0], |
|
545 |
+ targetSelector = args[1], |
|
546 |
+ listener = args[2], |
|
547 |
+ capture = args[3]; |
|
548 |
+ |
|
549 |
+ if (typeof args[1] === 'function') { |
|
550 |
+ eventType = args[0]; |
|
551 |
+ listener = args[1]; |
|
552 |
+ capture = args[2]; |
|
553 |
+ targetSelector = undefined; |
|
554 |
+ } |
|
555 |
+ |
|
556 |
+ if (!capture) capture = false; |
|
557 |
+ |
|
558 |
+ function handleLiveEvent(e) { |
|
559 |
+ var target = e.target; |
|
560 |
+ if (!target) return; |
|
561 |
+ var eventData = e.target.dom7EventData || []; |
|
562 |
+ |
|
563 |
+ if (eventData.indexOf(e) < 0) { |
|
564 |
+ eventData.unshift(e); |
|
565 |
+ } |
|
566 |
+ |
|
567 |
+ if ($(target).is(targetSelector)) listener.apply(target, eventData);else { |
|
568 |
+ var _parents = $(target).parents(); // eslint-disable-line |
|
569 |
+ |
|
570 |
+ |
|
571 |
+ for (var k = 0; k < _parents.length; k += 1) { |
|
572 |
+ if ($(_parents[k]).is(targetSelector)) listener.apply(_parents[k], eventData); |
|
573 |
+ } |
|
574 |
+ } |
|
575 |
+ } |
|
576 |
+ |
|
577 |
+ function handleEvent(e) { |
|
578 |
+ var eventData = e && e.target ? e.target.dom7EventData || [] : []; |
|
579 |
+ |
|
580 |
+ if (eventData.indexOf(e) < 0) { |
|
581 |
+ eventData.unshift(e); |
|
582 |
+ } |
|
583 |
+ |
|
584 |
+ listener.apply(this, eventData); |
|
585 |
+ } |
|
586 |
+ |
|
587 |
+ var events = eventType.split(' '); |
|
588 |
+ var j; |
|
589 |
+ |
|
590 |
+ for (var i = 0; i < this.length; i += 1) { |
|
591 |
+ var el = this[i]; |
|
592 |
+ |
|
593 |
+ if (!targetSelector) { |
|
594 |
+ for (j = 0; j < events.length; j += 1) { |
|
595 |
+ var event = events[j]; |
|
596 |
+ if (!el.dom7Listeners) el.dom7Listeners = {}; |
|
597 |
+ if (!el.dom7Listeners[event]) el.dom7Listeners[event] = []; |
|
598 |
+ el.dom7Listeners[event].push({ |
|
599 |
+ listener: listener, |
|
600 |
+ proxyListener: handleEvent |
|
601 |
+ }); |
|
602 |
+ el.addEventListener(event, handleEvent, capture); |
|
603 |
+ } |
|
604 |
+ } else { |
|
605 |
+ // Live events |
|
606 |
+ for (j = 0; j < events.length; j += 1) { |
|
607 |
+ var _event = events[j]; |
|
608 |
+ if (!el.dom7LiveListeners) el.dom7LiveListeners = {}; |
|
609 |
+ if (!el.dom7LiveListeners[_event]) el.dom7LiveListeners[_event] = []; |
|
610 |
+ |
|
611 |
+ el.dom7LiveListeners[_event].push({ |
|
612 |
+ listener: listener, |
|
613 |
+ proxyListener: handleLiveEvent |
|
614 |
+ }); |
|
615 |
+ |
|
616 |
+ el.addEventListener(_event, handleLiveEvent, capture); |
|
617 |
+ } |
|
618 |
+ } |
|
619 |
+ } |
|
620 |
+ |
|
621 |
+ return this; |
|
622 |
+} |
|
623 |
+ |
|
624 |
+function off() { |
|
625 |
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { |
|
626 |
+ args[_key6] = arguments[_key6]; |
|
627 |
+ } |
|
628 |
+ |
|
629 |
+ var eventType = args[0], |
|
630 |
+ targetSelector = args[1], |
|
631 |
+ listener = args[2], |
|
632 |
+ capture = args[3]; |
|
633 |
+ |
|
634 |
+ if (typeof args[1] === 'function') { |
|
635 |
+ eventType = args[0]; |
|
636 |
+ listener = args[1]; |
|
637 |
+ capture = args[2]; |
|
638 |
+ targetSelector = undefined; |
|
639 |
+ } |
|
640 |
+ |
|
641 |
+ if (!capture) capture = false; |
|
642 |
+ var events = eventType.split(' '); |
|
643 |
+ |
|
644 |
+ for (var i = 0; i < events.length; i += 1) { |
|
645 |
+ var event = events[i]; |
|
646 |
+ |
|
647 |
+ for (var j = 0; j < this.length; j += 1) { |
|
648 |
+ var el = this[j]; |
|
649 |
+ var handlers = void 0; |
|
650 |
+ |
|
651 |
+ if (!targetSelector && el.dom7Listeners) { |
|
652 |
+ handlers = el.dom7Listeners[event]; |
|
653 |
+ } else if (targetSelector && el.dom7LiveListeners) { |
|
654 |
+ handlers = el.dom7LiveListeners[event]; |
|
655 |
+ } |
|
656 |
+ |
|
657 |
+ if (handlers && handlers.length) { |
|
658 |
+ for (var k = handlers.length - 1; k >= 0; k -= 1) { |
|
659 |
+ var handler = handlers[k]; |
|
660 |
+ |
|
661 |
+ if (listener && handler.listener === listener) { |
|
662 |
+ el.removeEventListener(event, handler.proxyListener, capture); |
|
663 |
+ handlers.splice(k, 1); |
|
664 |
+ } else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) { |
|
665 |
+ el.removeEventListener(event, handler.proxyListener, capture); |
|
666 |
+ handlers.splice(k, 1); |
|
667 |
+ } else if (!listener) { |
|
668 |
+ el.removeEventListener(event, handler.proxyListener, capture); |
|
669 |
+ handlers.splice(k, 1); |
|
670 |
+ } |
|
671 |
+ } |
|
672 |
+ } |
|
673 |
+ } |
|
674 |
+ } |
|
675 |
+ |
|
676 |
+ return this; |
|
677 |
+} |
|
678 |
+ |
|
679 |
+function trigger() { |
|
680 |
+ var window = getWindow(); |
|
681 |
+ |
|
682 |
+ for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { |
|
683 |
+ args[_key9] = arguments[_key9]; |
|
684 |
+ } |
|
685 |
+ |
|
686 |
+ var events = args[0].split(' '); |
|
687 |
+ var eventData = args[1]; |
|
688 |
+ |
|
689 |
+ for (var i = 0; i < events.length; i += 1) { |
|
690 |
+ var event = events[i]; |
|
691 |
+ |
|
692 |
+ for (var j = 0; j < this.length; j += 1) { |
|
693 |
+ var el = this[j]; |
|
694 |
+ |
|
695 |
+ if (window.CustomEvent) { |
|
696 |
+ var evt = new window.CustomEvent(event, { |
|
697 |
+ detail: eventData, |
|
698 |
+ bubbles: true, |
|
699 |
+ cancelable: true |
|
700 |
+ }); |
|
701 |
+ el.dom7EventData = args.filter(function (data, dataIndex) { |
|
702 |
+ return dataIndex > 0; |
|
703 |
+ }); |
|
704 |
+ el.dispatchEvent(evt); |
|
705 |
+ el.dom7EventData = []; |
|
706 |
+ delete el.dom7EventData; |
|
707 |
+ } |
|
708 |
+ } |
|
709 |
+ } |
|
710 |
+ |
|
711 |
+ return this; |
|
712 |
+} |
|
713 |
+ |
|
714 |
+function transitionEnd(callback) { |
|
715 |
+ var dom = this; |
|
716 |
+ |
|
717 |
+ function fireCallBack(e) { |
|
718 |
+ if (e.target !== this) return; |
|
719 |
+ callback.call(this, e); |
|
720 |
+ dom.off('transitionend', fireCallBack); |
|
721 |
+ } |
|
722 |
+ |
|
723 |
+ if (callback) { |
|
724 |
+ dom.on('transitionend', fireCallBack); |
|
725 |
+ } |
|
726 |
+ |
|
727 |
+ return this; |
|
728 |
+} |
|
729 |
+ |
|
730 |
+function outerWidth(includeMargins) { |
|
731 |
+ if (this.length > 0) { |
|
732 |
+ if (includeMargins) { |
|
733 |
+ var _styles = this.styles(); |
|
734 |
+ |
|
735 |
+ return this[0].offsetWidth + parseFloat(_styles.getPropertyValue('margin-right')) + parseFloat(_styles.getPropertyValue('margin-left')); |
|
736 |
+ } |
|
737 |
+ |
|
738 |
+ return this[0].offsetWidth; |
|
739 |
+ } |
|
740 |
+ |
|
741 |
+ return null; |
|
742 |
+} |
|
743 |
+ |
|
744 |
+function outerHeight(includeMargins) { |
|
745 |
+ if (this.length > 0) { |
|
746 |
+ if (includeMargins) { |
|
747 |
+ var _styles2 = this.styles(); |
|
748 |
+ |
|
749 |
+ return this[0].offsetHeight + parseFloat(_styles2.getPropertyValue('margin-top')) + parseFloat(_styles2.getPropertyValue('margin-bottom')); |
|
750 |
+ } |
|
751 |
+ |
|
752 |
+ return this[0].offsetHeight; |
|
753 |
+ } |
|
754 |
+ |
|
755 |
+ return null; |
|
756 |
+} |
|
757 |
+ |
|
758 |
+function offset() { |
|
759 |
+ if (this.length > 0) { |
|
760 |
+ var window = getWindow(); |
|
761 |
+ var document = getDocument(); |
|
762 |
+ var el = this[0]; |
|
763 |
+ var box = el.getBoundingClientRect(); |
|
764 |
+ var body = document.body; |
|
765 |
+ var clientTop = el.clientTop || body.clientTop || 0; |
|
766 |
+ var clientLeft = el.clientLeft || body.clientLeft || 0; |
|
767 |
+ var scrollTop = el === window ? window.scrollY : el.scrollTop; |
|
768 |
+ var scrollLeft = el === window ? window.scrollX : el.scrollLeft; |
|
769 |
+ return { |
|
770 |
+ top: box.top + scrollTop - clientTop, |
|
771 |
+ left: box.left + scrollLeft - clientLeft |
|
772 |
+ }; |
|
773 |
+ } |
|
774 |
+ |
|
775 |
+ return null; |
|
776 |
+} |
|
777 |
+ |
|
778 |
+function styles() { |
|
779 |
+ var window = getWindow(); |
|
780 |
+ if (this[0]) return window.getComputedStyle(this[0], null); |
|
781 |
+ return {}; |
|
782 |
+} |
|
783 |
+ |
|
784 |
+function css(props, value) { |
|
785 |
+ var window = getWindow(); |
|
786 |
+ var i; |
|
787 |
+ |
|
788 |
+ if (arguments.length === 1) { |
|
789 |
+ if (typeof props === 'string') { |
|
790 |
+ // .css('width') |
|
791 |
+ if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props); |
|
792 |
+ } else { |
|
793 |
+ // .css({ width: '100px' }) |
|
794 |
+ for (i = 0; i < this.length; i += 1) { |
|
795 |
+ for (var _prop in props) { |
|
796 |
+ this[i].style[_prop] = props[_prop]; |
|
797 |
+ } |
|
798 |
+ } |
|
799 |
+ |
|
800 |
+ return this; |
|
801 |
+ } |
|
802 |
+ } |
|
803 |
+ |
|
804 |
+ if (arguments.length === 2 && typeof props === 'string') { |
|
805 |
+ // .css('width', '100px') |
|
806 |
+ for (i = 0; i < this.length; i += 1) { |
|
807 |
+ this[i].style[props] = value; |
|
808 |
+ } |
|
809 |
+ |
|
810 |
+ return this; |
|
811 |
+ } |
|
812 |
+ |
|
813 |
+ return this; |
|
814 |
+} |
|
815 |
+ |
|
816 |
+function each(callback) { |
|
817 |
+ if (!callback) return this; |
|
818 |
+ this.forEach(function (el, index) { |
|
819 |
+ callback.apply(el, [el, index]); |
|
820 |
+ }); |
|
821 |
+ return this; |
|
822 |
+} |
|
823 |
+ |
|
824 |
+function filter(callback) { |
|
825 |
+ var result = arrayFilter(this, callback); |
|
826 |
+ return $(result); |
|
827 |
+} |
|
828 |
+ |
|
829 |
+function html(html) { |
|
830 |
+ if (typeof html === 'undefined') { |
|
831 |
+ return this[0] ? this[0].innerHTML : null; |
|
832 |
+ } |
|
833 |
+ |
|
834 |
+ for (var i = 0; i < this.length; i += 1) { |
|
835 |
+ this[i].innerHTML = html; |
|
836 |
+ } |
|
837 |
+ |
|
838 |
+ return this; |
|
839 |
+} |
|
840 |
+ |
|
841 |
+function text(text) { |
|
842 |
+ if (typeof text === 'undefined') { |
|
843 |
+ return this[0] ? this[0].textContent.trim() : null; |
|
844 |
+ } |
|
845 |
+ |
|
846 |
+ for (var i = 0; i < this.length; i += 1) { |
|
847 |
+ this[i].textContent = text; |
|
848 |
+ } |
|
849 |
+ |
|
850 |
+ return this; |
|
851 |
+} |
|
852 |
+ |
|
853 |
+function is(selector) { |
|
854 |
+ var window = getWindow(); |
|
855 |
+ var document = getDocument(); |
|
856 |
+ var el = this[0]; |
|
857 |
+ var compareWith; |
|
858 |
+ var i; |
|
859 |
+ if (!el || typeof selector === 'undefined') return false; |
|
860 |
+ |
|
861 |
+ if (typeof selector === 'string') { |
|
862 |
+ if (el.matches) return el.matches(selector); |
|
863 |
+ if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector); |
|
864 |
+ if (el.msMatchesSelector) return el.msMatchesSelector(selector); |
|
865 |
+ compareWith = $(selector); |
|
866 |
+ |
|
867 |
+ for (i = 0; i < compareWith.length; i += 1) { |
|
868 |
+ if (compareWith[i] === el) return true; |
|
869 |
+ } |
|
870 |
+ |
|
871 |
+ return false; |
|
872 |
+ } |
|
873 |
+ |
|
874 |
+ if (selector === document) { |
|
875 |
+ return el === document; |
|
876 |
+ } |
|
877 |
+ |
|
878 |
+ if (selector === window) { |
|
879 |
+ return el === window; |
|
880 |
+ } |
|
881 |
+ |
|
882 |
+ if (selector.nodeType || selector instanceof Dom7) { |
|
883 |
+ compareWith = selector.nodeType ? [selector] : selector; |
|
884 |
+ |
|
885 |
+ for (i = 0; i < compareWith.length; i += 1) { |
|
886 |
+ if (compareWith[i] === el) return true; |
|
887 |
+ } |
|
888 |
+ |
|
889 |
+ return false; |
|
890 |
+ } |
|
891 |
+ |
|
892 |
+ return false; |
|
893 |
+} |
|
894 |
+ |
|
895 |
+function index() { |
|
896 |
+ var child = this[0]; |
|
897 |
+ var i; |
|
898 |
+ |
|
899 |
+ if (child) { |
|
900 |
+ i = 0; // eslint-disable-next-line |
|
901 |
+ |
|
902 |
+ while ((child = child.previousSibling) !== null) { |
|
903 |
+ if (child.nodeType === 1) i += 1; |
|
904 |
+ } |
|
905 |
+ |
|
906 |
+ return i; |
|
907 |
+ } |
|
908 |
+ |
|
909 |
+ return undefined; |
|
910 |
+} |
|
911 |
+ |
|
912 |
+function eq(index) { |
|
913 |
+ if (typeof index === 'undefined') return this; |
|
914 |
+ var length = this.length; |
|
915 |
+ |
|
916 |
+ if (index > length - 1) { |
|
917 |
+ return $([]); |
|
918 |
+ } |
|
919 |
+ |
|
920 |
+ if (index < 0) { |
|
921 |
+ var returnIndex = length + index; |
|
922 |
+ if (returnIndex < 0) return $([]); |
|
923 |
+ return $([this[returnIndex]]); |
|
924 |
+ } |
|
925 |
+ |
|
926 |
+ return $([this[index]]); |
|
927 |
+} |
|
928 |
+ |
|
929 |
+function append() { |
|
930 |
+ var newChild; |
|
931 |
+ var document = getDocument(); |
|
932 |
+ |
|
933 |
+ for (var k = 0; k < arguments.length; k += 1) { |
|
934 |
+ newChild = k < 0 || arguments.length <= k ? undefined : arguments[k]; |
|
935 |
+ |
|
936 |
+ for (var i = 0; i < this.length; i += 1) { |
|
937 |
+ if (typeof newChild === 'string') { |
|
938 |
+ var tempDiv = document.createElement('div'); |
|
939 |
+ tempDiv.innerHTML = newChild; |
|
940 |
+ |
|
941 |
+ while (tempDiv.firstChild) { |
|
942 |
+ this[i].appendChild(tempDiv.firstChild); |
|
943 |
+ } |
|
944 |
+ } else if (newChild instanceof Dom7) { |
|
945 |
+ for (var j = 0; j < newChild.length; j += 1) { |
|
946 |
+ this[i].appendChild(newChild[j]); |
|
947 |
+ } |
|
948 |
+ } else { |
|
949 |
+ this[i].appendChild(newChild); |
|
950 |
+ } |
|
951 |
+ } |
|
952 |
+ } |
|
953 |
+ |
|
954 |
+ return this; |
|
955 |
+} |
|
956 |
+ |
|
957 |
+function prepend(newChild) { |
|
958 |
+ var document = getDocument(); |
|
959 |
+ var i; |
|
960 |
+ var j; |
|
961 |
+ |
|
962 |
+ for (i = 0; i < this.length; i += 1) { |
|
963 |
+ if (typeof newChild === 'string') { |
|
964 |
+ var tempDiv = document.createElement('div'); |
|
965 |
+ tempDiv.innerHTML = newChild; |
|
966 |
+ |
|
967 |
+ for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) { |
|
968 |
+ this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]); |
|
969 |
+ } |
|
970 |
+ } else if (newChild instanceof Dom7) { |
|
971 |
+ for (j = 0; j < newChild.length; j += 1) { |
|
972 |
+ this[i].insertBefore(newChild[j], this[i].childNodes[0]); |
|
973 |
+ } |
|
974 |
+ } else { |
|
975 |
+ this[i].insertBefore(newChild, this[i].childNodes[0]); |
|
976 |
+ } |
|
977 |
+ } |
|
978 |
+ |
|
979 |
+ return this; |
|
980 |
+} |
|
981 |
+ |
|
982 |
+function next(selector) { |
|
983 |
+ if (this.length > 0) { |
|
984 |
+ if (selector) { |
|
985 |
+ if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) { |
|
986 |
+ return $([this[0].nextElementSibling]); |
|
987 |
+ } |
|
988 |
+ |
|
989 |
+ return $([]); |
|
990 |
+ } |
|
991 |
+ |
|
992 |
+ if (this[0].nextElementSibling) return $([this[0].nextElementSibling]); |
|
993 |
+ return $([]); |
|
994 |
+ } |
|
995 |
+ |
|
996 |
+ return $([]); |
|
997 |
+} |
|
998 |
+ |
|
999 |
+function nextAll(selector) { |
|
1000 |
+ var nextEls = []; |
|
1001 |
+ var el = this[0]; |
|
1002 |
+ if (!el) return $([]); |
|
1003 |
+ |
|
1004 |
+ while (el.nextElementSibling) { |
|
1005 |
+ var _next = el.nextElementSibling; // eslint-disable-line |
|
1006 |
+ |
|
1007 |
+ if (selector) { |
|
1008 |
+ if ($(_next).is(selector)) nextEls.push(_next); |
|
1009 |
+ } else nextEls.push(_next); |
|
1010 |
+ |
|
1011 |
+ el = _next; |
|
1012 |
+ } |
|
1013 |
+ |
|
1014 |
+ return $(nextEls); |
|
1015 |
+} |
|
1016 |
+ |
|
1017 |
+function prev(selector) { |
|
1018 |
+ if (this.length > 0) { |
|
1019 |
+ var el = this[0]; |
|
1020 |
+ |
|
1021 |
+ if (selector) { |
|
1022 |
+ if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) { |
|
1023 |
+ return $([el.previousElementSibling]); |
|
1024 |
+ } |
|
1025 |
+ |
|
1026 |
+ return $([]); |
|
1027 |
+ } |
|
1028 |
+ |
|
1029 |
+ if (el.previousElementSibling) return $([el.previousElementSibling]); |
|
1030 |
+ return $([]); |
|
1031 |
+ } |
|
1032 |
+ |
|
1033 |
+ return $([]); |
|
1034 |
+} |
|
1035 |
+ |
|
1036 |
+function prevAll(selector) { |
|
1037 |
+ var prevEls = []; |
|
1038 |
+ var el = this[0]; |
|
1039 |
+ if (!el) return $([]); |
|
1040 |
+ |
|
1041 |
+ while (el.previousElementSibling) { |
|
1042 |
+ var _prev = el.previousElementSibling; // eslint-disable-line |
|
1043 |
+ |
|
1044 |
+ if (selector) { |
|
1045 |
+ if ($(_prev).is(selector)) prevEls.push(_prev); |
|
1046 |
+ } else prevEls.push(_prev); |
|
1047 |
+ |
|
1048 |
+ el = _prev; |
|
1049 |
+ } |
|
1050 |
+ |
|
1051 |
+ return $(prevEls); |
|
1052 |
+} |
|
1053 |
+ |
|
1054 |
+function parent(selector) { |
|
1055 |
+ var parents = []; // eslint-disable-line |
|
1056 |
+ |
|
1057 |
+ for (var i = 0; i < this.length; i += 1) { |
|
1058 |
+ if (this[i].parentNode !== null) { |
|
1059 |
+ if (selector) { |
|
1060 |
+ if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode); |
|
1061 |
+ } else { |
|
1062 |
+ parents.push(this[i].parentNode); |
|
1063 |
+ } |
|
1064 |
+ } |
|
1065 |
+ } |
|
1066 |
+ |
|
1067 |
+ return $(parents); |
|
1068 |
+} |
|
1069 |
+ |
|
1070 |
+function parents(selector) { |
|
1071 |
+ var parents = []; // eslint-disable-line |
|
1072 |
+ |
|
1073 |
+ for (var i = 0; i < this.length; i += 1) { |
|
1074 |
+ var _parent = this[i].parentNode; // eslint-disable-line |
|
1075 |
+ |
|
1076 |
+ while (_parent) { |
|
1077 |
+ if (selector) { |
|
1078 |
+ if ($(_parent).is(selector)) parents.push(_parent); |
|
1079 |
+ } else { |
|
1080 |
+ parents.push(_parent); |
|
1081 |
+ } |
|
1082 |
+ |
|
1083 |
+ _parent = _parent.parentNode; |
|
1084 |
+ } |
|
1085 |
+ } |
|
1086 |
+ |
|
1087 |
+ return $(parents); |
|
1088 |
+} |
|
1089 |
+ |
|
1090 |
+function closest(selector) { |
|
1091 |
+ var closest = this; // eslint-disable-line |
|
1092 |
+ |
|
1093 |
+ if (typeof selector === 'undefined') { |
|
1094 |
+ return $([]); |
|
1095 |
+ } |
|
1096 |
+ |
|
1097 |
+ if (!closest.is(selector)) { |
|
1098 |
+ closest = closest.parents(selector).eq(0); |
|
1099 |
+ } |
|
1100 |
+ |
|
1101 |
+ return closest; |
|
1102 |
+} |
|
1103 |
+ |
|
1104 |
+function find(selector) { |
|
1105 |
+ var foundElements = []; |
|
1106 |
+ |
|
1107 |
+ for (var i = 0; i < this.length; i += 1) { |
|
1108 |
+ var found = this[i].querySelectorAll(selector); |
|
1109 |
+ |
|
1110 |
+ for (var j = 0; j < found.length; j += 1) { |
|
1111 |
+ foundElements.push(found[j]); |
|
1112 |
+ } |
|
1113 |
+ } |
|
1114 |
+ |
|
1115 |
+ return $(foundElements); |
|
1116 |
+} |
|
1117 |
+ |
|
1118 |
+function children(selector) { |
|
1119 |
+ var children = []; // eslint-disable-line |
|
1120 |
+ |
|
1121 |
+ for (var i = 0; i < this.length; i += 1) { |
|
1122 |
+ var childNodes = this[i].children; |
|
1123 |
+ |
|
1124 |
+ for (var j = 0; j < childNodes.length; j += 1) { |
|
1125 |
+ if (!selector || $(childNodes[j]).is(selector)) { |
|
1126 |
+ children.push(childNodes[j]); |
|
1127 |
+ } |
|
1128 |
+ } |
|
1129 |
+ } |
|
1130 |
+ |
|
1131 |
+ return $(children); |
|
1132 |
+} |
|
1133 |
+ |
|
1134 |
+function remove() { |
|
1135 |
+ for (var i = 0; i < this.length; i += 1) { |
|
1136 |
+ if (this[i].parentNode) this[i].parentNode.removeChild(this[i]); |
|
1137 |
+ } |
|
1138 |
+ |
|
1139 |
+ return this; |
|
1140 |
+} |
|
1141 |
+ |
|
1142 |
+var Methods = { |
|
1143 |
+ addClass: addClass, |
|
1144 |
+ removeClass: removeClass, |
|
1145 |
+ hasClass: hasClass, |
|
1146 |
+ toggleClass: toggleClass, |
|
1147 |
+ attr: attr, |
|
1148 |
+ removeAttr: removeAttr, |
|
1149 |
+ transform: transform, |
|
1150 |
+ transition: transition, |
|
1151 |
+ on: on, |
|
1152 |
+ off: off, |
|
1153 |
+ trigger: trigger, |
|
1154 |
+ transitionEnd: transitionEnd, |
|
1155 |
+ outerWidth: outerWidth, |
|
1156 |
+ outerHeight: outerHeight, |
|
1157 |
+ styles: styles, |
|
1158 |
+ offset: offset, |
|
1159 |
+ css: css, |
|
1160 |
+ each: each, |
|
1161 |
+ html: html, |
|
1162 |
+ text: text, |
|
1163 |
+ is: is, |
|
1164 |
+ index: index, |
|
1165 |
+ eq: eq, |
|
1166 |
+ append: append, |
|
1167 |
+ prepend: prepend, |
|
1168 |
+ next: next, |
|
1169 |
+ nextAll: nextAll, |
|
1170 |
+ prev: prev, |
|
1171 |
+ prevAll: prevAll, |
|
1172 |
+ parent: parent, |
|
1173 |
+ parents: parents, |
|
1174 |
+ closest: closest, |
|
1175 |
+ find: find, |
|
1176 |
+ children: children, |
|
1177 |
+ filter: filter, |
|
1178 |
+ remove: remove |
|
1179 |
+}; |
|
1180 |
+Object.keys(Methods).forEach(function (methodName) { |
|
1181 |
+ $.fn[methodName] = Methods[methodName]; |
|
1182 |
+}); |
|
1183 |
+ |
|
1184 |
+function deleteProps(obj) { |
|
1185 |
+ var object = obj; |
|
1186 |
+ Object.keys(object).forEach(function (key) { |
|
1187 |
+ try { |
|
1188 |
+ object[key] = null; |
|
1189 |
+ } catch (e) {// no getter for object |
|
1190 |
+ } |
|
1191 |
+ |
|
1192 |
+ try { |
|
1193 |
+ delete object[key]; |
|
1194 |
+ } catch (e) {// something got wrong |
|
1195 |
+ } |
|
1196 |
+ }); |
|
1197 |
+} |
|
1198 |
+ |
|
1199 |
+function nextTick(callback, delay) { |
|
1200 |
+ if (delay === void 0) { |
|
1201 |
+ delay = 0; |
|
1202 |
+ } |
|
1203 |
+ |
|
1204 |
+ return setTimeout(callback, delay); |
|
1205 |
+} |
|
1206 |
+ |
|
1207 |
+function now() { |
|
1208 |
+ return Date.now(); |
|
1209 |
+} |
|
1210 |
+ |
|
1211 |
+function getTranslate(el, axis) { |
|
1212 |
+ if (axis === void 0) { |
|
1213 |
+ axis = 'x'; |
|
1214 |
+ } |
|
1215 |
+ |
|
1216 |
+ var window = getWindow(); |
|
1217 |
+ var matrix; |
|
1218 |
+ var curTransform; |
|
1219 |
+ var transformMatrix; |
|
1220 |
+ var curStyle = window.getComputedStyle(el, null); |
|
1221 |
+ |
|
1222 |
+ if (window.WebKitCSSMatrix) { |
|
1223 |
+ curTransform = curStyle.transform || curStyle.webkitTransform; |
|
1224 |
+ |
|
1225 |
+ if (curTransform.split(',').length > 6) { |
|
1226 |
+ curTransform = curTransform.split(', ').map(function (a) { |
|
1227 |
+ return a.replace(',', '.'); |
|
1228 |
+ }).join(', '); |
|
1229 |
+ } // Some old versions of Webkit choke when 'none' is passed; pass |
|
1230 |
+ // empty string instead in this case |
|
1231 |
+ |
|
1232 |
+ |
|
1233 |
+ transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform); |
|
1234 |
+ } else { |
|
1235 |
+ transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,'); |
|
1236 |
+ matrix = transformMatrix.toString().split(','); |
|
1237 |
+ } |
|
1238 |
+ |
|
1239 |
+ if (axis === 'x') { |
|
1240 |
+ // Latest Chrome and webkits Fix |
|
1241 |
+ if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41; // Crazy IE10 Matrix |
|
1242 |
+ else if (matrix.length === 16) curTransform = parseFloat(matrix[12]); // Normal Browsers |
|
1243 |
+ else curTransform = parseFloat(matrix[4]); |
|
1244 |
+ } |
|
1245 |
+ |
|
1246 |
+ if (axis === 'y') { |
|
1247 |
+ // Latest Chrome and webkits Fix |
|
1248 |
+ if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42; // Crazy IE10 Matrix |
|
1249 |
+ else if (matrix.length === 16) curTransform = parseFloat(matrix[13]); // Normal Browsers |
|
1250 |
+ else curTransform = parseFloat(matrix[5]); |
|
1251 |
+ } |
|
1252 |
+ |
|
1253 |
+ return curTransform || 0; |
|
1254 |
+} |
|
1255 |
+ |
|
1256 |
+function isObject$1(o) { |
|
1257 |
+ return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object; |
|
1258 |
+} |
|
1259 |
+ |
|
1260 |
+function extend$1() { |
|
1261 |
+ var to = Object(arguments.length <= 0 ? undefined : arguments[0]); |
|
1262 |
+ |
|
1263 |
+ for (var i = 1; i < arguments.length; i += 1) { |
|
1264 |
+ var nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i]; |
|
1265 |
+ |
|
1266 |
+ if (nextSource !== undefined && nextSource !== null) { |
|
1267 |
+ var keysArray = Object.keys(Object(nextSource)); |
|
1268 |
+ |
|
1269 |
+ for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) { |
|
1270 |
+ var nextKey = keysArray[nextIndex]; |
|
1271 |
+ var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); |
|
1272 |
+ |
|
1273 |
+ if (desc !== undefined && desc.enumerable) { |
|
1274 |
+ if (isObject$1(to[nextKey]) && isObject$1(nextSource[nextKey])) { |
|
1275 |
+ extend$1(to[nextKey], nextSource[nextKey]); |
|
1276 |
+ } else if (!isObject$1(to[nextKey]) && isObject$1(nextSource[nextKey])) { |
|
1277 |
+ to[nextKey] = {}; |
|
1278 |
+ extend$1(to[nextKey], nextSource[nextKey]); |
|
1279 |
+ } else { |
|
1280 |
+ to[nextKey] = nextSource[nextKey]; |
|
1281 |
+ } |
|
1282 |
+ } |
|
1283 |
+ } |
|
1284 |
+ } |
|
1285 |
+ } |
|
1286 |
+ |
|
1287 |
+ return to; |
|
1288 |
+} |
|
1289 |
+ |
|
1290 |
+function bindModuleMethods(instance, obj) { |
|
1291 |
+ Object.keys(obj).forEach(function (key) { |
|
1292 |
+ if (isObject$1(obj[key])) { |
|
1293 |
+ Object.keys(obj[key]).forEach(function (subKey) { |
|
1294 |
+ if (typeof obj[key][subKey] === 'function') { |
|
1295 |
+ obj[key][subKey] = obj[key][subKey].bind(instance); |
|
1296 |
+ } |
|
1297 |
+ }); |
|
1298 |
+ } |
|
1299 |
+ |
|
1300 |
+ instance[key] = obj[key]; |
|
1301 |
+ }); |
|
1302 |
+} |
|
1303 |
+ |
|
1304 |
+var support; |
|
1305 |
+ |
|
1306 |
+function calcSupport() { |
|
1307 |
+ var window = getWindow(); |
|
1308 |
+ var document = getDocument(); |
|
1309 |
+ return { |
|
1310 |
+ touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch), |
|
1311 |
+ pointerEvents: !!window.PointerEvent && 'maxTouchPoints' in window.navigator && window.navigator.maxTouchPoints >= 0, |
|
1312 |
+ observer: function checkObserver() { |
|
1313 |
+ return 'MutationObserver' in window || 'WebkitMutationObserver' in window; |
|
1314 |
+ }(), |
|
1315 |
+ passiveListener: function checkPassiveListener() { |
|
1316 |
+ var supportsPassive = false; |
|
1317 |
+ |
|
1318 |
+ try { |
|
1319 |
+ var opts = Object.defineProperty({}, 'passive', { |
|
1320 |
+ // eslint-disable-next-line |
|
1321 |
+ get: function get() { |
|
1322 |
+ supportsPassive = true; |
|
1323 |
+ } |
|
1324 |
+ }); |
|
1325 |
+ window.addEventListener('testPassiveListener', null, opts); |
|
1326 |
+ } catch (e) {// No support |
|
1327 |
+ } |
|
1328 |
+ |
|
1329 |
+ return supportsPassive; |
|
1330 |
+ }(), |
|
1331 |
+ gestures: function checkGestures() { |
|
1332 |
+ return 'ongesturestart' in window; |
|
1333 |
+ }() |
|
1334 |
+ }; |
|
1335 |
+} |
|
1336 |
+ |
|
1337 |
+function getSupport() { |
|
1338 |
+ if (!support) { |
|
1339 |
+ support = calcSupport(); |
|
1340 |
+ } |
|
1341 |
+ |
|
1342 |
+ return support; |
|
1343 |
+} |
|
1344 |
+ |
|
1345 |
+var device; |
|
1346 |
+ |
|
1347 |
+function calcDevice(_temp) { |
|
1348 |
+ var _ref = _temp === void 0 ? {} : _temp, |
|
1349 |
+ userAgent = _ref.userAgent; |
|
1350 |
+ |
|
1351 |
+ var support = getSupport(); |
|
1352 |
+ var window = getWindow(); |
|
1353 |
+ var platform = window.navigator.platform; |
|
1354 |
+ var ua = userAgent || window.navigator.userAgent; |
|
1355 |
+ var device = { |
|
1356 |
+ ios: false, |
|
1357 |
+ android: false |
|
1358 |
+ }; |
|
1359 |
+ var screenWidth = window.screen.width; |
|
1360 |
+ var screenHeight = window.screen.height; |
|
1361 |
+ var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line |
|
1362 |
+ |
|
1363 |
+ var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); |
|
1364 |
+ var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); |
|
1365 |
+ var iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/); |
|
1366 |
+ var windows = platform === 'Win32'; |
|
1367 |
+ var macos = platform === 'MacIntel'; // iPadOs 13 fix |
|
1368 |
+ |
|
1369 |
+ var iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810']; |
|
1370 |
+ |
|
1371 |
+ if (!ipad && macos && support.touch && iPadScreens.indexOf(screenWidth + "x" + screenHeight) >= 0) { |
|
1372 |
+ ipad = ua.match(/(Version)\/([\d.]+)/); |
|
1373 |
+ if (!ipad) ipad = [0, 1, '13_0_0']; |
|
1374 |
+ macos = false; |
|
1375 |
+ } // Android |
|
1376 |
+ |
|
1377 |
+ |
|
1378 |
+ if (android && !windows) { |
|
1379 |
+ device.os = 'android'; |
|
1380 |
+ device.android = true; |
|
1381 |
+ } |
|
1382 |
+ |
|
1383 |
+ if (ipad || iphone || ipod) { |
|
1384 |
+ device.os = 'ios'; |
|
1385 |
+ device.ios = true; |
|
1386 |
+ } // Export object |
|
1387 |
+ |
|
1388 |
+ |
|
1389 |
+ return device; |
|
1390 |
+} |
|
1391 |
+ |
|
1392 |
+function getDevice(overrides) { |
|
1393 |
+ if (overrides === void 0) { |
|
1394 |
+ overrides = {}; |
|
1395 |
+ } |
|
1396 |
+ |
|
1397 |
+ if (!device) { |
|
1398 |
+ device = calcDevice(overrides); |
|
1399 |
+ } |
|
1400 |
+ |
|
1401 |
+ return device; |
|
1402 |
+} |
|
1403 |
+ |
|
1404 |
+var browser; |
|
1405 |
+ |
|
1406 |
+function calcBrowser() { |
|
1407 |
+ var window = getWindow(); |
|
1408 |
+ |
|
1409 |
+ function isSafari() { |
|
1410 |
+ var ua = window.navigator.userAgent.toLowerCase(); |
|
1411 |
+ return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0; |
|
1412 |
+ } |
|
1413 |
+ |
|
1414 |
+ return { |
|
1415 |
+ isEdge: !!window.navigator.userAgent.match(/Edge/g), |
|
1416 |
+ isSafari: isSafari(), |
|
1417 |
+ isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent) |
|
1418 |
+ }; |
|
1419 |
+} |
|
1420 |
+ |
|
1421 |
+function getBrowser() { |
|
1422 |
+ if (!browser) { |
|
1423 |
+ browser = calcBrowser(); |
|
1424 |
+ } |
|
1425 |
+ |
|
1426 |
+ return browser; |
|
1427 |
+} |
|
1428 |
+ |
|
1429 |
+var Resize = { |
|
1430 |
+ name: 'resize', |
|
1431 |
+ create: function create() { |
|
1432 |
+ var swiper = this; |
|
1433 |
+ extend$1(swiper, { |
|
1434 |
+ resize: { |
|
1435 |
+ resizeHandler: function resizeHandler() { |
|
1436 |
+ if (!swiper || swiper.destroyed || !swiper.initialized) return; |
|
1437 |
+ swiper.emit('beforeResize'); |
|
1438 |
+ swiper.emit('resize'); |
|
1439 |
+ }, |
|
1440 |
+ orientationChangeHandler: function orientationChangeHandler() { |
|
1441 |
+ if (!swiper || swiper.destroyed || !swiper.initialized) return; |
|
1442 |
+ swiper.emit('orientationchange'); |
|
1443 |
+ } |
|
1444 |
+ } |
|
1445 |
+ }); |
|
1446 |
+ }, |
|
1447 |
+ on: { |
|
1448 |
+ init: function init(swiper) { |
|
1449 |
+ var window = getWindow(); // Emit resize |
|
1450 |
+ |
|
1451 |
+ window.addEventListener('resize', swiper.resize.resizeHandler); // Emit orientationchange |
|
1452 |
+ |
|
1453 |
+ window.addEventListener('orientationchange', swiper.resize.orientationChangeHandler); |
|
1454 |
+ }, |
|
1455 |
+ destroy: function destroy(swiper) { |
|
1456 |
+ var window = getWindow(); |
|
1457 |
+ window.removeEventListener('resize', swiper.resize.resizeHandler); |
|
1458 |
+ window.removeEventListener('orientationchange', swiper.resize.orientationChangeHandler); |
|
1459 |
+ } |
|
1460 |
+ } |
|
1461 |
+}; |
|
1462 |
+ |
|
1463 |
+var Observer = { |
|
1464 |
+ attach: function attach(target, options) { |
|
1465 |
+ if (options === void 0) { |
|
1466 |
+ options = {}; |
|
1467 |
+ } |
|
1468 |
+ |
|
1469 |
+ var window = getWindow(); |
|
1470 |
+ var swiper = this; |
|
1471 |
+ var ObserverFunc = window.MutationObserver || window.WebkitMutationObserver; |
|
1472 |
+ var observer = new ObserverFunc(function (mutations) { |
|
1473 |
+ // The observerUpdate event should only be triggered |
|
1474 |
+ // once despite the number of mutations. Additional |
|
1475 |
+ // triggers are redundant and are very costly |
|
1476 |
+ if (mutations.length === 1) { |
|
1477 |
+ swiper.emit('observerUpdate', mutations[0]); |
|
1478 |
+ return; |
|
1479 |
+ } |
|
1480 |
+ |
|
1481 |
+ var observerUpdate = function observerUpdate() { |
|
1482 |
+ swiper.emit('observerUpdate', mutations[0]); |
|
1483 |
+ }; |
|
1484 |
+ |
|
1485 |
+ if (window.requestAnimationFrame) { |
|
1486 |
+ window.requestAnimationFrame(observerUpdate); |
|
1487 |
+ } else { |
|
1488 |
+ window.setTimeout(observerUpdate, 0); |
|
1489 |
+ } |
|
1490 |
+ }); |
|
1491 |
+ observer.observe(target, { |
|
1492 |
+ attributes: typeof options.attributes === 'undefined' ? true : options.attributes, |
|
1493 |
+ childList: typeof options.childList === 'undefined' ? true : options.childList, |
|
1494 |
+ characterData: typeof options.characterData === 'undefined' ? true : options.characterData |
|
1495 |
+ }); |
|
1496 |
+ swiper.observer.observers.push(observer); |
|
1497 |
+ }, |
|
1498 |
+ init: function init() { |
|
1499 |
+ var swiper = this; |
|
1500 |
+ if (!swiper.support.observer || !swiper.params.observer) return; |
|
1501 |
+ |
|
1502 |
+ if (swiper.params.observeParents) { |
|
1503 |
+ var containerParents = swiper.$el.parents(); |
|
1504 |
+ |
|
1505 |
+ for (var i = 0; i < containerParents.length; i += 1) { |
|
1506 |
+ swiper.observer.attach(containerParents[i]); |
|
1507 |
+ } |
|
1508 |
+ } // Observe container |
|
1509 |
+ |
|
1510 |
+ |
|
1511 |
+ swiper.observer.attach(swiper.$el[0], { |
|
1512 |
+ childList: swiper.params.observeSlideChildren |
|
1513 |
+ }); // Observe wrapper |
|
1514 |
+ |
|
1515 |
+ swiper.observer.attach(swiper.$wrapperEl[0], { |
|
1516 |
+ attributes: false |
|
1517 |
+ }); |
|
1518 |
+ }, |
|
1519 |
+ destroy: function destroy() { |
|
1520 |
+ var swiper = this; |
|
1521 |
+ swiper.observer.observers.forEach(function (observer) { |
|
1522 |
+ observer.disconnect(); |
|
1523 |
+ }); |
|
1524 |
+ swiper.observer.observers = []; |
|
1525 |
+ } |
|
1526 |
+}; |
|
1527 |
+var Observer$1 = { |
|
1528 |
+ name: 'observer', |
|
1529 |
+ params: { |
|
1530 |
+ observer: false, |
|
1531 |
+ observeParents: false, |
|
1532 |
+ observeSlideChildren: false |
|
1533 |
+ }, |
|
1534 |
+ create: function create() { |
|
1535 |
+ var swiper = this; |
|
1536 |
+ bindModuleMethods(swiper, { |
|
1537 |
+ observer: _extends(_extends({}, Observer), {}, { |
|
1538 |
+ observers: [] |
|
1539 |
+ }) |
|
1540 |
+ }); |
|
1541 |
+ }, |
|
1542 |
+ on: { |
|
1543 |
+ init: function init(swiper) { |
|
1544 |
+ swiper.observer.init(); |
|
1545 |
+ }, |
|
1546 |
+ destroy: function destroy(swiper) { |
|
1547 |
+ swiper.observer.destroy(); |
|
1548 |
+ } |
|
1549 |
+ } |
|
1550 |
+}; |
|
1551 |
+ |
|
1552 |
+var modular = { |
|
1553 |
+ useParams: function useParams(instanceParams) { |
|
1554 |
+ var instance = this; |
|
1555 |
+ if (!instance.modules) return; |
|
1556 |
+ Object.keys(instance.modules).forEach(function (moduleName) { |
|
1557 |
+ var module = instance.modules[moduleName]; // Extend params |
|
1558 |
+ |
|
1559 |
+ if (module.params) { |
|
1560 |
+ extend$1(instanceParams, module.params); |
|
1561 |
+ } |
|
1562 |
+ }); |
|
1563 |
+ }, |
|
1564 |
+ useModules: function useModules(modulesParams) { |
|
1565 |
+ if (modulesParams === void 0) { |
|
1566 |
+ modulesParams = {}; |
|
1567 |
+ } |
|
1568 |
+ |
|
1569 |
+ var instance = this; |
|
1570 |
+ if (!instance.modules) return; |
|
1571 |
+ Object.keys(instance.modules).forEach(function (moduleName) { |
|
1572 |
+ var module = instance.modules[moduleName]; |
|
1573 |
+ var moduleParams = modulesParams[moduleName] || {}; // Add event listeners |
|
1574 |
+ |
|
1575 |
+ if (module.on && instance.on) { |
|
1576 |
+ Object.keys(module.on).forEach(function (moduleEventName) { |
|
1577 |
+ instance.on(moduleEventName, module.on[moduleEventName]); |
|
1578 |
+ }); |
|
1579 |
+ } // Module create callback |
|
1580 |
+ |
|
1581 |
+ |
|
1582 |
+ if (module.create) { |
|
1583 |
+ module.create.bind(instance)(moduleParams); |
|
1584 |
+ } |
|
1585 |
+ }); |
|
1586 |
+ } |
|
1587 |
+}; |
|
1588 |
+ |
|
1589 |
+/* eslint-disable no-underscore-dangle */ |
|
1590 |
+var eventsEmitter = { |
|
1591 |
+ on: function on(events, handler, priority) { |
|
1592 |
+ var self = this; |
|
1593 |
+ if (typeof handler !== 'function') return self; |
|
1594 |
+ var method = priority ? 'unshift' : 'push'; |
|
1595 |
+ events.split(' ').forEach(function (event) { |
|
1596 |
+ if (!self.eventsListeners[event]) self.eventsListeners[event] = []; |
|
1597 |
+ self.eventsListeners[event][method](handler); |
|
1598 |
+ }); |
|
1599 |
+ return self; |
|
1600 |
+ }, |
|
1601 |
+ once: function once(events, handler, priority) { |
|
1602 |
+ var self = this; |
|
1603 |
+ if (typeof handler !== 'function') return self; |
|
1604 |
+ |
|
1605 |
+ function onceHandler() { |
|
1606 |
+ self.off(events, onceHandler); |
|
1607 |
+ |
|
1608 |
+ if (onceHandler.__emitterProxy) { |
|
1609 |
+ delete onceHandler.__emitterProxy; |
|
1610 |
+ } |
|
1611 |
+ |
|
1612 |
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
|
1613 |
+ args[_key] = arguments[_key]; |
|
1614 |
+ } |
|
1615 |
+ |
|
1616 |
+ handler.apply(self, args); |
|
1617 |
+ } |
|
1618 |
+ |
|
1619 |
+ onceHandler.__emitterProxy = handler; |
|
1620 |
+ return self.on(events, onceHandler, priority); |
|
1621 |
+ }, |
|
1622 |
+ onAny: function onAny(handler, priority) { |
|
1623 |
+ var self = this; |
|
1624 |
+ if (typeof handler !== 'function') return self; |
|
1625 |
+ var method = priority ? 'unshift' : 'push'; |
|
1626 |
+ |
|
1627 |
+ if (self.eventsAnyListeners.indexOf(handler) < 0) { |
|
1628 |
+ self.eventsAnyListeners[method](handler); |
|
1629 |
+ } |
|
1630 |
+ |
|
1631 |
+ return self; |
|
1632 |
+ }, |
|
1633 |
+ offAny: function offAny(handler) { |
|
1634 |
+ var self = this; |
|
1635 |
+ if (!self.eventsAnyListeners) return self; |
|
1636 |
+ var index = self.eventsAnyListeners.indexOf(handler); |
|
1637 |
+ |
|
1638 |
+ if (index >= 0) { |
|
1639 |
+ self.eventsAnyListeners.splice(index, 1); |
|
1640 |
+ } |
|
1641 |
+ |
|
1642 |
+ return self; |
|
1643 |
+ }, |
|
1644 |
+ off: function off(events, handler) { |
|
1645 |
+ var self = this; |
|
1646 |
+ if (!self.eventsListeners) return self; |
|
1647 |
+ events.split(' ').forEach(function (event) { |
|
1648 |
+ if (typeof handler === 'undefined') { |
|
1649 |
+ self.eventsListeners[event] = []; |
|
1650 |
+ } else if (self.eventsListeners[event]) { |
|
1651 |
+ self.eventsListeners[event].forEach(function (eventHandler, index) { |
|
1652 |
+ if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) { |
|
1653 |
+ self.eventsListeners[event].splice(index, 1); |
|
1654 |
+ } |
|
1655 |
+ }); |
|
1656 |
+ } |
|
1657 |
+ }); |
|
1658 |
+ return self; |
|
1659 |
+ }, |
|
1660 |
+ emit: function emit() { |
|
1661 |
+ var self = this; |
|
1662 |
+ if (!self.eventsListeners) return self; |
|
1663 |
+ var events; |
|
1664 |
+ var data; |
|
1665 |
+ var context; |
|
1666 |
+ |
|
1667 |
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { |
|
1668 |
+ args[_key2] = arguments[_key2]; |
|
1669 |
+ } |
|
1670 |
+ |
|
1671 |
+ if (typeof args[0] === 'string' || Array.isArray(args[0])) { |
|
1672 |
+ events = args[0]; |
|
1673 |
+ data = args.slice(1, args.length); |
|
1674 |
+ context = self; |
|
1675 |
+ } else { |
|
1676 |
+ events = args[0].events; |
|
1677 |
+ data = args[0].data; |
|
1678 |
+ context = args[0].context || self; |
|
1679 |
+ } |
|
1680 |
+ |
|
1681 |
+ data.unshift(context); |
|
1682 |
+ var eventsArray = Array.isArray(events) ? events : events.split(' '); |
|
1683 |
+ eventsArray.forEach(function (event) { |
|
1684 |
+ if (self.eventsAnyListeners && self.eventsAnyListeners.length) { |
|
1685 |
+ self.eventsAnyListeners.forEach(function (eventHandler) { |
|
1686 |
+ eventHandler.apply(context, [event].concat(data)); |
|
1687 |
+ }); |
|
1688 |
+ } |
|
1689 |
+ |
|
1690 |
+ if (self.eventsListeners && self.eventsListeners[event]) { |
|
1691 |
+ var handlers = []; |
|
1692 |
+ self.eventsListeners[event].forEach(function (eventHandler) { |
|
1693 |
+ handlers.push(eventHandler); |
|
1694 |
+ }); |
|
1695 |
+ handlers.forEach(function (eventHandler) { |
|
1696 |
+ eventHandler.apply(context, data); |
|
1697 |
+ }); |
|
1698 |
+ } |
|
1699 |
+ }); |
|
1700 |
+ return self; |
|
1701 |
+ } |
|
1702 |
+}; |
|
1703 |
+ |
|
1704 |
+function updateSize() { |
|
1705 |
+ var swiper = this; |
|
1706 |
+ var width; |
|
1707 |
+ var height; |
|
1708 |
+ var $el = swiper.$el; |
|
1709 |
+ |
|
1710 |
+ if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) { |
|
1711 |
+ width = swiper.params.width; |
|
1712 |
+ } else { |
|
1713 |
+ width = $el[0].clientWidth; |
|
1714 |
+ } |
|
1715 |
+ |
|
1716 |
+ if (typeof swiper.params.height !== 'undefined' && swiper.params.width !== null) { |
|
1717 |
+ height = swiper.params.height; |
|
1718 |
+ } else { |
|
1719 |
+ height = $el[0].clientHeight; |
|
1720 |
+ } |
|
1721 |
+ |
|
1722 |
+ if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) { |
|
1723 |
+ return; |
|
1724 |
+ } // Subtract paddings |
|
1725 |
+ |
|
1726 |
+ |
|
1727 |
+ width = width - parseInt($el.css('padding-left') || 0, 10) - parseInt($el.css('padding-right') || 0, 10); |
|
1728 |
+ height = height - parseInt($el.css('padding-top') || 0, 10) - parseInt($el.css('padding-bottom') || 0, 10); |
|
1729 |
+ if (Number.isNaN(width)) width = 0; |
|
1730 |
+ if (Number.isNaN(height)) height = 0; |
|
1731 |
+ extend$1(swiper, { |
|
1732 |
+ width: width, |
|
1733 |
+ height: height, |
|
1734 |
+ size: swiper.isHorizontal() ? width : height |
|
1735 |
+ }); |
|
1736 |
+} |
|
1737 |
+ |
|
1738 |
+function updateSlides() { |
|
1739 |
+ var swiper = this; |
|
1740 |
+ var window = getWindow(); |
|
1741 |
+ var params = swiper.params; |
|
1742 |
+ var $wrapperEl = swiper.$wrapperEl, |
|
1743 |
+ swiperSize = swiper.size, |
|
1744 |
+ rtl = swiper.rtlTranslate, |
|
1745 |
+ wrongRTL = swiper.wrongRTL; |
|
1746 |
+ var isVirtual = swiper.virtual && params.virtual.enabled; |
|
1747 |
+ var previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length; |
|
1748 |
+ var slides = $wrapperEl.children("." + swiper.params.slideClass); |
|
1749 |
+ var slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length; |
|
1750 |
+ var snapGrid = []; |
|
1751 |
+ var slidesGrid = []; |
|
1752 |
+ var slidesSizesGrid = []; |
|
1753 |
+ |
|
1754 |
+ function slidesForMargin(slideEl, slideIndex) { |
|
1755 |
+ if (!params.cssMode) return true; |
|
1756 |
+ |
|
1757 |
+ if (slideIndex === slides.length - 1) { |
|
1758 |
+ return false; |
|
1759 |
+ } |
|
1760 |
+ |
|
1761 |
+ return true; |
|
1762 |
+ } |
|
1763 |
+ |
|
1764 |
+ var offsetBefore = params.slidesOffsetBefore; |
|
1765 |
+ |
|
1766 |
+ if (typeof offsetBefore === 'function') { |
|
1767 |
+ offsetBefore = params.slidesOffsetBefore.call(swiper); |
|
1768 |
+ } |
|
1769 |
+ |
|
1770 |
+ var offsetAfter = params.slidesOffsetAfter; |
|
1771 |
+ |
|
1772 |
+ if (typeof offsetAfter === 'function') { |
|
1773 |
+ offsetAfter = params.slidesOffsetAfter.call(swiper); |
|
1774 |
+ } |
|
1775 |
+ |
|
1776 |
+ var previousSnapGridLength = swiper.snapGrid.length; |
|
1777 |
+ var previousSlidesGridLength = swiper.snapGrid.length; |
|
1778 |
+ var spaceBetween = params.spaceBetween; |
|
1779 |
+ var slidePosition = -offsetBefore; |
|
1780 |
+ var prevSlideSize = 0; |
|
1781 |
+ var index = 0; |
|
1782 |
+ |
|
1783 |
+ if (typeof swiperSize === 'undefined') { |
|
1784 |
+ return; |
|
1785 |
+ } |
|
1786 |
+ |
|
1787 |
+ if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) { |
|
1788 |
+ spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize; |
|
1789 |
+ } |
|
1790 |
+ |
|
1791 |
+ swiper.virtualSize = -spaceBetween; // reset margins |
|
1792 |
+ |
|
1793 |
+ if (rtl) slides.css({ |
|
1794 |
+ marginLeft: '', |
|
1795 |
+ marginTop: '' |
|
1796 |
+ });else slides.css({ |
|
1797 |
+ marginRight: '', |
|
1798 |
+ marginBottom: '' |
|
1799 |
+ }); |
|
1800 |
+ var slidesNumberEvenToRows; |
|
1801 |
+ |
|
1802 |
+ if (params.slidesPerColumn > 1) { |
|
1803 |
+ if (Math.floor(slidesLength / params.slidesPerColumn) === slidesLength / swiper.params.slidesPerColumn) { |
|
1804 |
+ slidesNumberEvenToRows = slidesLength; |
|
1805 |
+ } else { |
|
1806 |
+ slidesNumberEvenToRows = Math.ceil(slidesLength / params.slidesPerColumn) * params.slidesPerColumn; |
|
1807 |
+ } |
|
1808 |
+ |
|
1809 |
+ if (params.slidesPerView !== 'auto' && params.slidesPerColumnFill === 'row') { |
|
1810 |
+ slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, params.slidesPerView * params.slidesPerColumn); |
|
1811 |
+ } |
|
1812 |
+ } // Calc slides |
|
1813 |
+ |
|
1814 |
+ |
|
1815 |
+ var slideSize; |
|
1816 |
+ var slidesPerColumn = params.slidesPerColumn; |
|
1817 |
+ var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn; |
|
1818 |
+ var numFullColumns = Math.floor(slidesLength / params.slidesPerColumn); |
|
1819 |
+ |
|
1820 |
+ for (var i = 0; i < slidesLength; i += 1) { |
|
1821 |
+ slideSize = 0; |
|
1822 |
+ var slide = slides.eq(i); |
|
1823 |
+ |
|
1824 |
+ if (params.slidesPerColumn > 1) { |
|
1825 |
+ // Set slides order |
|
1826 |
+ var newSlideOrderIndex = void 0; |
|
1827 |
+ var column = void 0; |
|
1828 |
+ var row = void 0; |
|
1829 |
+ |
|
1830 |
+ if (params.slidesPerColumnFill === 'row' && params.slidesPerGroup > 1) { |
|
1831 |
+ var groupIndex = Math.floor(i / (params.slidesPerGroup * params.slidesPerColumn)); |
|
1832 |
+ var slideIndexInGroup = i - params.slidesPerColumn * params.slidesPerGroup * groupIndex; |
|
1833 |
+ var columnsInGroup = groupIndex === 0 ? params.slidesPerGroup : Math.min(Math.ceil((slidesLength - groupIndex * slidesPerColumn * params.slidesPerGroup) / slidesPerColumn), params.slidesPerGroup); |
|
1834 |
+ row = Math.floor(slideIndexInGroup / columnsInGroup); |
|
1835 |
+ column = slideIndexInGroup - row * columnsInGroup + groupIndex * params.slidesPerGroup; |
|
1836 |
+ newSlideOrderIndex = column + row * slidesNumberEvenToRows / slidesPerColumn; |
|
1837 |
+ slide.css({ |
|
1838 |
+ '-webkit-box-ordinal-group': newSlideOrderIndex, |
|
1839 |
+ '-moz-box-ordinal-group': newSlideOrderIndex, |
|
1840 |
+ '-ms-flex-order': newSlideOrderIndex, |
|
1841 |
+ '-webkit-order': newSlideOrderIndex, |
|
1842 |
+ order: newSlideOrderIndex |
|
1843 |
+ }); |
|
1844 |
+ } else if (params.slidesPerColumnFill === 'column') { |
|
1845 |
+ column = Math.floor(i / slidesPerColumn); |
|
1846 |
+ row = i - column * slidesPerColumn; |
|
1847 |
+ |
|
1848 |
+ if (column > numFullColumns || column === numFullColumns && row === slidesPerColumn - 1) { |
|
1849 |
+ row += 1; |
|
1850 |
+ |
|
1851 |
+ if (row >= slidesPerColumn) { |
|
1852 |
+ row = 0; |
|
1853 |
+ column += 1; |
|
1854 |
+ } |
|
1855 |
+ } |
|
1856 |
+ } else { |
|
1857 |
+ row = Math.floor(i / slidesPerRow); |
|
1858 |
+ column = i - row * slidesPerRow; |
|
1859 |
+ } |
|
1860 |
+ |
|
1861 |
+ slide.css("margin-" + (swiper.isHorizontal() ? 'top' : 'left'), row !== 0 && params.spaceBetween && params.spaceBetween + "px"); |
|
1862 |
+ } |
|
1863 |
+ |
|
1864 |
+ if (slide.css('display') === 'none') continue; // eslint-disable-line |
|
1865 |
+ |
|
1866 |
+ if (params.slidesPerView === 'auto') { |
|
1867 |
+ var slideStyles = window.getComputedStyle(slide[0], null); |
|
1868 |
+ var currentTransform = slide[0].style.transform; |
|
1869 |
+ var currentWebKitTransform = slide[0].style.webkitTransform; |
|
1870 |
+ |
|
1871 |
+ if (currentTransform) { |
|
1872 |
+ slide[0].style.transform = 'none'; |
|
1873 |
+ } |
|
1874 |
+ |
|
1875 |
+ if (currentWebKitTransform) { |
|
1876 |
+ slide[0].style.webkitTransform = 'none'; |
|
1877 |
+ } |
|
1878 |
+ |
|
1879 |
+ if (params.roundLengths) { |
|
1880 |
+ slideSize = swiper.isHorizontal() ? slide.outerWidth(true) : slide.outerHeight(true); |
|
1881 |
+ } else { |
|
1882 |
+ // eslint-disable-next-line |
|
1883 |
+ if (swiper.isHorizontal()) { |
|
1884 |
+ var width = parseFloat(slideStyles.getPropertyValue('width') || 0); |
|
1885 |
+ var paddingLeft = parseFloat(slideStyles.getPropertyValue('padding-left') || 0); |
|
1886 |
+ var paddingRight = parseFloat(slideStyles.getPropertyValue('padding-right') || 0); |
|
1887 |
+ var marginLeft = parseFloat(slideStyles.getPropertyValue('margin-left') || 0); |
|
1888 |
+ var marginRight = parseFloat(slideStyles.getPropertyValue('margin-right') || 0); |
|
1889 |
+ var boxSizing = slideStyles.getPropertyValue('box-sizing'); |
|
1890 |
+ |
|
1891 |
+ if (boxSizing && boxSizing === 'border-box') { |
|
1892 |
+ slideSize = width + marginLeft + marginRight; |
|
1893 |
+ } else { |
|
1894 |
+ var _slide$ = slide[0], |
|
1895 |
+ clientWidth = _slide$.clientWidth, |
|
1896 |
+ offsetWidth = _slide$.offsetWidth; |
|
1897 |
+ slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth); |
|
1898 |
+ } |
|
1899 |
+ } else { |
|
1900 |
+ var height = parseFloat(slideStyles.getPropertyValue('height') || 0); |
|
1901 |
+ var paddingTop = parseFloat(slideStyles.getPropertyValue('padding-top') || 0); |
|
1902 |
+ var paddingBottom = parseFloat(slideStyles.getPropertyValue('padding-bottom') || 0); |
|
1903 |
+ var marginTop = parseFloat(slideStyles.getPropertyValue('margin-top') || 0); |
|
1904 |
+ var marginBottom = parseFloat(slideStyles.getPropertyValue('margin-bottom') || 0); |
|
1905 |
+ |
|
1906 |
+ var _boxSizing = slideStyles.getPropertyValue('box-sizing'); |
|
1907 |
+ |
|
1908 |
+ if (_boxSizing && _boxSizing === 'border-box') { |
|
1909 |
+ slideSize = height + marginTop + marginBottom; |
|
1910 |
+ } else { |
|
1911 |
+ var _slide$2 = slide[0], |
|
1912 |
+ clientHeight = _slide$2.clientHeight, |
|
1913 |
+ offsetHeight = _slide$2.offsetHeight; |
|
1914 |
+ slideSize = height + paddingTop + paddingBottom + marginTop + marginBottom + (offsetHeight - clientHeight); |
|
1915 |
+ } |
|
1916 |
+ } |
|
1917 |
+ } |
|
1918 |
+ |
|
1919 |
+ if (currentTransform) { |
|
1920 |
+ slide[0].style.transform = currentTransform; |
|
1921 |
+ } |
|
1922 |
+ |
|
1923 |
+ if (currentWebKitTransform) { |
|
1924 |
+ slide[0].style.webkitTransform = currentWebKitTransform; |
|
1925 |
+ } |
|
1926 |
+ |
|
1927 |
+ if (params.roundLengths) slideSize = Math.floor(slideSize); |
|
1928 |
+ } else { |
|
1929 |
+ slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView; |
|
1930 |
+ if (params.roundLengths) slideSize = Math.floor(slideSize); |
|
1931 |
+ |
|
1932 |
+ if (slides[i]) { |
|
1933 |
+ if (swiper.isHorizontal()) { |
|
1934 |
+ slides[i].style.width = slideSize + "px"; |
|
1935 |
+ } else { |
|
1936 |
+ slides[i].style.height = slideSize + "px"; |
|
1937 |
+ } |
|
1938 |
+ } |
|
1939 |
+ } |
|
1940 |
+ |
|
1941 |
+ if (slides[i]) { |
|
1942 |
+ slides[i].swiperSlideSize = slideSize; |
|
1943 |
+ } |
|
1944 |
+ |
|
1945 |
+ slidesSizesGrid.push(slideSize); |
|
1946 |
+ |
|
1947 |
+ if (params.centeredSlides) { |
|
1948 |
+ slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween; |
|
1949 |
+ if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween; |
|
1950 |
+ if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween; |
|
1951 |
+ if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0; |
|
1952 |
+ if (params.roundLengths) slidePosition = Math.floor(slidePosition); |
|
1953 |
+ if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition); |
|
1954 |
+ slidesGrid.push(slidePosition); |
|
1955 |
+ } else { |
|
1956 |
+ if (params.roundLengths) slidePosition = Math.floor(slidePosition); |
|
1957 |
+ if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition); |
|
1958 |
+ slidesGrid.push(slidePosition); |
|
1959 |
+ slidePosition = slidePosition + slideSize + spaceBetween; |
|
1960 |
+ } |
|
1961 |
+ |
|
1962 |
+ swiper.virtualSize += slideSize + spaceBetween; |
|
1963 |
+ prevSlideSize = slideSize; |
|
1964 |
+ index += 1; |
|
1965 |
+ } |
|
1966 |
+ |
|
1967 |
+ swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter; |
|
1968 |
+ var newSlidesGrid; |
|
1969 |
+ |
|
1970 |
+ if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) { |
|
1971 |
+ $wrapperEl.css({ |
|
1972 |
+ width: swiper.virtualSize + params.spaceBetween + "px" |
|
1973 |
+ }); |
|
1974 |
+ } |
|
1975 |
+ |
|
1976 |
+ if (params.setWrapperSize) { |
|
1977 |
+ if (swiper.isHorizontal()) $wrapperEl.css({ |
|
1978 |
+ width: swiper.virtualSize + params.spaceBetween + "px" |
|
1979 |
+ });else $wrapperEl.css({ |
|
1980 |
+ height: swiper.virtualSize + params.spaceBetween + "px" |
|
1981 |
+ }); |
|
1982 |
+ } |
|
1983 |
+ |
|
1984 |
+ if (params.slidesPerColumn > 1) { |
|
1985 |
+ swiper.virtualSize = (slideSize + params.spaceBetween) * slidesNumberEvenToRows; |
|
1986 |
+ swiper.virtualSize = Math.ceil(swiper.virtualSize / params.slidesPerColumn) - params.spaceBetween; |
|
1987 |
+ if (swiper.isHorizontal()) $wrapperEl.css({ |
|
1988 |
+ width: swiper.virtualSize + params.spaceBetween + "px" |
|
1989 |
+ });else $wrapperEl.css({ |
|
1990 |
+ height: swiper.virtualSize + params.spaceBetween + "px" |
|
1991 |
+ }); |
|
1992 |
+ |
|
1993 |
+ if (params.centeredSlides) { |
|
1994 |
+ newSlidesGrid = []; |
|
1995 |
+ |
|
1996 |
+ for (var _i = 0; _i < snapGrid.length; _i += 1) { |
|
1997 |
+ var slidesGridItem = snapGrid[_i]; |
|
1998 |
+ if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem); |
|
1999 |
+ if (snapGrid[_i] < swiper.virtualSize + snapGrid[0]) newSlidesGrid.push(slidesGridItem); |
|
2000 |
+ } |
|
2001 |
+ |
|
2002 |
+ snapGrid = newSlidesGrid; |
|
2003 |
+ } |
|
2004 |
+ } // Remove last grid elements depending on width |
|
2005 |
+ |
|
2006 |
+ |
|
2007 |
+ if (!params.centeredSlides) { |
|
2008 |
+ newSlidesGrid = []; |
|
2009 |
+ |
|
2010 |
+ for (var _i2 = 0; _i2 < snapGrid.length; _i2 += 1) { |
|
2011 |
+ var _slidesGridItem = snapGrid[_i2]; |
|
2012 |
+ if (params.roundLengths) _slidesGridItem = Math.floor(_slidesGridItem); |
|
2013 |
+ |
|
2014 |
+ if (snapGrid[_i2] <= swiper.virtualSize - swiperSize) { |
|
2015 |
+ newSlidesGrid.push(_slidesGridItem); |
|
2016 |
+ } |
|
2017 |
+ } |
|
2018 |
+ |
|
2019 |
+ snapGrid = newSlidesGrid; |
|
2020 |
+ |
|
2021 |
+ if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) { |
|
2022 |
+ snapGrid.push(swiper.virtualSize - swiperSize); |
|
2023 |
+ } |
|
2024 |
+ } |
|
2025 |
+ |
|
2026 |
+ if (snapGrid.length === 0) snapGrid = [0]; |
|
2027 |
+ |
|
2028 |
+ if (params.spaceBetween !== 0) { |
|
2029 |
+ if (swiper.isHorizontal()) { |
|
2030 |
+ if (rtl) slides.filter(slidesForMargin).css({ |
|
2031 |
+ marginLeft: spaceBetween + "px" |
|
2032 |
+ });else slides.filter(slidesForMargin).css({ |
|
2033 |
+ marginRight: spaceBetween + "px" |
|
2034 |
+ }); |
|
2035 |
+ } else slides.filter(slidesForMargin).css({ |
|
2036 |
+ marginBottom: spaceBetween + "px" |
|
2037 |
+ }); |
|
2038 |
+ } |
|
2039 |
+ |
|
2040 |
+ if (params.centeredSlides && params.centeredSlidesBounds) { |
|
2041 |
+ var allSlidesSize = 0; |
|
2042 |
+ slidesSizesGrid.forEach(function (slideSizeValue) { |
|
2043 |
+ allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0); |
|
2044 |
+ }); |
|
2045 |
+ allSlidesSize -= params.spaceBetween; |
|
2046 |
+ var maxSnap = allSlidesSize - swiperSize; |
|
2047 |
+ snapGrid = snapGrid.map(function (snap) { |
|
2048 |
+ if (snap < 0) return -offsetBefore; |
|
2049 |
+ if (snap > maxSnap) return maxSnap + offsetAfter; |
|
2050 |
+ return snap; |
|
2051 |
+ }); |
|
2052 |
+ } |
|
2053 |
+ |
|
2054 |
+ if (params.centerInsufficientSlides) { |
|
2055 |
+ var _allSlidesSize = 0; |
|
2056 |
+ slidesSizesGrid.forEach(function (slideSizeValue) { |
|
2057 |
+ _allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0); |
|
2058 |
+ }); |
|
2059 |
+ _allSlidesSize -= params.spaceBetween; |
|
2060 |
+ |
|
2061 |
+ if (_allSlidesSize < swiperSize) { |
|
2062 |
+ var allSlidesOffset = (swiperSize - _allSlidesSize) / 2; |
|
2063 |
+ snapGrid.forEach(function (snap, snapIndex) { |
|
2064 |
+ snapGrid[snapIndex] = snap - allSlidesOffset; |
|
2065 |
+ }); |
|
2066 |
+ slidesGrid.forEach(function (snap, snapIndex) { |
|
2067 |
+ slidesGrid[snapIndex] = snap + allSlidesOffset; |
|
2068 |
+ }); |
|
2069 |
+ } |
|
2070 |
+ } |
|
2071 |
+ |
|
2072 |
+ extend$1(swiper, { |
|
2073 |
+ slides: slides, |
|
2074 |
+ snapGrid: snapGrid, |
|
2075 |
+ slidesGrid: slidesGrid, |
|
2076 |
+ slidesSizesGrid: slidesSizesGrid |
|
2077 |
+ }); |
|
2078 |
+ |
|
2079 |
+ if (slidesLength !== previousSlidesLength) { |
|
2080 |
+ swiper.emit('slidesLengthChange'); |
|
2081 |
+ } |
|
2082 |
+ |
|
2083 |
+ if (snapGrid.length !== previousSnapGridLength) { |
|
2084 |
+ if (swiper.params.watchOverflow) swiper.checkOverflow(); |
|
2085 |
+ swiper.emit('snapGridLengthChange'); |
|
2086 |
+ } |
|
2087 |
+ |
|
2088 |
+ if (slidesGrid.length !== previousSlidesGridLength) { |
|
2089 |
+ swiper.emit('slidesGridLengthChange'); |
|
2090 |
+ } |
|
2091 |
+ |
|
2092 |
+ if (params.watchSlidesProgress || params.watchSlidesVisibility) { |
|
2093 |
+ swiper.updateSlidesOffset(); |
|
2094 |
+ } |
|
2095 |
+} |
|
2096 |
+ |
|
2097 |
+function updateAutoHeight(speed) { |
|
2098 |
+ var swiper = this; |
|
2099 |
+ var activeSlides = []; |
|
2100 |
+ var newHeight = 0; |
|
2101 |
+ var i; |
|
2102 |
+ |
|
2103 |
+ if (typeof speed === 'number') { |
|
2104 |
+ swiper.setTransition(speed); |
|
2105 |
+ } else if (speed === true) { |
|
2106 |
+ swiper.setTransition(swiper.params.speed); |
|
2107 |
+ } // Find slides currently in view |
|
2108 |
+ |
|
2109 |
+ |
|
2110 |
+ if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) { |
|
2111 |
+ if (swiper.params.centeredSlides) { |
|
2112 |
+ swiper.visibleSlides.each(function (slide) { |
|
2113 |
+ activeSlides.push(slide); |
|
2114 |
+ }); |
|
2115 |
+ } else { |
|
2116 |
+ for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) { |
|
2117 |
+ var index = swiper.activeIndex + i; |
|
2118 |
+ if (index > swiper.slides.length) break; |
|
2119 |
+ activeSlides.push(swiper.slides.eq(index)[0]); |
|
2120 |
+ } |
|
2121 |
+ } |
|
2122 |
+ } else { |
|
2123 |
+ activeSlides.push(swiper.slides.eq(swiper.activeIndex)[0]); |
|
2124 |
+ } // Find new height from highest slide in view |
|
2125 |
+ |
|
2126 |
+ |
|
2127 |
+ for (i = 0; i < activeSlides.length; i += 1) { |
|
2128 |
+ if (typeof activeSlides[i] !== 'undefined') { |
|
2129 |
+ var height = activeSlides[i].offsetHeight; |
|
2130 |
+ newHeight = height > newHeight ? height : newHeight; |
|
2131 |
+ } |
|
2132 |
+ } // Update Height |
|
2133 |
+ |
|
2134 |
+ |
|
2135 |
+ if (newHeight) swiper.$wrapperEl.css('height', newHeight + "px"); |
|
2136 |
+} |
|
2137 |
+ |
|
2138 |
+function updateSlidesOffset() { |
|
2139 |
+ var swiper = this; |
|
2140 |
+ var slides = swiper.slides; |
|
2141 |
+ |
|
2142 |
+ for (var i = 0; i < slides.length; i += 1) { |
|
2143 |
+ slides[i].swiperSlideOffset = swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop; |
|
2144 |
+ } |
|
2145 |
+} |
|
2146 |
+ |
|
2147 |
+function updateSlidesProgress(translate) { |
|
2148 |
+ if (translate === void 0) { |
|
2149 |
+ translate = this && this.translate || 0; |
|
2150 |
+ } |
|
2151 |
+ |
|
2152 |
+ var swiper = this; |
|
2153 |
+ var params = swiper.params; |
|
2154 |
+ var slides = swiper.slides, |
|
2155 |
+ rtl = swiper.rtlTranslate; |
|
2156 |
+ if (slides.length === 0) return; |
|
2157 |
+ if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset(); |
|
2158 |
+ var offsetCenter = -translate; |
|
2159 |
+ if (rtl) offsetCenter = translate; // Visible Slides |
|
2160 |
+ |
|
2161 |
+ slides.removeClass(params.slideVisibleClass); |
|
2162 |
+ swiper.visibleSlidesIndexes = []; |
|
2163 |
+ swiper.visibleSlides = []; |
|
2164 |
+ |
|
2165 |
+ for (var i = 0; i < slides.length; i += 1) { |
|
2166 |
+ var slide = slides[i]; |
|
2167 |
+ var slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slide.swiperSlideOffset) / (slide.swiperSlideSize + params.spaceBetween); |
|
2168 |
+ |
|
2169 |
+ if (params.watchSlidesVisibility || params.centeredSlides && params.autoHeight) { |
|
2170 |
+ var slideBefore = -(offsetCenter - slide.swiperSlideOffset); |
|
2171 |
+ var slideAfter = slideBefore + swiper.slidesSizesGrid[i]; |
|
2172 |
+ var isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size; |
|
2173 |
+ |
|
2174 |
+ if (isVisible) { |
|
2175 |
+ swiper.visibleSlides.push(slide); |
|
2176 |
+ swiper.visibleSlidesIndexes.push(i); |
|
2177 |
+ slides.eq(i).addClass(params.slideVisibleClass); |
|
2178 |
+ } |
|
2179 |
+ } |
|
2180 |
+ |
|
2181 |
+ slide.progress = rtl ? -slideProgress : slideProgress; |
|
2182 |
+ } |
|
2183 |
+ |
|
2184 |
+ swiper.visibleSlides = $(swiper.visibleSlides); |
|
2185 |
+} |
|
2186 |
+ |
|
2187 |
+function updateProgress(translate) { |
|
2188 |
+ var swiper = this; |
|
2189 |
+ |
|
2190 |
+ if (typeof translate === 'undefined') { |
|
2191 |
+ var multiplier = swiper.rtlTranslate ? -1 : 1; // eslint-disable-next-line |
|
2192 |
+ |
|
2193 |
+ translate = swiper && swiper.translate && swiper.translate * multiplier || 0; |
|
2194 |
+ } |
|
2195 |
+ |
|
2196 |
+ var params = swiper.params; |
|
2197 |
+ var translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); |
|
2198 |
+ var progress = swiper.progress, |
|
2199 |
+ isBeginning = swiper.isBeginning, |
|
2200 |
+ isEnd = swiper.isEnd; |
|
2201 |
+ var wasBeginning = isBeginning; |
|
2202 |
+ var wasEnd = isEnd; |
|
2203 |
+ |
|
2204 |
+ if (translatesDiff === 0) { |
|
2205 |
+ progress = 0; |
|
2206 |
+ isBeginning = true; |
|
2207 |
+ isEnd = true; |
|
2208 |
+ } else { |
|
2209 |
+ progress = (translate - swiper.minTranslate()) / translatesDiff; |
|
2210 |
+ isBeginning = progress <= 0; |
|
2211 |
+ isEnd = progress >= 1; |
|
2212 |
+ } |
|
2213 |
+ |
|
2214 |
+ extend$1(swiper, { |
|
2215 |
+ progress: progress, |
|
2216 |
+ isBeginning: isBeginning, |
|
2217 |
+ isEnd: isEnd |
|
2218 |
+ }); |
|
2219 |
+ if (params.watchSlidesProgress || params.watchSlidesVisibility || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate); |
|
2220 |
+ |
|
2221 |
+ if (isBeginning && !wasBeginning) { |
|
2222 |
+ swiper.emit('reachBeginning toEdge'); |
|
2223 |
+ } |
|
2224 |
+ |
|
2225 |
+ if (isEnd && !wasEnd) { |
|
2226 |
+ swiper.emit('reachEnd toEdge'); |
|
2227 |
+ } |
|
2228 |
+ |
|
2229 |
+ if (wasBeginning && !isBeginning || wasEnd && !isEnd) { |
|
2230 |
+ swiper.emit('fromEdge'); |
|
2231 |
+ } |
|
2232 |
+ |
|
2233 |
+ swiper.emit('progress', progress); |
|
2234 |
+} |
|
2235 |
+ |
|
2236 |
+function updateSlidesClasses() { |
|
2237 |
+ var swiper = this; |
|
2238 |
+ var slides = swiper.slides, |
|
2239 |
+ params = swiper.params, |
|
2240 |
+ $wrapperEl = swiper.$wrapperEl, |
|
2241 |
+ activeIndex = swiper.activeIndex, |
|
2242 |
+ realIndex = swiper.realIndex; |
|
2243 |
+ var isVirtual = swiper.virtual && params.virtual.enabled; |
|
2244 |
+ slides.removeClass(params.slideActiveClass + " " + params.slideNextClass + " " + params.slidePrevClass + " " + params.slideDuplicateActiveClass + " " + params.slideDuplicateNextClass + " " + params.slideDuplicatePrevClass); |
|
2245 |
+ var activeSlide; |
|
2246 |
+ |
|
2247 |
+ if (isVirtual) { |
|
2248 |
+ activeSlide = swiper.$wrapperEl.find("." + params.slideClass + "[data-swiper-slide-index=\"" + activeIndex + "\"]"); |
|
2249 |
+ } else { |
|
2250 |
+ activeSlide = slides.eq(activeIndex); |
|
2251 |
+ } // Active classes |
|
2252 |
+ |
|
2253 |
+ |
|
2254 |
+ activeSlide.addClass(params.slideActiveClass); |
|
2255 |
+ |
|
2256 |
+ if (params.loop) { |
|
2257 |
+ // Duplicate to all looped slides |
|
2258 |
+ if (activeSlide.hasClass(params.slideDuplicateClass)) { |
|
2259 |
+ $wrapperEl.children("." + params.slideClass + ":not(." + params.slideDuplicateClass + ")[data-swiper-slide-index=\"" + realIndex + "\"]").addClass(params.slideDuplicateActiveClass); |
|
2260 |
+ } else { |
|
2261 |
+ $wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass + "[data-swiper-slide-index=\"" + realIndex + "\"]").addClass(params.slideDuplicateActiveClass); |
|
2262 |
+ } |
|
2263 |
+ } // Next Slide |
|
2264 |
+ |
|
2265 |
+ |
|
2266 |
+ var nextSlide = activeSlide.nextAll("." + params.slideClass).eq(0).addClass(params.slideNextClass); |
|
2267 |
+ |
|
2268 |
+ if (params.loop && nextSlide.length === 0) { |
|
2269 |
+ nextSlide = slides.eq(0); |
|
2270 |
+ nextSlide.addClass(params.slideNextClass); |
|
2271 |
+ } // Prev Slide |
|
2272 |
+ |
|
2273 |
+ |
|
2274 |
+ var prevSlide = activeSlide.prevAll("." + params.slideClass).eq(0).addClass(params.slidePrevClass); |
|
2275 |
+ |
|
2276 |
+ if (params.loop && prevSlide.length === 0) { |
|
2277 |
+ prevSlide = slides.eq(-1); |
|
2278 |
+ prevSlide.addClass(params.slidePrevClass); |
|
2279 |
+ } |
|
2280 |
+ |
|
2281 |
+ if (params.loop) { |
|
2282 |
+ // Duplicate to all looped slides |
|
2283 |
+ if (nextSlide.hasClass(params.slideDuplicateClass)) { |
|
2284 |
+ $wrapperEl.children("." + params.slideClass + ":not(." + params.slideDuplicateClass + ")[data-swiper-slide-index=\"" + nextSlide.attr('data-swiper-slide-index') + "\"]").addClass(params.slideDuplicateNextClass); |
|
2285 |
+ } else { |
|
2286 |
+ $wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass + "[data-swiper-slide-index=\"" + nextSlide.attr('data-swiper-slide-index') + "\"]").addClass(params.slideDuplicateNextClass); |
|
2287 |
+ } |
|
2288 |
+ |
|
2289 |
+ if (prevSlide.hasClass(params.slideDuplicateClass)) { |
|
2290 |
+ $wrapperEl.children("." + params.slideClass + ":not(." + params.slideDuplicateClass + ")[data-swiper-slide-index=\"" + prevSlide.attr('data-swiper-slide-index') + "\"]").addClass(params.slideDuplicatePrevClass); |
|
2291 |
+ } else { |
|
2292 |
+ $wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass + "[data-swiper-slide-index=\"" + prevSlide.attr('data-swiper-slide-index') + "\"]").addClass(params.slideDuplicatePrevClass); |
|
2293 |
+ } |
|
2294 |
+ } |
|
2295 |
+ |
|
2296 |
+ swiper.emitSlidesClasses(); |
|
2297 |
+} |
|
2298 |
+ |
|
2299 |
+function updateActiveIndex(newActiveIndex) { |
|
2300 |
+ var swiper = this; |
|
2301 |
+ var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate; |
|
2302 |
+ var slidesGrid = swiper.slidesGrid, |
|
2303 |
+ snapGrid = swiper.snapGrid, |
|
2304 |
+ params = swiper.params, |
|
2305 |
+ previousIndex = swiper.activeIndex, |
|
2306 |
+ previousRealIndex = swiper.realIndex, |
|
2307 |
+ previousSnapIndex = swiper.snapIndex; |
|
2308 |
+ var activeIndex = newActiveIndex; |
|
2309 |
+ var snapIndex; |
|
2310 |
+ |
|
2311 |
+ if (typeof activeIndex === 'undefined') { |
|
2312 |
+ for (var i = 0; i < slidesGrid.length; i += 1) { |
|
2313 |
+ if (typeof slidesGrid[i + 1] !== 'undefined') { |
|
2314 |
+ if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) { |
|
2315 |
+ activeIndex = i; |
|
2316 |
+ } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) { |
|
2317 |
+ activeIndex = i + 1; |
|
2318 |
+ } |
|
2319 |
+ } else if (translate >= slidesGrid[i]) { |
|
2320 |
+ activeIndex = i; |
|
2321 |
+ } |
|
2322 |
+ } // Normalize slideIndex |
|
2323 |
+ |
|
2324 |
+ |
|
2325 |
+ if (params.normalizeSlideIndex) { |
|
2326 |
+ if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0; |
|
2327 |
+ } |
|
2328 |
+ } |
|
2329 |
+ |
|
2330 |
+ if (snapGrid.indexOf(translate) >= 0) { |
|
2331 |
+ snapIndex = snapGrid.indexOf(translate); |
|
2332 |
+ } else { |
|
2333 |
+ var skip = Math.min(params.slidesPerGroupSkip, activeIndex); |
|
2334 |
+ snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup); |
|
2335 |
+ } |
|
2336 |
+ |
|
2337 |
+ if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1; |
|
2338 |
+ |
|
2339 |
+ if (activeIndex === previousIndex) { |
|
2340 |
+ if (snapIndex !== previousSnapIndex) { |
|
2341 |
+ swiper.snapIndex = snapIndex; |
|
2342 |
+ swiper.emit('snapIndexChange'); |
|
2343 |
+ } |
|
2344 |
+ |
|
2345 |
+ return; |
|
2346 |
+ } // Get real index |
|
2347 |
+ |
|
2348 |
+ |
|
2349 |
+ var realIndex = parseInt(swiper.slides.eq(activeIndex).attr('data-swiper-slide-index') || activeIndex, 10); |
|
2350 |
+ extend$1(swiper, { |
|
2351 |
+ snapIndex: snapIndex, |
|
2352 |
+ realIndex: realIndex, |
|
2353 |
+ previousIndex: previousIndex, |
|
2354 |
+ activeIndex: activeIndex |
|
2355 |
+ }); |
|
2356 |
+ swiper.emit('activeIndexChange'); |
|
2357 |
+ swiper.emit('snapIndexChange'); |
|
2358 |
+ |
|
2359 |
+ if (previousRealIndex !== realIndex) { |
|
2360 |
+ swiper.emit('realIndexChange'); |
|
2361 |
+ } |
|
2362 |
+ |
|
2363 |
+ if (swiper.initialized || swiper.params.runCallbacksOnInit) { |
|
2364 |
+ swiper.emit('slideChange'); |
|
2365 |
+ } |
|
2366 |
+} |
|
2367 |
+ |
|
2368 |
+function updateClickedSlide(e) { |
|
2369 |
+ var swiper = this; |
|
2370 |
+ var params = swiper.params; |
|
2371 |
+ var slide = $(e.target).closest("." + params.slideClass)[0]; |
|
2372 |
+ var slideFound = false; |
|
2373 |
+ |
|
2374 |
+ if (slide) { |
|
2375 |
+ for (var i = 0; i < swiper.slides.length; i += 1) { |
|
2376 |
+ if (swiper.slides[i] === slide) slideFound = true; |
|
2377 |
+ } |
|
2378 |
+ } |
|
2379 |
+ |
|
2380 |
+ if (slide && slideFound) { |
|
2381 |
+ swiper.clickedSlide = slide; |
|
2382 |
+ |
|
2383 |
+ if (swiper.virtual && swiper.params.virtual.enabled) { |
|
2384 |
+ swiper.clickedIndex = parseInt($(slide).attr('data-swiper-slide-index'), 10); |
|
2385 |
+ } else { |
|
2386 |
+ swiper.clickedIndex = $(slide).index(); |
|
2387 |
+ } |
|
2388 |
+ } else { |
|
2389 |
+ swiper.clickedSlide = undefined; |
|
2390 |
+ swiper.clickedIndex = undefined; |
|
2391 |
+ return; |
|
2392 |
+ } |
|
2393 |
+ |
|
2394 |
+ if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) { |
|
2395 |
+ swiper.slideToClickedSlide(); |
|
2396 |
+ } |
|
2397 |
+} |
|
2398 |
+ |
|
2399 |
+var update = { |
|
2400 |
+ updateSize: updateSize, |
|
2401 |
+ updateSlides: updateSlides, |
|
2402 |
+ updateAutoHeight: updateAutoHeight, |
|
2403 |
+ updateSlidesOffset: updateSlidesOffset, |
|
2404 |
+ updateSlidesProgress: updateSlidesProgress, |
|
2405 |
+ updateProgress: updateProgress, |
|
2406 |
+ updateSlidesClasses: updateSlidesClasses, |
|
2407 |
+ updateActiveIndex: updateActiveIndex, |
|
2408 |
+ updateClickedSlide: updateClickedSlide |
|
2409 |
+}; |
|
2410 |
+ |
|
2411 |
+function getSwiperTranslate(axis) { |
|
2412 |
+ if (axis === void 0) { |
|
2413 |
+ axis = this.isHorizontal() ? 'x' : 'y'; |
|
2414 |
+ } |
|
2415 |
+ |
|
2416 |
+ var swiper = this; |
|
2417 |
+ var params = swiper.params, |
|
2418 |
+ rtl = swiper.rtlTranslate, |
|
2419 |
+ translate = swiper.translate, |
|
2420 |
+ $wrapperEl = swiper.$wrapperEl; |
|
2421 |
+ |
|
2422 |
+ if (params.virtualTranslate) { |
|
2423 |
+ return rtl ? -translate : translate; |
|
2424 |
+ } |
|
2425 |
+ |
|
2426 |
+ if (params.cssMode) { |
|
2427 |
+ return translate; |
|
2428 |
+ } |
|
2429 |
+ |
|
2430 |
+ var currentTranslate = getTranslate($wrapperEl[0], axis); |
|
2431 |
+ if (rtl) currentTranslate = -currentTranslate; |
|
2432 |
+ return currentTranslate || 0; |
|
2433 |
+} |
|
2434 |
+ |
|
2435 |
+function setTranslate(translate, byController) { |
|
2436 |
+ var swiper = this; |
|
2437 |
+ var rtl = swiper.rtlTranslate, |
|
2438 |
+ params = swiper.params, |
|
2439 |
+ $wrapperEl = swiper.$wrapperEl, |
|
2440 |
+ wrapperEl = swiper.wrapperEl, |
|
2441 |
+ progress = swiper.progress; |
|
2442 |
+ var x = 0; |
|
2443 |
+ var y = 0; |
|
2444 |
+ var z = 0; |
|
2445 |
+ |
|
2446 |
+ if (swiper.isHorizontal()) { |
|
2447 |
+ x = rtl ? -translate : translate; |
|
2448 |
+ } else { |
|
2449 |
+ y = translate; |
|
2450 |
+ } |
|
2451 |
+ |
|
2452 |
+ if (params.roundLengths) { |
|
2453 |
+ x = Math.floor(x); |
|
2454 |
+ y = Math.floor(y); |
|
2455 |
+ } |
|
2456 |
+ |
|
2457 |
+ if (params.cssMode) { |
|
2458 |
+ wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y; |
|
2459 |
+ } else if (!params.virtualTranslate) { |
|
2460 |
+ $wrapperEl.transform("translate3d(" + x + "px, " + y + "px, " + z + "px)"); |
|
2461 |
+ } |
|
2462 |
+ |
|
2463 |
+ swiper.previousTranslate = swiper.translate; |
|
2464 |
+ swiper.translate = swiper.isHorizontal() ? x : y; // Check if we need to update progress |
|
2465 |
+ |
|
2466 |
+ var newProgress; |
|
2467 |
+ var translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); |
|
2468 |
+ |
|
2469 |
+ if (translatesDiff === 0) { |
|
2470 |
+ newProgress = 0; |
|
2471 |
+ } else { |
|
2472 |
+ newProgress = (translate - swiper.minTranslate()) / translatesDiff; |
|
2473 |
+ } |
|
2474 |
+ |
|
2475 |
+ if (newProgress !== progress) { |
|
2476 |
+ swiper.updateProgress(translate); |
|
2477 |
+ } |
|
2478 |
+ |
|
2479 |
+ swiper.emit('setTranslate', swiper.translate, byController); |
|
2480 |
+} |
|
2481 |
+ |
|
2482 |
+function minTranslate() { |
|
2483 |
+ return -this.snapGrid[0]; |
|
2484 |
+} |
|
2485 |
+ |
|
2486 |
+function maxTranslate() { |
|
2487 |
+ return -this.snapGrid[this.snapGrid.length - 1]; |
|
2488 |
+} |
|
2489 |
+ |
|
2490 |
+function translateTo(translate, speed, runCallbacks, translateBounds, internal) { |
|
2491 |
+ if (translate === void 0) { |
|
2492 |
+ translate = 0; |
|
2493 |
+ } |
|
2494 |
+ |
|
2495 |
+ if (speed === void 0) { |
|
2496 |
+ speed = this.params.speed; |
|
2497 |
+ } |
|
2498 |
+ |
|
2499 |
+ if (runCallbacks === void 0) { |
|
2500 |
+ runCallbacks = true; |
|
2501 |
+ } |
|
2502 |
+ |
|
2503 |
+ if (translateBounds === void 0) { |
|
2504 |
+ translateBounds = true; |
|
2505 |
+ } |
|
2506 |
+ |
|
2507 |
+ var swiper = this; |
|
2508 |
+ var params = swiper.params, |
|
2509 |
+ wrapperEl = swiper.wrapperEl; |
|
2510 |
+ |
|
2511 |
+ if (swiper.animating && params.preventInteractionOnTransition) { |
|
2512 |
+ return false; |
|
2513 |
+ } |
|
2514 |
+ |
|
2515 |
+ var minTranslate = swiper.minTranslate(); |
|
2516 |
+ var maxTranslate = swiper.maxTranslate(); |
|
2517 |
+ var newTranslate; |
|
2518 |
+ if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate; // Update progress |
|
2519 |
+ |
|
2520 |
+ swiper.updateProgress(newTranslate); |
|
2521 |
+ |
|
2522 |
+ if (params.cssMode) { |
|
2523 |
+ var isH = swiper.isHorizontal(); |
|
2524 |
+ |
|
2525 |
+ if (speed === 0) { |
|
2526 |
+ wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate; |
|
2527 |
+ } else { |
|
2528 |
+ // eslint-disable-next-line |
|
2529 |
+ if (wrapperEl.scrollTo) { |
|
2530 |
+ var _wrapperEl$scrollTo; |
|
2531 |
+ |
|
2532 |
+ wrapperEl.scrollTo((_wrapperEl$scrollTo = {}, _wrapperEl$scrollTo[isH ? 'left' : 'top'] = -newTranslate, _wrapperEl$scrollTo.behavior = 'smooth', _wrapperEl$scrollTo)); |
|
2533 |
+ } else { |
|
2534 |
+ wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate; |
|
2535 |
+ } |
|
2536 |
+ } |
|
2537 |
+ |
|
2538 |
+ return true; |
|
2539 |
+ } |
|
2540 |
+ |
|
2541 |
+ if (speed === 0) { |
|
2542 |
+ swiper.setTransition(0); |
|
2543 |
+ swiper.setTranslate(newTranslate); |
|
2544 |
+ |
|
2545 |
+ if (runCallbacks) { |
|
2546 |
+ swiper.emit('beforeTransitionStart', speed, internal); |
|
2547 |
+ swiper.emit('transitionEnd'); |
|
2548 |
+ } |
|
2549 |
+ } else { |
|
2550 |
+ swiper.setTransition(speed); |
|
2551 |
+ swiper.setTranslate(newTranslate); |
|
2552 |
+ |
|
2553 |
+ if (runCallbacks) { |
|
2554 |
+ swiper.emit('beforeTransitionStart', speed, internal); |
|
2555 |
+ swiper.emit('transitionStart'); |
|
2556 |
+ } |
|
2557 |
+ |
|
2558 |
+ if (!swiper.animating) { |
|
2559 |
+ swiper.animating = true; |
|
2560 |
+ |
|
2561 |
+ if (!swiper.onTranslateToWrapperTransitionEnd) { |
|
2562 |
+ swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) { |
|
2563 |
+ if (!swiper || swiper.destroyed) return; |
|
2564 |
+ if (e.target !== this) return; |
|
2565 |
+ swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd); |
|
2566 |
+ swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd); |
|
2567 |
+ swiper.onTranslateToWrapperTransitionEnd = null; |
|
2568 |
+ delete swiper.onTranslateToWrapperTransitionEnd; |
|
2569 |
+ |
|
2570 |
+ if (runCallbacks) { |
|
2571 |
+ swiper.emit('transitionEnd'); |
|
2572 |
+ } |
|
2573 |
+ }; |
|
2574 |
+ } |
|
2575 |
+ |
|
2576 |
+ swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd); |
|
2577 |
+ swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd); |
|
2578 |
+ } |
|
2579 |
+ } |
|
2580 |
+ |
|
2581 |
+ return true; |
|
2582 |
+} |
|
2583 |
+ |
|
2584 |
+var translate = { |
|
2585 |
+ getTranslate: getSwiperTranslate, |
|
2586 |
+ setTranslate: setTranslate, |
|
2587 |
+ minTranslate: minTranslate, |
|
2588 |
+ maxTranslate: maxTranslate, |
|
2589 |
+ translateTo: translateTo |
|
2590 |
+}; |
|
2591 |
+ |
|
2592 |
+function setTransition(duration, byController) { |
|
2593 |
+ var swiper = this; |
|
2594 |
+ |
|
2595 |
+ if (!swiper.params.cssMode) { |
|
2596 |
+ swiper.$wrapperEl.transition(duration); |
|
2597 |
+ } |
|
2598 |
+ |
|
2599 |
+ swiper.emit('setTransition', duration, byController); |
|
2600 |
+} |
|
2601 |
+ |
|
2602 |
+function transitionStart(runCallbacks, direction) { |
|
2603 |
+ if (runCallbacks === void 0) { |
|
2604 |
+ runCallbacks = true; |
|
2605 |
+ } |
|
2606 |
+ |
|
2607 |
+ var swiper = this; |
|
2608 |
+ var activeIndex = swiper.activeIndex, |
|
2609 |
+ params = swiper.params, |
|
2610 |
+ previousIndex = swiper.previousIndex; |
|
2611 |
+ if (params.cssMode) return; |
|
2612 |
+ |
|
2613 |
+ if (params.autoHeight) { |
|
2614 |
+ swiper.updateAutoHeight(); |
|
2615 |
+ } |
|
2616 |
+ |
|
2617 |
+ var dir = direction; |
|
2618 |
+ |
|
2619 |
+ if (!dir) { |
|
2620 |
+ if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset'; |
|
2621 |
+ } |
|
2622 |
+ |
|
2623 |
+ swiper.emit('transitionStart'); |
|
2624 |
+ |
|
2625 |
+ if (runCallbacks && activeIndex !== previousIndex) { |
|
2626 |
+ if (dir === 'reset') { |
|
2627 |
+ swiper.emit('slideResetTransitionStart'); |
|
2628 |
+ return; |
|
2629 |
+ } |
|
2630 |
+ |
|
2631 |
+ swiper.emit('slideChangeTransitionStart'); |
|
2632 |
+ |
|
2633 |
+ if (dir === 'next') { |
|
2634 |
+ swiper.emit('slideNextTransitionStart'); |
|
2635 |
+ } else { |
|
2636 |
+ swiper.emit('slidePrevTransitionStart'); |
|
2637 |
+ } |
|
2638 |
+ } |
|
2639 |
+} |
|
2640 |
+ |
|
2641 |
+function transitionEnd$1(runCallbacks, direction) { |
|
2642 |
+ if (runCallbacks === void 0) { |
|
2643 |
+ runCallbacks = true; |
|
2644 |
+ } |
|
2645 |
+ |
|
2646 |
+ var swiper = this; |
|
2647 |
+ var activeIndex = swiper.activeIndex, |
|
2648 |
+ previousIndex = swiper.previousIndex, |
|
2649 |
+ params = swiper.params; |
|
2650 |
+ swiper.animating = false; |
|
2651 |
+ if (params.cssMode) return; |
|
2652 |
+ swiper.setTransition(0); |
|
2653 |
+ var dir = direction; |
|
2654 |
+ |
|
2655 |
+ if (!dir) { |
|
2656 |
+ if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset'; |
|
2657 |
+ } |
|
2658 |
+ |
|
2659 |
+ swiper.emit('transitionEnd'); |
|
2660 |
+ |
|
2661 |
+ if (runCallbacks && activeIndex !== previousIndex) { |
|
2662 |
+ if (dir === 'reset') { |
|
2663 |
+ swiper.emit('slideResetTransitionEnd'); |
|
2664 |
+ return; |
|
2665 |
+ } |
|
2666 |
+ |
|
2667 |
+ swiper.emit('slideChangeTransitionEnd'); |
|
2668 |
+ |
|
2669 |
+ if (dir === 'next') { |
|
2670 |
+ swiper.emit('slideNextTransitionEnd'); |
|
2671 |
+ } else { |
|
2672 |
+ swiper.emit('slidePrevTransitionEnd'); |
|
2673 |
+ } |
|
2674 |
+ } |
|
2675 |
+} |
|
2676 |
+ |
|
2677 |
+var transition$1 = { |
|
2678 |
+ setTransition: setTransition, |
|
2679 |
+ transitionStart: transitionStart, |
|
2680 |
+ transitionEnd: transitionEnd$1 |
|
2681 |
+}; |
|
2682 |
+ |
|
2683 |
+function slideTo(index, speed, runCallbacks, internal) { |
|
2684 |
+ if (index === void 0) { |
|
2685 |
+ index = 0; |
|
2686 |
+ } |
|
2687 |
+ |
|
2688 |
+ if (speed === void 0) { |
|
2689 |
+ speed = this.params.speed; |
|
2690 |
+ } |
|
2691 |
+ |
|
2692 |
+ if (runCallbacks === void 0) { |
|
2693 |
+ runCallbacks = true; |
|
2694 |
+ } |
|
2695 |
+ |
|
2696 |
+ var swiper = this; |
|
2697 |
+ var slideIndex = index; |
|
2698 |
+ if (slideIndex < 0) slideIndex = 0; |
|
2699 |
+ var params = swiper.params, |
|
2700 |
+ snapGrid = swiper.snapGrid, |
|
2701 |
+ slidesGrid = swiper.slidesGrid, |
|
2702 |
+ previousIndex = swiper.previousIndex, |
|
2703 |
+ activeIndex = swiper.activeIndex, |
|
2704 |
+ rtl = swiper.rtlTranslate, |
|
2705 |
+ wrapperEl = swiper.wrapperEl; |
|
2706 |
+ |
|
2707 |
+ if (swiper.animating && params.preventInteractionOnTransition) { |
|
2708 |
+ return false; |
|
2709 |
+ } |
|
2710 |
+ |
|
2711 |
+ var skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex); |
|
2712 |
+ var snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup); |
|
2713 |
+ if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1; |
|
2714 |
+ |
|
2715 |
+ if ((activeIndex || params.initialSlide || 0) === (previousIndex || 0) && runCallbacks) { |
|
2716 |
+ swiper.emit('beforeSlideChangeStart'); |
|
2717 |
+ } |
|
2718 |
+ |
|
2719 |
+ var translate = -snapGrid[snapIndex]; // Update progress |
|
2720 |
+ |
|
2721 |
+ swiper.updateProgress(translate); // Normalize slideIndex |
|
2722 |
+ |
|
2723 |
+ if (params.normalizeSlideIndex) { |
|
2724 |
+ for (var i = 0; i < slidesGrid.length; i += 1) { |
|
2725 |
+ if (-Math.floor(translate * 100) >= Math.floor(slidesGrid[i] * 100)) { |
|
2726 |
+ slideIndex = i; |
|
2727 |
+ } |
|
2728 |
+ } |
|
2729 |
+ } // Directions locks |
|
2730 |
+ |
|
2731 |
+ |
|
2732 |
+ if (swiper.initialized && slideIndex !== activeIndex) { |
|
2733 |
+ if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) { |
|
2734 |
+ return false; |
|
2735 |
+ } |
|
2736 |
+ |
|
2737 |
+ if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) { |
|
2738 |
+ if ((activeIndex || 0) !== slideIndex) return false; |
|
2739 |
+ } |
|
2740 |
+ } |
|
2741 |
+ |
|
2742 |
+ var direction; |
|
2743 |
+ if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset'; // Update Index |
|
2744 |
+ |
|
2745 |
+ if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) { |
|
2746 |
+ swiper.updateActiveIndex(slideIndex); // Update Height |
|
2747 |
+ |
|
2748 |
+ if (params.autoHeight) { |
|
2749 |
+ swiper.updateAutoHeight(); |
|
2750 |
+ } |
|
2751 |
+ |
|
2752 |
+ swiper.updateSlidesClasses(); |
|
2753 |
+ |
|
2754 |
+ if (params.effect !== 'slide') { |
|
2755 |
+ swiper.setTranslate(translate); |
|
2756 |
+ } |
|
2757 |
+ |
|
2758 |
+ if (direction !== 'reset') { |
|
2759 |
+ swiper.transitionStart(runCallbacks, direction); |
|
2760 |
+ swiper.transitionEnd(runCallbacks, direction); |
|
2761 |
+ } |
|
2762 |
+ |
|
2763 |
+ return false; |
|
2764 |
+ } |
|
2765 |
+ |
|
2766 |
+ if (params.cssMode) { |
|
2767 |
+ var isH = swiper.isHorizontal(); |
|
2768 |
+ var t = -translate; |
|
2769 |
+ |
|
2770 |
+ if (rtl) { |
|
2771 |
+ t = wrapperEl.scrollWidth - wrapperEl.offsetWidth - t; |
|
2772 |
+ } |
|
2773 |
+ |
|
2774 |
+ if (speed === 0) { |
|
2775 |
+ wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t; |
|
2776 |
+ } else { |
|
2777 |
+ // eslint-disable-next-line |
|
2778 |
+ if (wrapperEl.scrollTo) { |
|
2779 |
+ var _wrapperEl$scrollTo; |
|
2780 |
+ |
|
2781 |
+ wrapperEl.scrollTo((_wrapperEl$scrollTo = {}, _wrapperEl$scrollTo[isH ? 'left' : 'top'] = t, _wrapperEl$scrollTo.behavior = 'smooth', _wrapperEl$scrollTo)); |
|
2782 |
+ } else { |
|
2783 |
+ wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t; |
|
2784 |
+ } |
|
2785 |
+ } |
|
2786 |
+ |
|
2787 |
+ return true; |
|
2788 |
+ } |
|
2789 |
+ |
|
2790 |
+ if (speed === 0) { |
|
2791 |
+ swiper.setTransition(0); |
|
2792 |
+ swiper.setTranslate(translate); |
|
2793 |
+ swiper.updateActiveIndex(slideIndex); |
|
2794 |
+ swiper.updateSlidesClasses(); |
|
2795 |
+ swiper.emit('beforeTransitionStart', speed, internal); |
|
2796 |
+ swiper.transitionStart(runCallbacks, direction); |
|
2797 |
+ swiper.transitionEnd(runCallbacks, direction); |
|
2798 |
+ } else { |
|
2799 |
+ swiper.setTransition(speed); |
|
2800 |
+ swiper.setTranslate(translate); |
|
2801 |
+ swiper.updateActiveIndex(slideIndex); |
|
2802 |
+ swiper.updateSlidesClasses(); |
|
2803 |
+ swiper.emit('beforeTransitionStart', speed, internal); |
|
2804 |
+ swiper.transitionStart(runCallbacks, direction); |
|
2805 |
+ |
|
2806 |
+ if (!swiper.animating) { |
|
2807 |
+ swiper.animating = true; |
|
2808 |
+ |
|
2809 |
+ if (!swiper.onSlideToWrapperTransitionEnd) { |
|
2810 |
+ swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) { |
|
2811 |
+ if (!swiper || swiper.destroyed) return; |
|
2812 |
+ if (e.target !== this) return; |
|
2813 |
+ swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd); |
|
2814 |
+ swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd); |
|
2815 |
+ swiper.onSlideToWrapperTransitionEnd = null; |
|
2816 |
+ delete swiper.onSlideToWrapperTransitionEnd; |
|
2817 |
+ swiper.transitionEnd(runCallbacks, direction); |
|
2818 |
+ }; |
|
2819 |
+ } |
|
2820 |
+ |
|
2821 |
+ swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd); |
|
2822 |
+ swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd); |
|
2823 |
+ } |
|
2824 |
+ } |
|
2825 |
+ |
|
2826 |
+ return true; |
|
2827 |
+} |
|
2828 |
+ |
|
2829 |
+function slideToLoop(index, speed, runCallbacks, internal) { |
|
2830 |
+ if (index === void 0) { |
|
2831 |
+ index = 0; |
|
2832 |
+ } |
|
2833 |
+ |
|
2834 |
+ if (speed === void 0) { |
|
2835 |
+ speed = this.params.speed; |
|
2836 |
+ } |
|
2837 |
+ |
|
2838 |
+ if (runCallbacks === void 0) { |
|
2839 |
+ runCallbacks = true; |
|
2840 |
+ } |
|
2841 |
+ |
|
2842 |
+ var swiper = this; |
|
2843 |
+ var newIndex = index; |
|
2844 |
+ |
|
2845 |
+ if (swiper.params.loop) { |
|
2846 |
+ newIndex += swiper.loopedSlides; |
|
2847 |
+ } |
|
2848 |
+ |
|
2849 |
+ return swiper.slideTo(newIndex, speed, runCallbacks, internal); |
|
2850 |
+} |
|
2851 |
+ |
|
2852 |
+/* eslint no-unused-vars: "off" */ |
|
2853 |
+function slideNext(speed, runCallbacks, internal) { |
|
2854 |
+ if (speed === void 0) { |
|
2855 |
+ speed = this.params.speed; |
|
2856 |
+ } |
|
2857 |
+ |
|
2858 |
+ if (runCallbacks === void 0) { |
|
2859 |
+ runCallbacks = true; |
|
2860 |
+ } |
|
2861 |
+ |
|
2862 |
+ var swiper = this; |
|
2863 |
+ var params = swiper.params, |
|
2864 |
+ animating = swiper.animating; |
|
2865 |
+ var increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup; |
|
2866 |
+ |
|
2867 |
+ if (params.loop) { |
|
2868 |
+ if (animating && params.loopPreventsSlide) return false; |
|
2869 |
+ swiper.loopFix(); // eslint-disable-next-line |
|
2870 |
+ |
|
2871 |
+ swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; |
|
2872 |
+ } |
|
2873 |
+ |
|
2874 |
+ return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal); |
|
2875 |
+} |
|
2876 |
+ |
|
2877 |
+/* eslint no-unused-vars: "off" */ |
|
2878 |
+function slidePrev(speed, runCallbacks, internal) { |
|
2879 |
+ if (speed === void 0) { |
|
2880 |
+ speed = this.params.speed; |
|
2881 |
+ } |
|
2882 |
+ |
|
2883 |
+ if (runCallbacks === void 0) { |
|
2884 |
+ runCallbacks = true; |
|
2885 |
+ } |
|
2886 |
+ |
|
2887 |
+ var swiper = this; |
|
2888 |
+ var params = swiper.params, |
|
2889 |
+ animating = swiper.animating, |
|
2890 |
+ snapGrid = swiper.snapGrid, |
|
2891 |
+ slidesGrid = swiper.slidesGrid, |
|
2892 |
+ rtlTranslate = swiper.rtlTranslate; |
|
2893 |
+ |
|
2894 |
+ if (params.loop) { |
|
2895 |
+ if (animating && params.loopPreventsSlide) return false; |
|
2896 |
+ swiper.loopFix(); // eslint-disable-next-line |
|
2897 |
+ |
|
2898 |
+ swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; |
|
2899 |
+ } |
|
2900 |
+ |
|
2901 |
+ var translate = rtlTranslate ? swiper.translate : -swiper.translate; |
|
2902 |
+ |
|
2903 |
+ function normalize(val) { |
|
2904 |
+ if (val < 0) return -Math.floor(Math.abs(val)); |
|
2905 |
+ return Math.floor(val); |
|
2906 |
+ } |
|
2907 |
+ |
|
2908 |
+ var normalizedTranslate = normalize(translate); |
|
2909 |
+ var normalizedSnapGrid = snapGrid.map(function (val) { |
|
2910 |
+ return normalize(val); |
|
2911 |
+ }); |
|
2912 |
+ var currentSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate)]; |
|
2913 |
+ var prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1]; |
|
2914 |
+ |
|
2915 |
+ if (typeof prevSnap === 'undefined' && params.cssMode) { |
|
2916 |
+ snapGrid.forEach(function (snap) { |
|
2917 |
+ if (!prevSnap && normalizedTranslate >= snap) prevSnap = snap; |
|
2918 |
+ }); |
|
2919 |
+ } |
|
2920 |
+ |
|
2921 |
+ var prevIndex; |
|
2922 |
+ |
|
2923 |
+ if (typeof prevSnap !== 'undefined') { |
|
2924 |
+ prevIndex = slidesGrid.indexOf(prevSnap); |
|
2925 |
+ if (prevIndex < 0) prevIndex = swiper.activeIndex - 1; |
|
2926 |
+ } |
|
2927 |
+ |
|
2928 |
+ return swiper.slideTo(prevIndex, speed, runCallbacks, internal); |
|
2929 |
+} |
|
2930 |
+ |
|
2931 |
+/* eslint no-unused-vars: "off" */ |
|
2932 |
+function slideReset(speed, runCallbacks, internal) { |
|
2933 |
+ if (speed === void 0) { |
|
2934 |
+ speed = this.params.speed; |
|
2935 |
+ } |
|
2936 |
+ |
|
2937 |
+ if (runCallbacks === void 0) { |
|
2938 |
+ runCallbacks = true; |
|
2939 |
+ } |
|
2940 |
+ |
|
2941 |
+ var swiper = this; |
|
2942 |
+ return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal); |
|
2943 |
+} |
|
2944 |
+ |
|
2945 |
+/* eslint no-unused-vars: "off" */ |
|
2946 |
+function slideToClosest(speed, runCallbacks, internal, threshold) { |
|
2947 |
+ if (speed === void 0) { |
|
2948 |
+ speed = this.params.speed; |
|
2949 |
+ } |
|
2950 |
+ |
|
2951 |
+ if (runCallbacks === void 0) { |
|
2952 |
+ runCallbacks = true; |
|
2953 |
+ } |
|
2954 |
+ |
|
2955 |
+ if (threshold === void 0) { |
|
2956 |
+ threshold = 0.5; |
|
2957 |
+ } |
|
2958 |
+ |
|
2959 |
+ var swiper = this; |
|
2960 |
+ var index = swiper.activeIndex; |
|
2961 |
+ var skip = Math.min(swiper.params.slidesPerGroupSkip, index); |
|
2962 |
+ var snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup); |
|
2963 |
+ var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate; |
|
2964 |
+ |
|
2965 |
+ if (translate >= swiper.snapGrid[snapIndex]) { |
|
2966 |
+ // The current translate is on or after the current snap index, so the choice |
|
2967 |
+ // is between the current index and the one after it. |
|
2968 |
+ var currentSnap = swiper.snapGrid[snapIndex]; |
|
2969 |
+ var nextSnap = swiper.snapGrid[snapIndex + 1]; |
|
2970 |
+ |
|
2971 |
+ if (translate - currentSnap > (nextSnap - currentSnap) * threshold) { |
|
2972 |
+ index += swiper.params.slidesPerGroup; |
|
2973 |
+ } |
|
2974 |
+ } else { |
|
2975 |
+ // The current translate is before the current snap index, so the choice |
|
2976 |
+ // is between the current index and the one before it. |
|
2977 |
+ var prevSnap = swiper.snapGrid[snapIndex - 1]; |
|
2978 |
+ var _currentSnap = swiper.snapGrid[snapIndex]; |
|
2979 |
+ |
|
2980 |
+ if (translate - prevSnap <= (_currentSnap - prevSnap) * threshold) { |
|
2981 |
+ index -= swiper.params.slidesPerGroup; |
|
2982 |
+ } |
|
2983 |
+ } |
|
2984 |
+ |
|
2985 |
+ index = Math.max(index, 0); |
|
2986 |
+ index = Math.min(index, swiper.slidesGrid.length - 1); |
|
2987 |
+ return swiper.slideTo(index, speed, runCallbacks, internal); |
|
2988 |
+} |
|
2989 |
+ |
|
2990 |
+function slideToClickedSlide() { |
|
2991 |
+ var swiper = this; |
|
2992 |
+ var params = swiper.params, |
|
2993 |
+ $wrapperEl = swiper.$wrapperEl; |
|
2994 |
+ var slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView; |
|
2995 |
+ var slideToIndex = swiper.clickedIndex; |
|
2996 |
+ var realIndex; |
|
2997 |
+ |
|
2998 |
+ if (params.loop) { |
|
2999 |
+ if (swiper.animating) return; |
|
3000 |
+ realIndex = parseInt($(swiper.clickedSlide).attr('data-swiper-slide-index'), 10); |
|
3001 |
+ |
|
3002 |
+ if (params.centeredSlides) { |
|
3003 |
+ if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2) { |
|
3004 |
+ swiper.loopFix(); |
|
3005 |
+ slideToIndex = $wrapperEl.children("." + params.slideClass + "[data-swiper-slide-index=\"" + realIndex + "\"]:not(." + params.slideDuplicateClass + ")").eq(0).index(); |
|
3006 |
+ nextTick(function () { |
|
3007 |
+ swiper.slideTo(slideToIndex); |
|
3008 |
+ }); |
|
3009 |
+ } else { |
|
3010 |
+ swiper.slideTo(slideToIndex); |
|
3011 |
+ } |
|
3012 |
+ } else if (slideToIndex > swiper.slides.length - slidesPerView) { |
|
3013 |
+ swiper.loopFix(); |
|
3014 |
+ slideToIndex = $wrapperEl.children("." + params.slideClass + "[data-swiper-slide-index=\"" + realIndex + "\"]:not(." + params.slideDuplicateClass + ")").eq(0).index(); |
|
3015 |
+ nextTick(function () { |
|
3016 |
+ swiper.slideTo(slideToIndex); |
|
3017 |
+ }); |
|
3018 |
+ } else { |
|
3019 |
+ swiper.slideTo(slideToIndex); |
|
3020 |
+ } |
|
3021 |
+ } else { |
|
3022 |
+ swiper.slideTo(slideToIndex); |
|
3023 |
+ } |
|
3024 |
+} |
|
3025 |
+ |
|
3026 |
+var slide = { |
|
3027 |
+ slideTo: slideTo, |
|
3028 |
+ slideToLoop: slideToLoop, |
|
3029 |
+ slideNext: slideNext, |
|
3030 |
+ slidePrev: slidePrev, |
|
3031 |
+ slideReset: slideReset, |
|
3032 |
+ slideToClosest: slideToClosest, |
|
3033 |
+ slideToClickedSlide: slideToClickedSlide |
|
3034 |
+}; |
|
3035 |
+ |
|
3036 |
+function loopCreate() { |
|
3037 |
+ var swiper = this; |
|
3038 |
+ var document = getDocument(); |
|
3039 |
+ var params = swiper.params, |
|
3040 |
+ $wrapperEl = swiper.$wrapperEl; // Remove duplicated slides |
|
3041 |
+ |
|
3042 |
+ $wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass).remove(); |
|
3043 |
+ var slides = $wrapperEl.children("." + params.slideClass); |
|
3044 |
+ |
|
3045 |
+ if (params.loopFillGroupWithBlank) { |
|
3046 |
+ var blankSlidesNum = params.slidesPerGroup - slides.length % params.slidesPerGroup; |
|
3047 |
+ |
|
3048 |
+ if (blankSlidesNum !== params.slidesPerGroup) { |
|
3049 |
+ for (var i = 0; i < blankSlidesNum; i += 1) { |
|
3050 |
+ var blankNode = $(document.createElement('div')).addClass(params.slideClass + " " + params.slideBlankClass); |
|
3051 |
+ $wrapperEl.append(blankNode); |
|
3052 |
+ } |
|
3053 |
+ |
|
3054 |
+ slides = $wrapperEl.children("." + params.slideClass); |
|
3055 |
+ } |
|
3056 |
+ } |
|
3057 |
+ |
|
3058 |
+ if (params.slidesPerView === 'auto' && !params.loopedSlides) params.loopedSlides = slides.length; |
|
3059 |
+ swiper.loopedSlides = Math.ceil(parseFloat(params.loopedSlides || params.slidesPerView, 10)); |
|
3060 |
+ swiper.loopedSlides += params.loopAdditionalSlides; |
|
3061 |
+ |
|
3062 |
+ if (swiper.loopedSlides > slides.length) { |
|
3063 |
+ swiper.loopedSlides = slides.length; |
|
3064 |
+ } |
|
3065 |
+ |
|
3066 |
+ var prependSlides = []; |
|
3067 |
+ var appendSlides = []; |
|
3068 |
+ slides.each(function (el, index) { |
|
3069 |
+ var slide = $(el); |
|
3070 |
+ |
|
3071 |
+ if (index < swiper.loopedSlides) { |
|
3072 |
+ appendSlides.push(el); |
|
3073 |
+ } |
|
3074 |
+ |
|
3075 |
+ if (index < slides.length && index >= slides.length - swiper.loopedSlides) { |
|
3076 |
+ prependSlides.push(el); |
|
3077 |
+ } |
|
3078 |
+ |
|
3079 |
+ slide.attr('data-swiper-slide-index', index); |
|
3080 |
+ }); |
|
3081 |
+ |
|
3082 |
+ for (var _i = 0; _i < appendSlides.length; _i += 1) { |
|
3083 |
+ $wrapperEl.append($(appendSlides[_i].cloneNode(true)).addClass(params.slideDuplicateClass)); |
|
3084 |
+ } |
|
3085 |
+ |
|
3086 |
+ for (var _i2 = prependSlides.length - 1; _i2 >= 0; _i2 -= 1) { |
|
3087 |
+ $wrapperEl.prepend($(prependSlides[_i2].cloneNode(true)).addClass(params.slideDuplicateClass)); |
|
3088 |
+ } |
|
3089 |
+} |
|
3090 |
+ |
|
3091 |
+function loopFix() { |
|
3092 |
+ var swiper = this; |
|
3093 |
+ swiper.emit('beforeLoopFix'); |
|
3094 |
+ var activeIndex = swiper.activeIndex, |
|
3095 |
+ slides = swiper.slides, |
|
3096 |
+ loopedSlides = swiper.loopedSlides, |
|
3097 |
+ allowSlidePrev = swiper.allowSlidePrev, |
|
3098 |
+ allowSlideNext = swiper.allowSlideNext, |
|
3099 |
+ snapGrid = swiper.snapGrid, |
|
3100 |
+ rtl = swiper.rtlTranslate; |
|
3101 |
+ var newIndex; |
|
3102 |
+ swiper.allowSlidePrev = true; |
|
3103 |
+ swiper.allowSlideNext = true; |
|
3104 |
+ var snapTranslate = -snapGrid[activeIndex]; |
|
3105 |
+ var diff = snapTranslate - swiper.getTranslate(); // Fix For Negative Oversliding |
|
3106 |
+ |
|
3107 |
+ if (activeIndex < loopedSlides) { |
|
3108 |
+ newIndex = slides.length - loopedSlides * 3 + activeIndex; |
|
3109 |
+ newIndex += loopedSlides; |
|
3110 |
+ var slideChanged = swiper.slideTo(newIndex, 0, false, true); |
|
3111 |
+ |
|
3112 |
+ if (slideChanged && diff !== 0) { |
|
3113 |
+ swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff); |
|
3114 |
+ } |
|
3115 |
+ } else if (activeIndex >= slides.length - loopedSlides) { |
|
3116 |
+ // Fix For Positive Oversliding |
|
3117 |
+ newIndex = -slides.length + activeIndex + loopedSlides; |
|
3118 |
+ newIndex += loopedSlides; |
|
3119 |
+ |
|
3120 |
+ var _slideChanged = swiper.slideTo(newIndex, 0, false, true); |
|
3121 |
+ |
|
3122 |
+ if (_slideChanged && diff !== 0) { |
|
3123 |
+ swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff); |
|
3124 |
+ } |
|
3125 |
+ } |
|
3126 |
+ |
|
3127 |
+ swiper.allowSlidePrev = allowSlidePrev; |
|
3128 |
+ swiper.allowSlideNext = allowSlideNext; |
|
3129 |
+ swiper.emit('loopFix'); |
|
3130 |
+} |
|
3131 |
+ |
|
3132 |
+function loopDestroy() { |
|
3133 |
+ var swiper = this; |
|
3134 |
+ var $wrapperEl = swiper.$wrapperEl, |
|
3135 |
+ params = swiper.params, |
|
3136 |
+ slides = swiper.slides; |
|
3137 |
+ $wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass + ",." + params.slideClass + "." + params.slideBlankClass).remove(); |
|
3138 |
+ slides.removeAttr('data-swiper-slide-index'); |
|
3139 |
+} |
|
3140 |
+ |
|
3141 |
+var loop = { |
|
3142 |
+ loopCreate: loopCreate, |
|
3143 |
+ loopFix: loopFix, |
|
3144 |
+ loopDestroy: loopDestroy |
|
3145 |
+}; |
|
3146 |
+ |
|
3147 |
+function setGrabCursor(moving) { |
|
3148 |
+ var swiper = this; |
|
3149 |
+ if (swiper.support.touch || !swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return; |
|
3150 |
+ var el = swiper.el; |
|
3151 |
+ el.style.cursor = 'move'; |
|
3152 |
+ el.style.cursor = moving ? '-webkit-grabbing' : '-webkit-grab'; |
|
3153 |
+ el.style.cursor = moving ? '-moz-grabbin' : '-moz-grab'; |
|
3154 |
+ el.style.cursor = moving ? 'grabbing' : 'grab'; |
|
3155 |
+} |
|
3156 |
+ |
|
3157 |
+function unsetGrabCursor() { |
|
3158 |
+ var swiper = this; |
|
3159 |
+ |
|
3160 |
+ if (swiper.support.touch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) { |
|
3161 |
+ return; |
|
3162 |
+ } |
|
3163 |
+ |
|
3164 |
+ swiper.el.style.cursor = ''; |
|
3165 |
+} |
|
3166 |
+ |
|
3167 |
+var grabCursor = { |
|
3168 |
+ setGrabCursor: setGrabCursor, |
|
3169 |
+ unsetGrabCursor: unsetGrabCursor |
|
3170 |
+}; |
|
3171 |
+ |
|
3172 |
+function appendSlide(slides) { |
|
3173 |
+ var swiper = this; |
|
3174 |
+ var $wrapperEl = swiper.$wrapperEl, |
|
3175 |
+ params = swiper.params; |
|
3176 |
+ |
|
3177 |
+ if (params.loop) { |
|
3178 |
+ swiper.loopDestroy(); |
|
3179 |
+ } |
|
3180 |
+ |
|
3181 |
+ if (typeof slides === 'object' && 'length' in slides) { |
|
3182 |
+ for (var i = 0; i < slides.length; i += 1) { |
|
3183 |
+ if (slides[i]) $wrapperEl.append(slides[i]); |
|
3184 |
+ } |
|
3185 |
+ } else { |
|
3186 |
+ $wrapperEl.append(slides); |
|
3187 |
+ } |
|
3188 |
+ |
|
3189 |
+ if (params.loop) { |
|
3190 |
+ swiper.loopCreate(); |
|
3191 |
+ } |
|
3192 |
+ |
|
3193 |
+ if (!(params.observer && swiper.support.observer)) { |
|
3194 |
+ swiper.update(); |
|
3195 |
+ } |
|
3196 |
+} |
|
3197 |
+ |
|
3198 |
+function prependSlide(slides) { |
|
3199 |
+ var swiper = this; |
|
3200 |
+ var params = swiper.params, |
|
3201 |
+ $wrapperEl = swiper.$wrapperEl, |
|
3202 |
+ activeIndex = swiper.activeIndex; |
|
3203 |
+ |
|
3204 |
+ if (params.loop) { |
|
3205 |
+ swiper.loopDestroy(); |
|
3206 |
+ } |
|
3207 |
+ |
|
3208 |
+ var newActiveIndex = activeIndex + 1; |
|
3209 |
+ |
|
3210 |
+ if (typeof slides === 'object' && 'length' in slides) { |
|
3211 |
+ for (var i = 0; i < slides.length; i += 1) { |
|
3212 |
+ if (slides[i]) $wrapperEl.prepend(slides[i]); |
|
3213 |
+ } |
|
3214 |
+ |
|
3215 |
+ newActiveIndex = activeIndex + slides.length; |
|
3216 |
+ } else { |
|
3217 |
+ $wrapperEl.prepend(slides); |
|
3218 |
+ } |
|
3219 |
+ |
|
3220 |
+ if (params.loop) { |
|
3221 |
+ swiper.loopCreate(); |
|
3222 |
+ } |
|
3223 |
+ |
|
3224 |
+ if (!(params.observer && swiper.support.observer)) { |
|
3225 |
+ swiper.update(); |
|
3226 |
+ } |
|
3227 |
+ |
|
3228 |
+ swiper.slideTo(newActiveIndex, 0, false); |
|
3229 |
+} |
|
3230 |
+ |
|
3231 |
+function addSlide(index, slides) { |
|
3232 |
+ var swiper = this; |
|
3233 |
+ var $wrapperEl = swiper.$wrapperEl, |
|
3234 |
+ params = swiper.params, |
|
3235 |
+ activeIndex = swiper.activeIndex; |
|
3236 |
+ var activeIndexBuffer = activeIndex; |
|
3237 |
+ |
|
3238 |
+ if (params.loop) { |
|
3239 |
+ activeIndexBuffer -= swiper.loopedSlides; |
|
3240 |
+ swiper.loopDestroy(); |
|
3241 |
+ swiper.slides = $wrapperEl.children("." + params.slideClass); |
|
3242 |
+ } |
|
3243 |
+ |
|
3244 |
+ var baseLength = swiper.slides.length; |
|
3245 |
+ |
|
3246 |
+ if (index <= 0) { |
|
3247 |
+ swiper.prependSlide(slides); |
|
3248 |
+ return; |
|
3249 |
+ } |
|
3250 |
+ |
|
3251 |
+ if (index >= baseLength) { |
|
3252 |
+ swiper.appendSlide(slides); |
|
3253 |
+ return; |
|
3254 |
+ } |
|
3255 |
+ |
|
3256 |
+ var newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer; |
|
3257 |
+ var slidesBuffer = []; |
|
3258 |
+ |
|
3259 |
+ for (var i = baseLength - 1; i >= index; i -= 1) { |
|
3260 |
+ var currentSlide = swiper.slides.eq(i); |
|
3261 |
+ currentSlide.remove(); |
|
3262 |
+ slidesBuffer.unshift(currentSlide); |
|
3263 |
+ } |
|
3264 |
+ |
|
3265 |
+ if (typeof slides === 'object' && 'length' in slides) { |
|
3266 |
+ for (var _i = 0; _i < slides.length; _i += 1) { |
|
3267 |
+ if (slides[_i]) $wrapperEl.append(slides[_i]); |
|
3268 |
+ } |
|
3269 |
+ |
|
3270 |
+ newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer; |
|
3271 |
+ } else { |
|
3272 |
+ $wrapperEl.append(slides); |
|
3273 |
+ } |
|
3274 |
+ |
|
3275 |
+ for (var _i2 = 0; _i2 < slidesBuffer.length; _i2 += 1) { |
|
3276 |
+ $wrapperEl.append(slidesBuffer[_i2]); |
|
3277 |
+ } |
|
3278 |
+ |
|
3279 |
+ if (params.loop) { |
|
3280 |
+ swiper.loopCreate(); |
|
3281 |
+ } |
|
3282 |
+ |
|
3283 |
+ if (!(params.observer && swiper.support.observer)) { |
|
3284 |
+ swiper.update(); |
|
3285 |
+ } |
|
3286 |
+ |
|
3287 |
+ if (params.loop) { |
|
3288 |
+ swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false); |
|
3289 |
+ } else { |
|
3290 |
+ swiper.slideTo(newActiveIndex, 0, false); |
|
3291 |
+ } |
|
3292 |
+} |
|
3293 |
+ |
|
3294 |
+function removeSlide(slidesIndexes) { |
|
3295 |
+ var swiper = this; |
|
3296 |
+ var params = swiper.params, |
|
3297 |
+ $wrapperEl = swiper.$wrapperEl, |
|
3298 |
+ activeIndex = swiper.activeIndex; |
|
3299 |
+ var activeIndexBuffer = activeIndex; |
|
3300 |
+ |
|
3301 |
+ if (params.loop) { |
|
3302 |
+ activeIndexBuffer -= swiper.loopedSlides; |
|
3303 |
+ swiper.loopDestroy(); |
|
3304 |
+ swiper.slides = $wrapperEl.children("." + params.slideClass); |
|
3305 |
+ } |
|
3306 |
+ |
|
3307 |
+ var newActiveIndex = activeIndexBuffer; |
|
3308 |
+ var indexToRemove; |
|
3309 |
+ |
|
3310 |
+ if (typeof slidesIndexes === 'object' && 'length' in slidesIndexes) { |
|
3311 |
+ for (var i = 0; i < slidesIndexes.length; i += 1) { |
|
3312 |
+ indexToRemove = slidesIndexes[i]; |
|
3313 |
+ if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove(); |
|
3314 |
+ if (indexToRemove < newActiveIndex) newActiveIndex -= 1; |
|
3315 |
+ } |
|
3316 |
+ |
|
3317 |
+ newActiveIndex = Math.max(newActiveIndex, 0); |
|
3318 |
+ } else { |
|
3319 |
+ indexToRemove = slidesIndexes; |
|
3320 |
+ if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove(); |
|
3321 |
+ if (indexToRemove < newActiveIndex) newActiveIndex -= 1; |
|
3322 |
+ newActiveIndex = Math.max(newActiveIndex, 0); |
|
3323 |
+ } |
|
3324 |
+ |
|
3325 |
+ if (params.loop) { |
|
3326 |
+ swiper.loopCreate(); |
|
3327 |
+ } |
|
3328 |
+ |
|
3329 |
+ if (!(params.observer && swiper.support.observer)) { |
|
3330 |
+ swiper.update(); |
|
3331 |
+ } |
|
3332 |
+ |
|
3333 |
+ if (params.loop) { |
|
3334 |
+ swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false); |
|
3335 |
+ } else { |
|
3336 |
+ swiper.slideTo(newActiveIndex, 0, false); |
|
3337 |
+ } |
|
3338 |
+} |
|
3339 |
+ |
|
3340 |
+function removeAllSlides() { |
|
3341 |
+ var swiper = this; |
|
3342 |
+ var slidesIndexes = []; |
|
3343 |
+ |
|
3344 |
+ for (var i = 0; i < swiper.slides.length; i += 1) { |
|
3345 |
+ slidesIndexes.push(i); |
|
3346 |
+ } |
|
3347 |
+ |
|
3348 |
+ swiper.removeSlide(slidesIndexes); |
|
3349 |
+} |
|
3350 |
+ |
|
3351 |
+var manipulation = { |
|
3352 |
+ appendSlide: appendSlide, |
|
3353 |
+ prependSlide: prependSlide, |
|
3354 |
+ addSlide: addSlide, |
|
3355 |
+ removeSlide: removeSlide, |
|
3356 |
+ removeAllSlides: removeAllSlides |
|
3357 |
+}; |
|
3358 |
+ |
|
3359 |
+function onTouchStart(event) { |
|
3360 |
+ var swiper = this; |
|
3361 |
+ var document = getDocument(); |
|
3362 |
+ var window = getWindow(); |
|
3363 |
+ var data = swiper.touchEventsData; |
|
3364 |
+ var params = swiper.params, |
|
3365 |
+ touches = swiper.touches; |
|
3366 |
+ |
|
3367 |
+ if (swiper.animating && params.preventInteractionOnTransition) { |
|
3368 |
+ return; |
|
3369 |
+ } |
|
3370 |
+ |
|
3371 |
+ var e = event; |
|
3372 |
+ if (e.originalEvent) e = e.originalEvent; |
|
3373 |
+ var $targetEl = $(e.target); |
|
3374 |
+ |
|
3375 |
+ if (params.touchEventsTarget === 'wrapper') { |
|
3376 |
+ if (!$targetEl.closest(swiper.wrapperEl).length) return; |
|
3377 |
+ } |
|
3378 |
+ |
|
3379 |
+ data.isTouchEvent = e.type === 'touchstart'; |
|
3380 |
+ if (!data.isTouchEvent && 'which' in e && e.which === 3) return; |
|
3381 |
+ if (!data.isTouchEvent && 'button' in e && e.button > 0) return; |
|
3382 |
+ if (data.isTouched && data.isMoved) return; |
|
3383 |
+ |
|
3384 |
+ if (params.noSwiping && $targetEl.closest(params.noSwipingSelector ? params.noSwipingSelector : "." + params.noSwipingClass)[0]) { |
|
3385 |
+ swiper.allowClick = true; |
|
3386 |
+ return; |
|
3387 |
+ } |
|
3388 |
+ |
|
3389 |
+ if (params.swipeHandler) { |
|
3390 |
+ if (!$targetEl.closest(params.swipeHandler)[0]) return; |
|
3391 |
+ } |
|
3392 |
+ |
|
3393 |
+ touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; |
|
3394 |
+ touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; |
|
3395 |
+ var startX = touches.currentX; |
|
3396 |
+ var startY = touches.currentY; // Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore |
|
3397 |
+ |
|
3398 |
+ var edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection; |
|
3399 |
+ var edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold; |
|
3400 |
+ |
|
3401 |
+ if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.screen.width - edgeSwipeThreshold)) { |
|
3402 |
+ return; |
|
3403 |
+ } |
|
3404 |
+ |
|
3405 |
+ extend$1(data, { |
|
3406 |
+ isTouched: true, |
|
3407 |
+ isMoved: false, |
|
3408 |
+ allowTouchCallbacks: true, |
|
3409 |
+ isScrolling: undefined, |
|
3410 |
+ startMoving: undefined |
|
3411 |
+ }); |
|
3412 |
+ touches.startX = startX; |
|
3413 |
+ touches.startY = startY; |
|
3414 |
+ data.touchStartTime = now(); |
|
3415 |
+ swiper.allowClick = true; |
|
3416 |
+ swiper.updateSize(); |
|
3417 |
+ swiper.swipeDirection = undefined; |
|
3418 |
+ if (params.threshold > 0) data.allowThresholdMove = false; |
|
3419 |
+ |
|
3420 |
+ if (e.type !== 'touchstart') { |
|
3421 |
+ var preventDefault = true; |
|
3422 |
+ if ($targetEl.is(data.formElements)) preventDefault = false; |
|
3423 |
+ |
|
3424 |
+ if (document.activeElement && $(document.activeElement).is(data.formElements) && document.activeElement !== $targetEl[0]) { |
|
3425 |
+ document.activeElement.blur(); |
|
3426 |
+ } |
|
3427 |
+ |
|
3428 |
+ var shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault; |
|
3429 |
+ |
|
3430 |
+ if (params.touchStartForcePreventDefault || shouldPreventDefault) { |
|
3431 |
+ e.preventDefault(); |
|
3432 |
+ } |
|
3433 |
+ } |
|
3434 |
+ |
|
3435 |
+ swiper.emit('touchStart', e); |
|
3436 |
+} |
|
3437 |
+ |
|
3438 |
+function onTouchMove(event) { |
|
3439 |
+ var document = getDocument(); |
|
3440 |
+ var swiper = this; |
|
3441 |
+ var data = swiper.touchEventsData; |
|
3442 |
+ var params = swiper.params, |
|
3443 |
+ touches = swiper.touches, |
|
3444 |
+ rtl = swiper.rtlTranslate; |
|
3445 |
+ var e = event; |
|
3446 |
+ if (e.originalEvent) e = e.originalEvent; |
|
3447 |
+ |
|
3448 |
+ if (!data.isTouched) { |
|
3449 |
+ if (data.startMoving && data.isScrolling) { |
|
3450 |
+ swiper.emit('touchMoveOpposite', e); |
|
3451 |
+ } |
|
3452 |
+ |
|
3453 |
+ return; |
|
3454 |
+ } |
|
3455 |
+ |
|
3456 |
+ if (data.isTouchEvent && e.type !== 'touchmove') return; |
|
3457 |
+ var targetTouch = e.type === 'touchmove' && e.targetTouches && (e.targetTouches[0] || e.changedTouches[0]); |
|
3458 |
+ var pageX = e.type === 'touchmove' ? targetTouch.pageX : e.pageX; |
|
3459 |
+ var pageY = e.type === 'touchmove' ? targetTouch.pageY : e.pageY; |
|
3460 |
+ |
|
3461 |
+ if (e.preventedByNestedSwiper) { |
|
3462 |
+ touches.startX = pageX; |
|
3463 |
+ touches.startY = pageY; |
|
3464 |
+ return; |
|
3465 |
+ } |
|
3466 |
+ |
|
3467 |
+ if (!swiper.allowTouchMove) { |
|
3468 |
+ // isMoved = true; |
|
3469 |
+ swiper.allowClick = false; |
|
3470 |
+ |
|
3471 |
+ if (data.isTouched) { |
|
3472 |
+ extend$1(touches, { |
|
3473 |
+ startX: pageX, |
|
3474 |
+ startY: pageY, |
|
3475 |
+ currentX: pageX, |
|
3476 |
+ currentY: pageY |
|
3477 |
+ }); |
|
3478 |
+ data.touchStartTime = now(); |
|
3479 |
+ } |
|
3480 |
+ |
|
3481 |
+ return; |
|
3482 |
+ } |
|
3483 |
+ |
|
3484 |
+ if (data.isTouchEvent && params.touchReleaseOnEdges && !params.loop) { |
|
3485 |
+ if (swiper.isVertical()) { |
|
3486 |
+ // Vertical |
|
3487 |
+ if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) { |
|
3488 |
+ data.isTouched = false; |
|
3489 |
+ data.isMoved = false; |
|
3490 |
+ return; |
|
3491 |
+ } |
|
3492 |
+ } else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate()) { |
|
3493 |
+ return; |
|
3494 |
+ } |
|
3495 |
+ } |
|
3496 |
+ |
|
3497 |
+ if (data.isTouchEvent && document.activeElement) { |
|
3498 |
+ if (e.target === document.activeElement && $(e.target).is(data.formElements)) { |
|
3499 |
+ data.isMoved = true; |
|
3500 |
+ swiper.allowClick = false; |
|
3501 |
+ return; |
|
3502 |
+ } |
|
3503 |
+ } |
|
3504 |
+ |
|
3505 |
+ if (data.allowTouchCallbacks) { |
|
3506 |
+ swiper.emit('touchMove', e); |
|
3507 |
+ } |
|
3508 |
+ |
|
3509 |
+ if (e.targetTouches && e.targetTouches.length > 1) return; |
|
3510 |
+ touches.currentX = pageX; |
|
3511 |
+ touches.currentY = pageY; |
|
3512 |
+ var diffX = touches.currentX - touches.startX; |
|
3513 |
+ var diffY = touches.currentY - touches.startY; |
|
3514 |
+ if (swiper.params.threshold && Math.sqrt(Math.pow(diffX, 2) + Math.pow(diffY, 2)) < swiper.params.threshold) return; |
|
3515 |
+ |
|
3516 |
+ if (typeof data.isScrolling === 'undefined') { |
|
3517 |
+ var touchAngle; |
|
3518 |
+ |
|
3519 |
+ if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) { |
|
3520 |
+ data.isScrolling = false; |
|
3521 |
+ } else { |
|
3522 |
+ // eslint-disable-next-line |
|
3523 |
+ if (diffX * diffX + diffY * diffY >= 25) { |
|
3524 |
+ touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI; |
|
3525 |
+ data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle; |
|
3526 |
+ } |
|
3527 |
+ } |
|
3528 |
+ } |
|
3529 |
+ |
|
3530 |
+ if (data.isScrolling) { |
|
3531 |
+ swiper.emit('touchMoveOpposite', e); |
|
3532 |
+ } |
|
3533 |
+ |
|
3534 |
+ if (typeof data.startMoving === 'undefined') { |
|
3535 |
+ if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) { |
|
3536 |
+ data.startMoving = true; |
|
3537 |
+ } |
|
3538 |
+ } |
|
3539 |
+ |
|
3540 |
+ if (data.isScrolling) { |
|
3541 |
+ data.isTouched = false; |
|
3542 |
+ return; |
|
3543 |
+ } |
|
3544 |
+ |
|
3545 |
+ if (!data.startMoving) { |
|
3546 |
+ return; |
|
3547 |
+ } |
|
3548 |
+ |
|
3549 |
+ swiper.allowClick = false; |
|
3550 |
+ |
|
3551 |
+ if (!params.cssMode && e.cancelable) { |
|
3552 |
+ e.preventDefault(); |
|
3553 |
+ } |
|
3554 |
+ |
|
3555 |
+ if (params.touchMoveStopPropagation && !params.nested) { |
|
3556 |
+ e.stopPropagation(); |
|
3557 |
+ } |
|
3558 |
+ |
|
3559 |
+ if (!data.isMoved) { |
|
3560 |
+ if (params.loop) { |
|
3561 |
+ swiper.loopFix(); |
|
3562 |
+ } |
|
3563 |
+ |
|
3564 |
+ data.startTranslate = swiper.getTranslate(); |
|
3565 |
+ swiper.setTransition(0); |
|
3566 |
+ |
|
3567 |
+ if (swiper.animating) { |
|
3568 |
+ swiper.$wrapperEl.trigger('webkitTransitionEnd transitionend'); |
|
3569 |
+ } |
|
3570 |
+ |
|
3571 |
+ data.allowMomentumBounce = false; // Grab Cursor |
|
3572 |
+ |
|
3573 |
+ if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { |
|
3574 |
+ swiper.setGrabCursor(true); |
|
3575 |
+ } |
|
3576 |
+ |
|
3577 |
+ swiper.emit('sliderFirstMove', e); |
|
3578 |
+ } |
|
3579 |
+ |
|
3580 |
+ swiper.emit('sliderMove', e); |
|
3581 |
+ data.isMoved = true; |
|
3582 |
+ var diff = swiper.isHorizontal() ? diffX : diffY; |
|
3583 |
+ touches.diff = diff; |
|
3584 |
+ diff *= params.touchRatio; |
|
3585 |
+ if (rtl) diff = -diff; |
|
3586 |
+ swiper.swipeDirection = diff > 0 ? 'prev' : 'next'; |
|
3587 |
+ data.currentTranslate = diff + data.startTranslate; |
|
3588 |
+ var disableParentSwiper = true; |
|
3589 |
+ var resistanceRatio = params.resistanceRatio; |
|
3590 |
+ |
|
3591 |
+ if (params.touchReleaseOnEdges) { |
|
3592 |
+ resistanceRatio = 0; |
|
3593 |
+ } |
|
3594 |
+ |
|
3595 |
+ if (diff > 0 && data.currentTranslate > swiper.minTranslate()) { |
|
3596 |
+ disableParentSwiper = false; |
|
3597 |
+ if (params.resistance) data.currentTranslate = swiper.minTranslate() - 1 + Math.pow(-swiper.minTranslate() + data.startTranslate + diff, resistanceRatio); |
|
3598 |
+ } else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) { |
|
3599 |
+ disableParentSwiper = false; |
|
3600 |
+ if (params.resistance) data.currentTranslate = swiper.maxTranslate() + 1 - Math.pow(swiper.maxTranslate() - data.startTranslate - diff, resistanceRatio); |
|
3601 |
+ } |
|
3602 |
+ |
|
3603 |
+ if (disableParentSwiper) { |
|
3604 |
+ e.preventedByNestedSwiper = true; |
|
3605 |
+ } // Directions locks |
|
3606 |
+ |
|
3607 |
+ |
|
3608 |
+ if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) { |
|
3609 |
+ data.currentTranslate = data.startTranslate; |
|
3610 |
+ } |
|
3611 |
+ |
|
3612 |
+ if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) { |
|
3613 |
+ data.currentTranslate = data.startTranslate; |
|
3614 |
+ } // Threshold |
|
3615 |
+ |
|
3616 |
+ |
|
3617 |
+ if (params.threshold > 0) { |
|
3618 |
+ if (Math.abs(diff) > params.threshold || data.allowThresholdMove) { |
|
3619 |
+ if (!data.allowThresholdMove) { |
|
3620 |
+ data.allowThresholdMove = true; |
|
3621 |
+ touches.startX = touches.currentX; |
|
3622 |
+ touches.startY = touches.currentY; |
|
3623 |
+ data.currentTranslate = data.startTranslate; |
|
3624 |
+ touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY; |
|
3625 |
+ return; |
|
3626 |
+ } |
|
3627 |
+ } else { |
|
3628 |
+ data.currentTranslate = data.startTranslate; |
|
3629 |
+ return; |
|
3630 |
+ } |
|
3631 |
+ } |
|
3632 |
+ |
|
3633 |
+ if (!params.followFinger || params.cssMode) return; // Update active index in free mode |
|
3634 |
+ |
|
3635 |
+ if (params.freeMode || params.watchSlidesProgress || params.watchSlidesVisibility) { |
|
3636 |
+ swiper.updateActiveIndex(); |
|
3637 |
+ swiper.updateSlidesClasses(); |
|
3638 |
+ } |
|
3639 |
+ |
|
3640 |
+ if (params.freeMode) { |
|
3641 |
+ // Velocity |
|
3642 |
+ if (data.velocities.length === 0) { |
|
3643 |
+ data.velocities.push({ |
|
3644 |
+ position: touches[swiper.isHorizontal() ? 'startX' : 'startY'], |
|
3645 |
+ time: data.touchStartTime |
|
3646 |
+ }); |
|
3647 |
+ } |
|
3648 |
+ |
|
3649 |
+ data.velocities.push({ |
|
3650 |
+ position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'], |
|
3651 |
+ time: now() |
|
3652 |
+ }); |
|
3653 |
+ } // Update progress |
|
3654 |
+ |
|
3655 |
+ |
|
3656 |
+ swiper.updateProgress(data.currentTranslate); // Update translate |
|
3657 |
+ |
|
3658 |
+ swiper.setTranslate(data.currentTranslate); |
|
3659 |
+} |
|
3660 |
+ |
|
3661 |
+function onTouchEnd(event) { |
|
3662 |
+ var swiper = this; |
|
3663 |
+ var data = swiper.touchEventsData; |
|
3664 |
+ var params = swiper.params, |
|
3665 |
+ touches = swiper.touches, |
|
3666 |
+ rtl = swiper.rtlTranslate, |
|
3667 |
+ $wrapperEl = swiper.$wrapperEl, |
|
3668 |
+ slidesGrid = swiper.slidesGrid, |
|
3669 |
+ snapGrid = swiper.snapGrid; |
|
3670 |
+ var e = event; |
|
3671 |
+ if (e.originalEvent) e = e.originalEvent; |
|
3672 |
+ |
|
3673 |
+ if (data.allowTouchCallbacks) { |
|
3674 |
+ swiper.emit('touchEnd', e); |
|
3675 |
+ } |
|
3676 |
+ |
|
3677 |
+ data.allowTouchCallbacks = false; |
|
3678 |
+ |
|
3679 |
+ if (!data.isTouched) { |
|
3680 |
+ if (data.isMoved && params.grabCursor) { |
|
3681 |
+ swiper.setGrabCursor(false); |
|
3682 |
+ } |
|
3683 |
+ |
|
3684 |
+ data.isMoved = false; |
|
3685 |
+ data.startMoving = false; |
|
3686 |
+ return; |
|
3687 |
+ } // Return Grab Cursor |
|
3688 |
+ |
|
3689 |
+ |
|
3690 |
+ if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { |
|
3691 |
+ swiper.setGrabCursor(false); |
|
3692 |
+ } // Time diff |
|
3693 |
+ |
|
3694 |
+ |
|
3695 |
+ var touchEndTime = now(); |
|
3696 |
+ var timeDiff = touchEndTime - data.touchStartTime; // Tap, doubleTap, Click |
|
3697 |
+ |
|
3698 |
+ if (swiper.allowClick) { |
|
3699 |
+ swiper.updateClickedSlide(e); |
|
3700 |
+ swiper.emit('tap click', e); |
|
3701 |
+ |
|
3702 |
+ if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) { |
|
3703 |
+ swiper.emit('doubleTap doubleClick', e); |
|
3704 |
+ } |
|
3705 |
+ } |
|
3706 |
+ |
|
3707 |
+ data.lastClickTime = now(); |
|
3708 |
+ nextTick(function () { |
|
3709 |
+ if (!swiper.destroyed) swiper.allowClick = true; |
|
3710 |
+ }); |
|
3711 |
+ |
|
3712 |
+ if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) { |
|
3713 |
+ data.isTouched = false; |
|
3714 |
+ data.isMoved = false; |
|
3715 |
+ data.startMoving = false; |
|
3716 |
+ return; |
|
3717 |
+ } |
|
3718 |
+ |
|
3719 |
+ data.isTouched = false; |
|
3720 |
+ data.isMoved = false; |
|
3721 |
+ data.startMoving = false; |
|
3722 |
+ var currentPos; |
|
3723 |
+ |
|
3724 |
+ if (params.followFinger) { |
|
3725 |
+ currentPos = rtl ? swiper.translate : -swiper.translate; |
|
3726 |
+ } else { |
|
3727 |
+ currentPos = -data.currentTranslate; |
|
3728 |
+ } |
|
3729 |
+ |
|
3730 |
+ if (params.cssMode) { |
|
3731 |
+ return; |
|
3732 |
+ } |
|
3733 |
+ |
|
3734 |
+ if (params.freeMode) { |
|
3735 |
+ if (currentPos < -swiper.minTranslate()) { |
|
3736 |
+ swiper.slideTo(swiper.activeIndex); |
|
3737 |
+ return; |
|
3738 |
+ } |
|
3739 |
+ |
|
3740 |
+ if (currentPos > -swiper.maxTranslate()) { |
|
3741 |
+ if (swiper.slides.length < snapGrid.length) { |
|
3742 |
+ swiper.slideTo(snapGrid.length - 1); |
|
3743 |
+ } else { |
|
3744 |
+ swiper.slideTo(swiper.slides.length - 1); |
|
3745 |
+ } |
|
3746 |
+ |
|
3747 |
+ return; |
|
3748 |
+ } |
|
3749 |
+ |
|
3750 |
+ if (params.freeModeMomentum) { |
|
3751 |
+ if (data.velocities.length > 1) { |
|
3752 |
+ var lastMoveEvent = data.velocities.pop(); |
|
3753 |
+ var velocityEvent = data.velocities.pop(); |
|
3754 |
+ var distance = lastMoveEvent.position - velocityEvent.position; |
|
3755 |
+ var time = lastMoveEvent.time - velocityEvent.time; |
|
3756 |
+ swiper.velocity = distance / time; |
|
3757 |
+ swiper.velocity /= 2; |
|
3758 |
+ |
|
3759 |
+ if (Math.abs(swiper.velocity) < params.freeModeMinimumVelocity) { |
|
3760 |
+ swiper.velocity = 0; |
|
3761 |
+ } // this implies that the user stopped moving a finger then released. |
|
3762 |
+ // There would be no events with distance zero, so the last event is stale. |
|
3763 |
+ |
|
3764 |
+ |
|
3765 |
+ if (time > 150 || now() - lastMoveEvent.time > 300) { |
|
3766 |
+ swiper.velocity = 0; |
|
3767 |
+ } |
|
3768 |
+ } else { |
|
3769 |
+ swiper.velocity = 0; |
|
3770 |
+ } |
|
3771 |
+ |
|
3772 |
+ swiper.velocity *= params.freeModeMomentumVelocityRatio; |
|
3773 |
+ data.velocities.length = 0; |
|
3774 |
+ var momentumDuration = 1000 * params.freeModeMomentumRatio; |
|
3775 |
+ var momentumDistance = swiper.velocity * momentumDuration; |
|
3776 |
+ var newPosition = swiper.translate + momentumDistance; |
|
3777 |
+ if (rtl) newPosition = -newPosition; |
|
3778 |
+ var doBounce = false; |
|
3779 |
+ var afterBouncePosition; |
|
3780 |
+ var bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeModeMomentumBounceRatio; |
|
3781 |
+ var needsLoopFix; |
|
3782 |
+ |
|
3783 |
+ if (newPosition < swiper.maxTranslate()) { |
|
3784 |
+ if (params.freeModeMomentumBounce) { |
|
3785 |
+ if (newPosition + swiper.maxTranslate() < -bounceAmount) { |
|
3786 |
+ newPosition = swiper.maxTranslate() - bounceAmount; |
|
3787 |
+ } |
|
3788 |
+ |
|
3789 |
+ afterBouncePosition = swiper.maxTranslate(); |
|
3790 |
+ doBounce = true; |
|
3791 |
+ data.allowMomentumBounce = true; |
|
3792 |
+ } else { |
|
3793 |
+ newPosition = swiper.maxTranslate(); |
|
3794 |
+ } |
|
3795 |
+ |
|
3796 |
+ if (params.loop && params.centeredSlides) needsLoopFix = true; |
|
3797 |
+ } else if (newPosition > swiper.minTranslate()) { |
|
3798 |
+ if (params.freeModeMomentumBounce) { |
|
3799 |
+ if (newPosition - swiper.minTranslate() > bounceAmount) { |
|
3800 |
+ newPosition = swiper.minTranslate() + bounceAmount; |
|
3801 |
+ } |
|
3802 |
+ |
|
3803 |
+ afterBouncePosition = swiper.minTranslate(); |
|
3804 |
+ doBounce = true; |
|
3805 |
+ data.allowMomentumBounce = true; |
|
3806 |
+ } else { |
|
3807 |
+ newPosition = swiper.minTranslate(); |
|
3808 |
+ } |
|
3809 |
+ |
|
3810 |
+ if (params.loop && params.centeredSlides) needsLoopFix = true; |
|
3811 |
+ } else if (params.freeModeSticky) { |
|
3812 |
+ var nextSlide; |
|
3813 |
+ |
|
3814 |
+ for (var j = 0; j < snapGrid.length; j += 1) { |
|
3815 |
+ if (snapGrid[j] > -newPosition) { |
|
3816 |
+ nextSlide = j; |
|
3817 |
+ break; |
|
3818 |
+ } |
|
3819 |
+ } |
|
3820 |
+ |
|
3821 |
+ if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') { |
|
3822 |
+ newPosition = snapGrid[nextSlide]; |
|
3823 |
+ } else { |
|
3824 |
+ newPosition = snapGrid[nextSlide - 1]; |
|
3825 |
+ } |
|
3826 |
+ |
|
3827 |
+ newPosition = -newPosition; |
|
3828 |
+ } |
|
3829 |
+ |
|
3830 |
+ if (needsLoopFix) { |
|
3831 |
+ swiper.once('transitionEnd', function () { |
|
3832 |
+ swiper.loopFix(); |
|
3833 |
+ }); |
|
3834 |
+ } // Fix duration |
|
3835 |
+ |
|
3836 |
+ |
|
3837 |
+ if (swiper.velocity !== 0) { |
|
3838 |
+ if (rtl) { |
|
3839 |
+ momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity); |
|
3840 |
+ } else { |
|
3841 |
+ momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity); |
|
3842 |
+ } |
|
3843 |
+ |
|
3844 |
+ if (params.freeModeSticky) { |
|
3845 |
+ // If freeModeSticky is active and the user ends a swipe with a slow-velocity |
|
3846 |
+ // event, then durations can be 20+ seconds to slide one (or zero!) slides. |
|
3847 |
+ // It's easy to see this when simulating touch with mouse events. To fix this, |
|
3848 |
+ // limit single-slide swipes to the default slide duration. This also has the |
|
3849 |
+ // nice side effect of matching slide speed if the user stopped moving before |
|
3850 |
+ // lifting finger or mouse vs. moving slowly before lifting the finger/mouse. |
|
3851 |
+ // For faster swipes, also apply limits (albeit higher ones). |
|
3852 |
+ var moveDistance = Math.abs((rtl ? -newPosition : newPosition) - swiper.translate); |
|
3853 |
+ var currentSlideSize = swiper.slidesSizesGrid[swiper.activeIndex]; |
|
3854 |
+ |
|
3855 |
+ if (moveDistance < currentSlideSize) { |
|
3856 |
+ momentumDuration = params.speed; |
|
3857 |
+ } else if (moveDistance < 2 * currentSlideSize) { |
|
3858 |
+ momentumDuration = params.speed * 1.5; |
|
3859 |
+ } else { |
|
3860 |
+ momentumDuration = params.speed * 2.5; |
|
3861 |
+ } |
|
3862 |
+ } |
|
3863 |
+ } else if (params.freeModeSticky) { |
|
3864 |
+ swiper.slideToClosest(); |
|
3865 |
+ return; |
|
3866 |
+ } |
|
3867 |
+ |
|
3868 |
+ if (params.freeModeMomentumBounce && doBounce) { |
|
3869 |
+ swiper.updateProgress(afterBouncePosition); |
|
3870 |
+ swiper.setTransition(momentumDuration); |
|
3871 |
+ swiper.setTranslate(newPosition); |
|
3872 |
+ swiper.transitionStart(true, swiper.swipeDirection); |
|
3873 |
+ swiper.animating = true; |
|
3874 |
+ $wrapperEl.transitionEnd(function () { |
|
3875 |
+ if (!swiper || swiper.destroyed || !data.allowMomentumBounce) return; |
|
3876 |
+ swiper.emit('momentumBounce'); |
|
3877 |
+ swiper.setTransition(params.speed); |
|
3878 |
+ setTimeout(function () { |
|
3879 |
+ swiper.setTranslate(afterBouncePosition); |
|
3880 |
+ $wrapperEl.transitionEnd(function () { |
|
3881 |
+ if (!swiper || swiper.destroyed) return; |
|
3882 |
+ swiper.transitionEnd(); |
|
3883 |
+ }); |
|
3884 |
+ }, 0); |
|
3885 |
+ }); |
|
3886 |
+ } else if (swiper.velocity) { |
|
3887 |
+ swiper.updateProgress(newPosition); |
|
3888 |
+ swiper.setTransition(momentumDuration); |
|
3889 |
+ swiper.setTranslate(newPosition); |
|
3890 |
+ swiper.transitionStart(true, swiper.swipeDirection); |
|
3891 |
+ |
|
3892 |
+ if (!swiper.animating) { |
|
3893 |
+ swiper.animating = true; |
|
3894 |
+ $wrapperEl.transitionEnd(function () { |
|
3895 |
+ if (!swiper || swiper.destroyed) return; |
|
3896 |
+ swiper.transitionEnd(); |
|
3897 |
+ }); |
|
3898 |
+ } |
|
3899 |
+ } else { |
|
3900 |
+ swiper.updateProgress(newPosition); |
|
3901 |
+ } |
|
3902 |
+ |
|
3903 |
+ swiper.updateActiveIndex(); |
|
3904 |
+ swiper.updateSlidesClasses(); |
|
3905 |
+ } else if (params.freeModeSticky) { |
|
3906 |
+ swiper.slideToClosest(); |
|
3907 |
+ return; |
|
3908 |
+ } |
|
3909 |
+ |
|
3910 |
+ if (!params.freeModeMomentum || timeDiff >= params.longSwipesMs) { |
|
3911 |
+ swiper.updateProgress(); |
|
3912 |
+ swiper.updateActiveIndex(); |
|
3913 |
+ swiper.updateSlidesClasses(); |
|
3914 |
+ } |
|
3915 |
+ |
|
3916 |
+ return; |
|
3917 |
+ } // Find current slide |
|
3918 |
+ |
|
3919 |
+ |
|
3920 |
+ var stopIndex = 0; |
|
3921 |
+ var groupSize = swiper.slidesSizesGrid[0]; |
|
3922 |
+ |
|
3923 |
+ for (var i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) { |
|
3924 |
+ var _increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup; |
|
3925 |
+ |
|
3926 |
+ if (typeof slidesGrid[i + _increment] !== 'undefined') { |
|
3927 |
+ if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + _increment]) { |
|
3928 |
+ stopIndex = i; |
|
3929 |
+ groupSize = slidesGrid[i + _increment] - slidesGrid[i]; |
|
3930 |
+ } |
|
3931 |
+ } else if (currentPos >= slidesGrid[i]) { |
|
3932 |
+ stopIndex = i; |
|
3933 |
+ groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2]; |
|
3934 |
+ } |
|
3935 |
+ } // Find current slide size |
|
3936 |
+ |
|
3937 |
+ |
|
3938 |
+ var ratio = (currentPos - slidesGrid[stopIndex]) / groupSize; |
|
3939 |
+ var increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup; |
|
3940 |
+ |
|
3941 |
+ if (timeDiff > params.longSwipesMs) { |
|
3942 |
+ // Long touches |
|
3943 |
+ if (!params.longSwipes) { |
|
3944 |
+ swiper.slideTo(swiper.activeIndex); |
|
3945 |
+ return; |
|
3946 |
+ } |
|
3947 |
+ |
|
3948 |
+ if (swiper.swipeDirection === 'next') { |
|
3949 |
+ if (ratio >= params.longSwipesRatio) swiper.slideTo(stopIndex + increment);else swiper.slideTo(stopIndex); |
|
3950 |
+ } |
|
3951 |
+ |
|
3952 |
+ if (swiper.swipeDirection === 'prev') { |
|
3953 |
+ if (ratio > 1 - params.longSwipesRatio) swiper.slideTo(stopIndex + increment);else swiper.slideTo(stopIndex); |
|
3954 |
+ } |
|
3955 |
+ } else { |
|
3956 |
+ // Short swipes |
|
3957 |
+ if (!params.shortSwipes) { |
|
3958 |
+ swiper.slideTo(swiper.activeIndex); |
|
3959 |
+ return; |
|
3960 |
+ } |
|
3961 |
+ |
|
3962 |
+ var isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl); |
|
3963 |
+ |
|
3964 |
+ if (!isNavButtonTarget) { |
|
3965 |
+ if (swiper.swipeDirection === 'next') { |
|
3966 |
+ swiper.slideTo(stopIndex + increment); |
|
3967 |
+ } |
|
3968 |
+ |
|
3969 |
+ if (swiper.swipeDirection === 'prev') { |
|
3970 |
+ swiper.slideTo(stopIndex); |
|
3971 |
+ } |
|
3972 |
+ } else if (e.target === swiper.navigation.nextEl) { |
|
3973 |
+ swiper.slideTo(stopIndex + increment); |
|
3974 |
+ } else { |
|
3975 |
+ swiper.slideTo(stopIndex); |
|
3976 |
+ } |
|
3977 |
+ } |
|
3978 |
+} |
|
3979 |
+ |
|
3980 |
+function onResize() { |
|
3981 |
+ var swiper = this; |
|
3982 |
+ var params = swiper.params, |
|
3983 |
+ el = swiper.el; |
|
3984 |
+ if (el && el.offsetWidth === 0) return; // Breakpoints |
|
3985 |
+ |
|
3986 |
+ if (params.breakpoints) { |
|
3987 |
+ swiper.setBreakpoint(); |
|
3988 |
+ } // Save locks |
|
3989 |
+ |
|
3990 |
+ |
|
3991 |
+ var allowSlideNext = swiper.allowSlideNext, |
|
3992 |
+ allowSlidePrev = swiper.allowSlidePrev, |
|
3993 |
+ snapGrid = swiper.snapGrid; // Disable locks on resize |
|
3994 |
+ |
|
3995 |
+ swiper.allowSlideNext = true; |
|
3996 |
+ swiper.allowSlidePrev = true; |
|
3997 |
+ swiper.updateSize(); |
|
3998 |
+ swiper.updateSlides(); |
|
3999 |
+ swiper.updateSlidesClasses(); |
|
4000 |
+ |
|
4001 |
+ if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) { |
|
4002 |
+ swiper.slideTo(swiper.slides.length - 1, 0, false, true); |
|
4003 |
+ } else { |
|
4004 |
+ swiper.slideTo(swiper.activeIndex, 0, false, true); |
|
4005 |
+ } |
|
4006 |
+ |
|
4007 |
+ if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) { |
|
4008 |
+ swiper.autoplay.run(); |
|
4009 |
+ } // Return locks after resize |
|
4010 |
+ |
|
4011 |
+ |
|
4012 |
+ swiper.allowSlidePrev = allowSlidePrev; |
|
4013 |
+ swiper.allowSlideNext = allowSlideNext; |
|
4014 |
+ |
|
4015 |
+ if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) { |
|
4016 |
+ swiper.checkOverflow(); |
|
4017 |
+ } |
|
4018 |
+} |
|
4019 |
+ |
|
4020 |
+function onClick(e) { |
|
4021 |
+ var swiper = this; |
|
4022 |
+ |
|
4023 |
+ if (!swiper.allowClick) { |
|
4024 |
+ if (swiper.params.preventClicks) e.preventDefault(); |
|
4025 |
+ |
|
4026 |
+ if (swiper.params.preventClicksPropagation && swiper.animating) { |
|
4027 |
+ e.stopPropagation(); |
|
4028 |
+ e.stopImmediatePropagation(); |
|
4029 |
+ } |
|
4030 |
+ } |
|
4031 |
+} |
|
4032 |
+ |
|
4033 |
+function onScroll() { |
|
4034 |
+ var swiper = this; |
|
4035 |
+ var wrapperEl = swiper.wrapperEl, |
|
4036 |
+ rtlTranslate = swiper.rtlTranslate; |
|
4037 |
+ swiper.previousTranslate = swiper.translate; |
|
4038 |
+ |
|
4039 |
+ if (swiper.isHorizontal()) { |
|
4040 |
+ if (rtlTranslate) { |
|
4041 |
+ swiper.translate = wrapperEl.scrollWidth - wrapperEl.offsetWidth - wrapperEl.scrollLeft; |
|
4042 |
+ } else { |
|
4043 |
+ swiper.translate = -wrapperEl.scrollLeft; |
|
4044 |
+ } |
|
4045 |
+ } else { |
|
4046 |
+ swiper.translate = -wrapperEl.scrollTop; |
|
4047 |
+ } // eslint-disable-next-line |
|
4048 |
+ |
|
4049 |
+ |
|
4050 |
+ if (swiper.translate === -0) swiper.translate = 0; |
|
4051 |
+ swiper.updateActiveIndex(); |
|
4052 |
+ swiper.updateSlidesClasses(); |
|
4053 |
+ var newProgress; |
|
4054 |
+ var translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); |
|
4055 |
+ |
|
4056 |
+ if (translatesDiff === 0) { |
|
4057 |
+ newProgress = 0; |
|
4058 |
+ } else { |
|
4059 |
+ newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff; |
|
4060 |
+ } |
|
4061 |
+ |
|
4062 |
+ if (newProgress !== swiper.progress) { |
|
4063 |
+ swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate); |
|
4064 |
+ } |
|
4065 |
+ |
|
4066 |
+ swiper.emit('setTranslate', swiper.translate, false); |
|
4067 |
+} |
|
4068 |
+ |
|
4069 |
+var dummyEventAttached = false; |
|
4070 |
+ |
|
4071 |
+function dummyEventListener() {} |
|
4072 |
+ |
|
4073 |
+function attachEvents() { |
|
4074 |
+ var swiper = this; |
|
4075 |
+ var document = getDocument(); |
|
4076 |
+ var params = swiper.params, |
|
4077 |
+ touchEvents = swiper.touchEvents, |
|
4078 |
+ el = swiper.el, |
|
4079 |
+ wrapperEl = swiper.wrapperEl, |
|
4080 |
+ device = swiper.device, |
|
4081 |
+ support = swiper.support; |
|
4082 |
+ swiper.onTouchStart = onTouchStart.bind(swiper); |
|
4083 |
+ swiper.onTouchMove = onTouchMove.bind(swiper); |
|
4084 |
+ swiper.onTouchEnd = onTouchEnd.bind(swiper); |
|
4085 |
+ |
|
4086 |
+ if (params.cssMode) { |
|
4087 |
+ swiper.onScroll = onScroll.bind(swiper); |
|
4088 |
+ } |
|
4089 |
+ |
|
4090 |
+ swiper.onClick = onClick.bind(swiper); |
|
4091 |
+ var capture = !!params.nested; // Touch Events |
|
4092 |
+ |
|
4093 |
+ if (!support.touch && support.pointerEvents) { |
|
4094 |
+ el.addEventListener(touchEvents.start, swiper.onTouchStart, false); |
|
4095 |
+ document.addEventListener(touchEvents.move, swiper.onTouchMove, capture); |
|
4096 |
+ document.addEventListener(touchEvents.end, swiper.onTouchEnd, false); |
|
4097 |
+ } else { |
|
4098 |
+ if (support.touch) { |
|
4099 |
+ var passiveListener = touchEvents.start === 'touchstart' && support.passiveListener && params.passiveListeners ? { |
|
4100 |
+ passive: true, |
|
4101 |
+ capture: false |
|
4102 |
+ } : false; |
|
4103 |
+ el.addEventListener(touchEvents.start, swiper.onTouchStart, passiveListener); |
|
4104 |
+ el.addEventListener(touchEvents.move, swiper.onTouchMove, support.passiveListener ? { |
|
4105 |
+ passive: false, |
|
4106 |
+ capture: capture |
|
4107 |
+ } : capture); |
|
4108 |
+ el.addEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener); |
|
4109 |
+ |
|
4110 |
+ if (touchEvents.cancel) { |
|
4111 |
+ el.addEventListener(touchEvents.cancel, swiper.onTouchEnd, passiveListener); |
|
4112 |
+ } |
|
4113 |
+ |
|
4114 |
+ if (!dummyEventAttached) { |
|
4115 |
+ document.addEventListener('touchstart', dummyEventListener); |
|
4116 |
+ dummyEventAttached = true; |
|
4117 |
+ } |
|
4118 |
+ } |
|
4119 |
+ |
|
4120 |
+ if (params.simulateTouch && !device.ios && !device.android || params.simulateTouch && !support.touch && device.ios) { |
|
4121 |
+ el.addEventListener('mousedown', swiper.onTouchStart, false); |
|
4122 |
+ document.addEventListener('mousemove', swiper.onTouchMove, capture); |
|
4123 |
+ document.addEventListener('mouseup', swiper.onTouchEnd, false); |
|
4124 |
+ } |
|
4125 |
+ } // Prevent Links Clicks |
|
4126 |
+ |
|
4127 |
+ |
|
4128 |
+ if (params.preventClicks || params.preventClicksPropagation) { |
|
4129 |
+ el.addEventListener('click', swiper.onClick, true); |
|
4130 |
+ } |
|
4131 |
+ |
|
4132 |
+ if (params.cssMode) { |
|
4133 |
+ wrapperEl.addEventListener('scroll', swiper.onScroll); |
|
4134 |
+ } // Resize handler |
|
4135 |
+ |
|
4136 |
+ |
|
4137 |
+ if (params.updateOnWindowResize) { |
|
4138 |
+ swiper.on(device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true); |
|
4139 |
+ } else { |
|
4140 |
+ swiper.on('observerUpdate', onResize, true); |
|
4141 |
+ } |
|
4142 |
+} |
|
4143 |
+ |
|
4144 |
+function detachEvents() { |
|
4145 |
+ var swiper = this; |
|
4146 |
+ var document = getDocument(); |
|
4147 |
+ var params = swiper.params, |
|
4148 |
+ touchEvents = swiper.touchEvents, |
|
4149 |
+ el = swiper.el, |
|
4150 |
+ wrapperEl = swiper.wrapperEl, |
|
4151 |
+ device = swiper.device, |
|
4152 |
+ support = swiper.support; |
|
4153 |
+ var capture = !!params.nested; // Touch Events |
|
4154 |
+ |
|
4155 |
+ if (!support.touch && support.pointerEvents) { |
|
4156 |
+ el.removeEventListener(touchEvents.start, swiper.onTouchStart, false); |
|
4157 |
+ document.removeEventListener(touchEvents.move, swiper.onTouchMove, capture); |
|
4158 |
+ document.removeEventListener(touchEvents.end, swiper.onTouchEnd, false); |
|
4159 |
+ } else { |
|
4160 |
+ if (support.touch) { |
|
4161 |
+ var passiveListener = touchEvents.start === 'onTouchStart' && support.passiveListener && params.passiveListeners ? { |
|
4162 |
+ passive: true, |
|
4163 |
+ capture: false |
|
4164 |
+ } : false; |
|
4165 |
+ el.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener); |
|
4166 |
+ el.removeEventListener(touchEvents.move, swiper.onTouchMove, capture); |
|
4167 |
+ el.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener); |
|
4168 |
+ |
|
4169 |
+ if (touchEvents.cancel) { |
|
4170 |
+ el.removeEventListener(touchEvents.cancel, swiper.onTouchEnd, passiveListener); |
|
4171 |
+ } |
|
4172 |
+ } |
|
4173 |
+ |
|
4174 |
+ if (params.simulateTouch && !device.ios && !device.android || params.simulateTouch && !support.touch && device.ios) { |
|
4175 |
+ el.removeEventListener('mousedown', swiper.onTouchStart, false); |
|
4176 |
+ document.removeEventListener('mousemove', swiper.onTouchMove, capture); |
|
4177 |
+ document.removeEventListener('mouseup', swiper.onTouchEnd, false); |
|
4178 |
+ } |
|
4179 |
+ } // Prevent Links Clicks |
|
4180 |
+ |
|
4181 |
+ |
|
4182 |
+ if (params.preventClicks || params.preventClicksPropagation) { |
|
4183 |
+ el.removeEventListener('click', swiper.onClick, true); |
|
4184 |
+ } |
|
4185 |
+ |
|
4186 |
+ if (params.cssMode) { |
|
4187 |
+ wrapperEl.removeEventListener('scroll', swiper.onScroll); |
|
4188 |
+ } // Resize handler |
|
4189 |
+ |
|
4190 |
+ |
|
4191 |
+ swiper.off(device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize); |
|
4192 |
+} |
|
4193 |
+ |
|
4194 |
+var events = { |
|
4195 |
+ attachEvents: attachEvents, |
|
4196 |
+ detachEvents: detachEvents |
|
4197 |
+}; |
|
4198 |
+ |
|
4199 |
+function setBreakpoint() { |
|
4200 |
+ var swiper = this; |
|
4201 |
+ var activeIndex = swiper.activeIndex, |
|
4202 |
+ initialized = swiper.initialized, |
|
4203 |
+ _swiper$loopedSlides = swiper.loopedSlides, |
|
4204 |
+ loopedSlides = _swiper$loopedSlides === void 0 ? 0 : _swiper$loopedSlides, |
|
4205 |
+ params = swiper.params, |
|
4206 |
+ $el = swiper.$el; |
|
4207 |
+ var breakpoints = params.breakpoints; |
|
4208 |
+ if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return; // Get breakpoint for window width and update parameters |
|
4209 |
+ |
|
4210 |
+ var breakpoint = swiper.getBreakpoint(breakpoints); |
|
4211 |
+ |
|
4212 |
+ if (breakpoint && swiper.currentBreakpoint !== breakpoint) { |
|
4213 |
+ var breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined; |
|
4214 |
+ |
|
4215 |
+ if (breakpointOnlyParams) { |
|
4216 |
+ ['slidesPerView', 'spaceBetween', 'slidesPerGroup', 'slidesPerGroupSkip', 'slidesPerColumn'].forEach(function (param) { |
|
4217 |
+ var paramValue = breakpointOnlyParams[param]; |
|
4218 |
+ if (typeof paramValue === 'undefined') return; |
|
4219 |
+ |
|
4220 |
+ if (param === 'slidesPerView' && (paramValue === 'AUTO' || paramValue === 'auto')) { |
|
4221 |
+ breakpointOnlyParams[param] = 'auto'; |
|
4222 |
+ } else if (param === 'slidesPerView') { |
|
4223 |
+ breakpointOnlyParams[param] = parseFloat(paramValue); |
|
4224 |
+ } else { |
|
4225 |
+ breakpointOnlyParams[param] = parseInt(paramValue, 10); |
|
4226 |
+ } |
|
4227 |
+ }); |
|
4228 |
+ } |
|
4229 |
+ |
|
4230 |
+ var breakpointParams = breakpointOnlyParams || swiper.originalParams; |
|
4231 |
+ var wasMultiRow = params.slidesPerColumn > 1; |
|
4232 |
+ var isMultiRow = breakpointParams.slidesPerColumn > 1; |
|
4233 |
+ |
|
4234 |
+ if (wasMultiRow && !isMultiRow) { |
|
4235 |
+ $el.removeClass(params.containerModifierClass + "multirow " + params.containerModifierClass + "multirow-column"); |
|
4236 |
+ swiper.emitContainerClasses(); |
|
4237 |
+ } else if (!wasMultiRow && isMultiRow) { |
|
4238 |
+ $el.addClass(params.containerModifierClass + "multirow"); |
|
4239 |
+ |
|
4240 |
+ if (breakpointParams.slidesPerColumnFill === 'column') { |
|
4241 |
+ $el.addClass(params.containerModifierClass + "multirow-column"); |
|
4242 |
+ } |
|
4243 |
+ |
|
4244 |
+ swiper.emitContainerClasses(); |
|
4245 |
+ } |
|
4246 |
+ |
|
4247 |
+ var directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction; |
|
4248 |
+ var needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged); |
|
4249 |
+ |
|
4250 |
+ if (directionChanged && initialized) { |
|
4251 |
+ swiper.changeDirection(); |
|
4252 |
+ } |
|
4253 |
+ |
|
4254 |
+ extend$1(swiper.params, breakpointParams); |
|
4255 |
+ extend$1(swiper, { |
|
4256 |
+ allowTouchMove: swiper.params.allowTouchMove, |
|
4257 |
+ allowSlideNext: swiper.params.allowSlideNext, |
|
4258 |
+ allowSlidePrev: swiper.params.allowSlidePrev |
|
4259 |
+ }); |
|
4260 |
+ swiper.currentBreakpoint = breakpoint; |
|
4261 |
+ swiper.emit('_beforeBreakpoint', breakpointParams); |
|
4262 |
+ |
|
4263 |
+ if (needsReLoop && initialized) { |
|
4264 |
+ swiper.loopDestroy(); |
|
4265 |
+ swiper.loopCreate(); |
|
4266 |
+ swiper.updateSlides(); |
|
4267 |
+ swiper.slideTo(activeIndex - loopedSlides + swiper.loopedSlides, 0, false); |
|
4268 |
+ } |
|
4269 |
+ |
|
4270 |
+ swiper.emit('breakpoint', breakpointParams); |
|
4271 |
+ } |
|
4272 |
+} |
|
4273 |
+ |
|
4274 |
+function getBreakpoints(breakpoints) { |
|
4275 |
+ var window = getWindow(); // Get breakpoint for window width |
|
4276 |
+ |
|
4277 |
+ if (!breakpoints) return undefined; |
|
4278 |
+ var breakpoint = false; |
|
4279 |
+ var points = Object.keys(breakpoints).map(function (point) { |
|
4280 |
+ if (typeof point === 'string' && point.indexOf('@') === 0) { |
|
4281 |
+ var minRatio = parseFloat(point.substr(1)); |
|
4282 |
+ var value = window.innerHeight * minRatio; |
|
4283 |
+ return { |
|
4284 |
+ value: value, |
|
4285 |
+ point: point |
|
4286 |
+ }; |
|
4287 |
+ } |
|
4288 |
+ |
|
4289 |
+ return { |
|
4290 |
+ value: point, |
|
4291 |
+ point: point |
|
4292 |
+ }; |
|
4293 |
+ }); |
|
4294 |
+ points.sort(function (a, b) { |
|
4295 |
+ return parseInt(a.value, 10) - parseInt(b.value, 10); |
|
4296 |
+ }); |
|
4297 |
+ |
|
4298 |
+ for (var i = 0; i < points.length; i += 1) { |
|
4299 |
+ var _points$i = points[i], |
|
4300 |
+ point = _points$i.point, |
|
4301 |
+ value = _points$i.value; |
|
4302 |
+ |
|
4303 |
+ if (value <= window.innerWidth) { |
|
4304 |
+ breakpoint = point; |
|
4305 |
+ } |
|
4306 |
+ } |
|
4307 |
+ |
|
4308 |
+ return breakpoint || 'max'; |
|
4309 |
+} |
|
4310 |
+ |
|
4311 |
+var breakpoints = { |
|
4312 |
+ setBreakpoint: setBreakpoint, |
|
4313 |
+ getBreakpoint: getBreakpoints |
|
4314 |
+}; |
|
4315 |
+ |
|
4316 |
+function addClasses() { |
|
4317 |
+ var swiper = this; |
|
4318 |
+ var classNames = swiper.classNames, |
|
4319 |
+ params = swiper.params, |
|
4320 |
+ rtl = swiper.rtl, |
|
4321 |
+ $el = swiper.$el, |
|
4322 |
+ device = swiper.device; |
|
4323 |
+ var suffixes = []; |
|
4324 |
+ suffixes.push('initialized'); |
|
4325 |
+ suffixes.push(params.direction); |
|
4326 |
+ |
|
4327 |
+ if (params.freeMode) { |
|
4328 |
+ suffixes.push('free-mode'); |
|
4329 |
+ } |
|
4330 |
+ |
|
4331 |
+ if (params.autoHeight) { |
|
4332 |
+ suffixes.push('autoheight'); |
|
4333 |
+ } |
|
4334 |
+ |
|
4335 |
+ if (rtl) { |
|
4336 |
+ suffixes.push('rtl'); |
|
4337 |
+ } |
|
4338 |
+ |
|
4339 |
+ if (params.slidesPerColumn > 1) { |
|
4340 |
+ suffixes.push('multirow'); |
|
4341 |
+ |
|
4342 |
+ if (params.slidesPerColumnFill === 'column') { |
|
4343 |
+ suffixes.push('multirow-column'); |
|
4344 |
+ } |
|
4345 |
+ } |
|
4346 |
+ |
|
4347 |
+ if (device.android) { |
|
4348 |
+ suffixes.push('android'); |
|
4349 |
+ } |
|
4350 |
+ |
|
4351 |
+ if (device.ios) { |
|
4352 |
+ suffixes.push('ios'); |
|
4353 |
+ } |
|
4354 |
+ |
|
4355 |
+ if (params.cssMode) { |
|
4356 |
+ suffixes.push('css-mode'); |
|
4357 |
+ } |
|
4358 |
+ |
|
4359 |
+ suffixes.forEach(function (suffix) { |
|
4360 |
+ classNames.push(params.containerModifierClass + suffix); |
|
4361 |
+ }); |
|
4362 |
+ $el.addClass(classNames.join(' ')); |
|
4363 |
+ swiper.emitContainerClasses(); |
|
4364 |
+} |
|
4365 |
+ |
|
4366 |
+function removeClasses() { |
|
4367 |
+ var swiper = this; |
|
4368 |
+ var $el = swiper.$el, |
|
4369 |
+ classNames = swiper.classNames; |
|
4370 |
+ $el.removeClass(classNames.join(' ')); |
|
4371 |
+ swiper.emitContainerClasses(); |
|
4372 |
+} |
|
4373 |
+ |
|
4374 |
+var classes = { |
|
4375 |
+ addClasses: addClasses, |
|
4376 |
+ removeClasses: removeClasses |
|
4377 |
+}; |
|
4378 |
+ |
|
4379 |
+function loadImage(imageEl, src, srcset, sizes, checkForComplete, callback) { |
|
4380 |
+ var window = getWindow(); |
|
4381 |
+ var image; |
|
4382 |
+ |
|
4383 |
+ function onReady() { |
|
4384 |
+ if (callback) callback(); |
|
4385 |
+ } |
|
4386 |
+ |
|
4387 |
+ var isPicture = $(imageEl).parent('picture')[0]; |
|
4388 |
+ |
|
4389 |
+ if (!isPicture && (!imageEl.complete || !checkForComplete)) { |
|
4390 |
+ if (src) { |
|
4391 |
+ image = new window.Image(); |
|
4392 |
+ image.onload = onReady; |
|
4393 |
+ image.onerror = onReady; |
|
4394 |
+ |
|
4395 |
+ if (sizes) { |
|
4396 |
+ image.sizes = sizes; |
|
4397 |
+ } |
|
4398 |
+ |
|
4399 |
+ if (srcset) { |
|
4400 |
+ image.srcset = srcset; |
|
4401 |
+ } |
|
4402 |
+ |
|
4403 |
+ if (src) { |
|
4404 |
+ image.src = src; |
|
4405 |
+ } |
|
4406 |
+ } else { |
|
4407 |
+ onReady(); |
|
4408 |
+ } |
|
4409 |
+ } else { |
|
4410 |
+ // image already loaded... |
|
4411 |
+ onReady(); |
|
4412 |
+ } |
|
4413 |
+} |
|
4414 |
+ |
|
4415 |
+function preloadImages() { |
|
4416 |
+ var swiper = this; |
|
4417 |
+ swiper.imagesToLoad = swiper.$el.find('img'); |
|
4418 |
+ |
|
4419 |
+ function onReady() { |
|
4420 |
+ if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper.destroyed) return; |
|
4421 |
+ if (swiper.imagesLoaded !== undefined) swiper.imagesLoaded += 1; |
|
4422 |
+ |
|
4423 |
+ if (swiper.imagesLoaded === swiper.imagesToLoad.length) { |
|
4424 |
+ if (swiper.params.updateOnImagesReady) swiper.update(); |
|
4425 |
+ swiper.emit('imagesReady'); |
|
4426 |
+ } |
|
4427 |
+ } |
|
4428 |
+ |
|
4429 |
+ for (var i = 0; i < swiper.imagesToLoad.length; i += 1) { |
|
4430 |
+ var imageEl = swiper.imagesToLoad[i]; |
|
4431 |
+ swiper.loadImage(imageEl, imageEl.currentSrc || imageEl.getAttribute('src'), imageEl.srcset || imageEl.getAttribute('srcset'), imageEl.sizes || imageEl.getAttribute('sizes'), true, onReady); |
|
4432 |
+ } |
|
4433 |
+} |
|
4434 |
+ |
|
4435 |
+var images = { |
|
4436 |
+ loadImage: loadImage, |
|
4437 |
+ preloadImages: preloadImages |
|
4438 |
+}; |
|
4439 |
+ |
|
4440 |
+function checkOverflow() { |
|
4441 |
+ var swiper = this; |
|
4442 |
+ var params = swiper.params; |
|
4443 |
+ var wasLocked = swiper.isLocked; |
|
4444 |
+ var lastSlidePosition = swiper.slides.length > 0 && params.slidesOffsetBefore + params.spaceBetween * (swiper.slides.length - 1) + swiper.slides[0].offsetWidth * swiper.slides.length; |
|
4445 |
+ |
|
4446 |
+ if (params.slidesOffsetBefore && params.slidesOffsetAfter && lastSlidePosition) { |
|
4447 |
+ swiper.isLocked = lastSlidePosition <= swiper.size; |
|
4448 |
+ } else { |
|
4449 |
+ swiper.isLocked = swiper.snapGrid.length === 1; |
|
4450 |
+ } |
|
4451 |
+ |
|
4452 |
+ swiper.allowSlideNext = !swiper.isLocked; |
|
4453 |
+ swiper.allowSlidePrev = !swiper.isLocked; // events |
|
4454 |
+ |
|
4455 |
+ if (wasLocked !== swiper.isLocked) swiper.emit(swiper.isLocked ? 'lock' : 'unlock'); |
|
4456 |
+ |
|
4457 |
+ if (wasLocked && wasLocked !== swiper.isLocked) { |
|
4458 |
+ swiper.isEnd = false; |
|
4459 |
+ if (swiper.navigation) swiper.navigation.update(); |
|
4460 |
+ } |
|
4461 |
+} |
|
4462 |
+ |
|
4463 |
+var checkOverflow$1 = { |
|
4464 |
+ checkOverflow: checkOverflow |
|
4465 |
+}; |
|
4466 |
+ |
|
4467 |
+var defaults = { |
|
4468 |
+ init: true, |
|
4469 |
+ direction: 'horizontal', |
|
4470 |
+ touchEventsTarget: 'container', |
|
4471 |
+ initialSlide: 0, |
|
4472 |
+ speed: 300, |
|
4473 |
+ cssMode: false, |
|
4474 |
+ updateOnWindowResize: true, |
|
4475 |
+ nested: false, |
|
4476 |
+ // Overrides |
|
4477 |
+ width: null, |
|
4478 |
+ height: null, |
|
4479 |
+ // |
|
4480 |
+ preventInteractionOnTransition: false, |
|
4481 |
+ // ssr |
|
4482 |
+ userAgent: null, |
|
4483 |
+ url: null, |
|
4484 |
+ // To support iOS's swipe-to-go-back gesture (when being used in-app). |
|
4485 |
+ edgeSwipeDetection: false, |
|
4486 |
+ edgeSwipeThreshold: 20, |
|
4487 |
+ // Free mode |
|
4488 |
+ freeMode: false, |
|
4489 |
+ freeModeMomentum: true, |
|
4490 |
+ freeModeMomentumRatio: 1, |
|
4491 |
+ freeModeMomentumBounce: true, |
|
4492 |
+ freeModeMomentumBounceRatio: 1, |
|
4493 |
+ freeModeMomentumVelocityRatio: 1, |
|
4494 |
+ freeModeSticky: false, |
|
4495 |
+ freeModeMinimumVelocity: 0.02, |
|
4496 |
+ // Autoheight |
|
4497 |
+ autoHeight: false, |
|
4498 |
+ // Set wrapper width |
|
4499 |
+ setWrapperSize: false, |
|
4500 |
+ // Virtual Translate |
|
4501 |
+ virtualTranslate: false, |
|
4502 |
+ // Effects |
|
4503 |
+ effect: 'slide', |
|
4504 |
+ // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip' |
|
4505 |
+ // Breakpoints |
|
4506 |
+ breakpoints: undefined, |
|
4507 |
+ // Slides grid |
|
4508 |
+ spaceBetween: 0, |
|
4509 |
+ slidesPerView: 1, |
|
4510 |
+ slidesPerColumn: 1, |
|
4511 |
+ slidesPerColumnFill: 'column', |
|
4512 |
+ slidesPerGroup: 1, |
|
4513 |
+ slidesPerGroupSkip: 0, |
|
4514 |
+ centeredSlides: false, |
|
4515 |
+ centeredSlidesBounds: false, |
|
4516 |
+ slidesOffsetBefore: 0, |
|
4517 |
+ // in px |
|
4518 |
+ slidesOffsetAfter: 0, |
|
4519 |
+ // in px |
|
4520 |
+ normalizeSlideIndex: true, |
|
4521 |
+ centerInsufficientSlides: false, |
|
4522 |
+ // Disable swiper and hide navigation when container not overflow |
|
4523 |
+ watchOverflow: false, |
|
4524 |
+ // Round length |
|
4525 |
+ roundLengths: false, |
|
4526 |
+ // Touches |
|
4527 |
+ touchRatio: 1, |
|
4528 |
+ touchAngle: 45, |
|
4529 |
+ simulateTouch: true, |
|
4530 |
+ shortSwipes: true, |
|
4531 |
+ longSwipes: true, |
|
4532 |
+ longSwipesRatio: 0.5, |
|
4533 |
+ longSwipesMs: 300, |
|
4534 |
+ followFinger: true, |
|
4535 |
+ allowTouchMove: true, |
|
4536 |
+ threshold: 0, |
|
4537 |
+ touchMoveStopPropagation: false, |
|
4538 |
+ touchStartPreventDefault: true, |
|
4539 |
+ touchStartForcePreventDefault: false, |
|
4540 |
+ touchReleaseOnEdges: false, |
|
4541 |
+ // Unique Navigation Elements |
|
4542 |
+ uniqueNavElements: true, |
|
4543 |
+ // Resistance |
|
4544 |
+ resistance: true, |
|
4545 |
+ resistanceRatio: 0.85, |
|
4546 |
+ // Progress |
|
4547 |
+ watchSlidesProgress: false, |
|
4548 |
+ watchSlidesVisibility: false, |
|
4549 |
+ // Cursor |
|
4550 |
+ grabCursor: false, |
|
4551 |
+ // Clicks |
|
4552 |
+ preventClicks: true, |
|
4553 |
+ preventClicksPropagation: true, |
|
4554 |
+ slideToClickedSlide: false, |
|
4555 |
+ // Images |
|
4556 |
+ preloadImages: true, |
|
4557 |
+ updateOnImagesReady: true, |
|
4558 |
+ // loop |
|
4559 |
+ loop: false, |
|
4560 |
+ loopAdditionalSlides: 0, |
|
4561 |
+ loopedSlides: null, |
|
4562 |
+ loopFillGroupWithBlank: false, |
|
4563 |
+ loopPreventsSlide: true, |
|
4564 |
+ // Swiping/no swiping |
|
4565 |
+ allowSlidePrev: true, |
|
4566 |
+ allowSlideNext: true, |
|
4567 |
+ swipeHandler: null, |
|
4568 |
+ // '.swipe-handler', |
|
4569 |
+ noSwiping: true, |
|
4570 |
+ noSwipingClass: 'swiper-no-swiping', |
|
4571 |
+ noSwipingSelector: null, |
|
4572 |
+ // Passive Listeners |
|
4573 |
+ passiveListeners: true, |
|
4574 |
+ // NS |
|
4575 |
+ containerModifierClass: 'swiper-container-', |
|
4576 |
+ // NEW |
|
4577 |
+ slideClass: 'swiper-slide', |
|
4578 |
+ slideBlankClass: 'swiper-slide-invisible-blank', |
|
4579 |
+ slideActiveClass: 'swiper-slide-active', |
|
4580 |
+ slideDuplicateActiveClass: 'swiper-slide-duplicate-active', |
|
4581 |
+ slideVisibleClass: 'swiper-slide-visible', |
|
4582 |
+ slideDuplicateClass: 'swiper-slide-duplicate', |
|
4583 |
+ slideNextClass: 'swiper-slide-next', |
|
4584 |
+ slideDuplicateNextClass: 'swiper-slide-duplicate-next', |
|
4585 |
+ slidePrevClass: 'swiper-slide-prev', |
|
4586 |
+ slideDuplicatePrevClass: 'swiper-slide-duplicate-prev', |
|
4587 |
+ wrapperClass: 'swiper-wrapper', |
|
4588 |
+ // Callbacks |
|
4589 |
+ runCallbacksOnInit: true, |
|
4590 |
+ // Internals |
|
4591 |
+ _emitClasses: false |
|
4592 |
+}; |
|
4593 |
+ |
|
4594 |
+var prototypes = { |
|
4595 |
+ modular: modular, |
|
4596 |
+ eventsEmitter: eventsEmitter, |
|
4597 |
+ update: update, |
|
4598 |
+ translate: translate, |
|
4599 |
+ transition: transition$1, |
|
4600 |
+ slide: slide, |
|
4601 |
+ loop: loop, |
|
4602 |
+ grabCursor: grabCursor, |
|
4603 |
+ manipulation: manipulation, |
|
4604 |
+ events: events, |
|
4605 |
+ breakpoints: breakpoints, |
|
4606 |
+ checkOverflow: checkOverflow$1, |
|
4607 |
+ classes: classes, |
|
4608 |
+ images: images |
|
4609 |
+}; |
|
4610 |
+var extendedDefaults = {}; |
|
4611 |
+ |
|
4612 |
+var Swiper = /*#__PURE__*/function () { |
|
4613 |
+ function Swiper() { |
|
4614 |
+ var el; |
|
4615 |
+ var params; |
|
4616 |
+ |
|
4617 |
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
|
4618 |
+ args[_key] = arguments[_key]; |
|
4619 |
+ } |
|
4620 |
+ |
|
4621 |
+ if (args.length === 1 && args[0].constructor && args[0].constructor === Object) { |
|
4622 |
+ params = args[0]; |
|
4623 |
+ } else { |
|
4624 |
+ el = args[0]; |
|
4625 |
+ params = args[1]; |
|
4626 |
+ } |
|
4627 |
+ |
|
4628 |
+ if (!params) params = {}; |
|
4629 |
+ params = extend$1({}, params); |
|
4630 |
+ if (el && !params.el) params.el = el; // Swiper Instance |
|
4631 |
+ |
|
4632 |
+ var swiper = this; |
|
4633 |
+ swiper.support = getSupport(); |
|
4634 |
+ swiper.device = getDevice({ |
|
4635 |
+ userAgent: params.userAgent |
|
4636 |
+ }); |
|
4637 |
+ swiper.browser = getBrowser(); |
|
4638 |
+ swiper.eventsListeners = {}; |
|
4639 |
+ swiper.eventsAnyListeners = []; |
|
4640 |
+ |
|
4641 |
+ if (typeof swiper.modules === 'undefined') { |
|
4642 |
+ swiper.modules = {}; |
|
4643 |
+ } |
|
4644 |
+ |
|
4645 |
+ Object.keys(swiper.modules).forEach(function (moduleName) { |
|
4646 |
+ var module = swiper.modules[moduleName]; |
|
4647 |
+ |
|
4648 |
+ if (module.params) { |
|
4649 |
+ var moduleParamName = Object.keys(module.params)[0]; |
|
4650 |
+ var moduleParams = module.params[moduleParamName]; |
|
4651 |
+ if (typeof moduleParams !== 'object' || moduleParams === null) return; |
|
4652 |
+ if (!(moduleParamName in params && 'enabled' in moduleParams)) return; |
|
4653 |
+ |
|
4654 |
+ if (params[moduleParamName] === true) { |
|
4655 |
+ params[moduleParamName] = { |
|
4656 |
+ enabled: true |
|
4657 |
+ }; |
|
4658 |
+ } |
|
4659 |
+ |
|
4660 |
+ if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) { |
|
4661 |
+ params[moduleParamName].enabled = true; |
|
4662 |
+ } |
|
4663 |
+ |
|
4664 |
+ if (!params[moduleParamName]) params[moduleParamName] = { |
|
4665 |
+ enabled: false |
|
4666 |
+ }; |
|
4667 |
+ } |
|
4668 |
+ }); // Extend defaults with modules params |
|
4669 |
+ |
|
4670 |
+ var swiperParams = extend$1({}, defaults); |
|
4671 |
+ swiper.useParams(swiperParams); // Extend defaults with passed params |
|
4672 |
+ |
|
4673 |
+ swiper.params = extend$1({}, swiperParams, extendedDefaults, params); |
|
4674 |
+ swiper.originalParams = extend$1({}, swiper.params); |
|
4675 |
+ swiper.passedParams = extend$1({}, params); // add event listeners |
|
4676 |
+ |
|
4677 |
+ if (swiper.params && swiper.params.on) { |
|
4678 |
+ Object.keys(swiper.params.on).forEach(function (eventName) { |
|
4679 |
+ swiper.on(eventName, swiper.params.on[eventName]); |
|
4680 |
+ }); |
|
4681 |
+ } |
|
4682 |
+ |
|
4683 |
+ if (swiper.params && swiper.params.onAny) { |
|
4684 |
+ swiper.onAny(swiper.params.onAny); |
|
4685 |
+ } // Save Dom lib |
|
4686 |
+ |
|
4687 |
+ |
|
4688 |
+ swiper.$ = $; // Find el |
|
4689 |
+ |
|
4690 |
+ var $el = $(swiper.params.el); |
|
4691 |
+ el = $el[0]; |
|
4692 |
+ |
|
4693 |
+ if (!el) { |
|
4694 |
+ return undefined; |
|
4695 |
+ } |
|
4696 |
+ |
|
4697 |
+ if ($el.length > 1) { |
|
4698 |
+ var swipers = []; |
|
4699 |
+ $el.each(function (containerEl) { |
|
4700 |
+ var newParams = extend$1({}, params, { |
|
4701 |
+ el: containerEl |
|
4702 |
+ }); |
|
4703 |
+ swipers.push(new Swiper(newParams)); |
|
4704 |
+ }); |
|
4705 |
+ return swipers; |
|
4706 |
+ } |
|
4707 |
+ |
|
4708 |
+ el.swiper = swiper; // Find Wrapper |
|
4709 |
+ |
|
4710 |
+ var $wrapperEl; |
|
4711 |
+ |
|
4712 |
+ if (el && el.shadowRoot && el.shadowRoot.querySelector) { |
|
4713 |
+ $wrapperEl = $(el.shadowRoot.querySelector("." + swiper.params.wrapperClass)); // Children needs to return slot items |
|
4714 |
+ |
|
4715 |
+ $wrapperEl.children = function (options) { |
|
4716 |
+ return $el.children(options); |
|
4717 |
+ }; |
|
4718 |
+ } else { |
|
4719 |
+ $wrapperEl = $el.children("." + swiper.params.wrapperClass); |
|
4720 |
+ } // Extend Swiper |
|
4721 |
+ |
|
4722 |
+ |
|
4723 |
+ extend$1(swiper, { |
|
4724 |
+ $el: $el, |
|
4725 |
+ el: el, |
|
4726 |
+ $wrapperEl: $wrapperEl, |
|
4727 |
+ wrapperEl: $wrapperEl[0], |
|
4728 |
+ // Classes |
|
4729 |
+ classNames: [], |
|
4730 |
+ // Slides |
|
4731 |
+ slides: $(), |
|
4732 |
+ slidesGrid: [], |
|
4733 |
+ snapGrid: [], |
|
4734 |
+ slidesSizesGrid: [], |
|
4735 |
+ // isDirection |
|
4736 |
+ isHorizontal: function isHorizontal() { |
|
4737 |
+ return swiper.params.direction === 'horizontal'; |
|
4738 |
+ }, |
|
4739 |
+ isVertical: function isVertical() { |
|
4740 |
+ return swiper.params.direction === 'vertical'; |
|
4741 |
+ }, |
|
4742 |
+ // RTL |
|
4743 |
+ rtl: el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl', |
|
4744 |
+ rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'), |
|
4745 |
+ wrongRTL: $wrapperEl.css('display') === '-webkit-box', |
|
4746 |
+ // Indexes |
|
4747 |
+ activeIndex: 0, |
|
4748 |
+ realIndex: 0, |
|
4749 |
+ // |
|
4750 |
+ isBeginning: true, |
|
4751 |
+ isEnd: false, |
|
4752 |
+ // Props |
|
4753 |
+ translate: 0, |
|
4754 |
+ previousTranslate: 0, |
|
4755 |
+ progress: 0, |
|
4756 |
+ velocity: 0, |
|
4757 |
+ animating: false, |
|
4758 |
+ // Locks |
|
4759 |
+ allowSlideNext: swiper.params.allowSlideNext, |
|
4760 |
+ allowSlidePrev: swiper.params.allowSlidePrev, |
|
4761 |
+ // Touch Events |
|
4762 |
+ touchEvents: function touchEvents() { |
|
4763 |
+ var touch = ['touchstart', 'touchmove', 'touchend', 'touchcancel']; |
|
4764 |
+ var desktop = ['mousedown', 'mousemove', 'mouseup']; |
|
4765 |
+ |
|
4766 |
+ if (swiper.support.pointerEvents) { |
|
4767 |
+ desktop = ['pointerdown', 'pointermove', 'pointerup']; |
|
4768 |
+ } |
|
4769 |
+ |
|
4770 |
+ swiper.touchEventsTouch = { |
|
4771 |
+ start: touch[0], |
|
4772 |
+ move: touch[1], |
|
4773 |
+ end: touch[2], |
|
4774 |
+ cancel: touch[3] |
|
4775 |
+ }; |
|
4776 |
+ swiper.touchEventsDesktop = { |
|
4777 |
+ start: desktop[0], |
|
4778 |
+ move: desktop[1], |
|
4779 |
+ end: desktop[2] |
|
4780 |
+ }; |
|
4781 |
+ return swiper.support.touch || !swiper.params.simulateTouch ? swiper.touchEventsTouch : swiper.touchEventsDesktop; |
|
4782 |
+ }(), |
|
4783 |
+ touchEventsData: { |
|
4784 |
+ isTouched: undefined, |
|
4785 |
+ isMoved: undefined, |
|
4786 |
+ allowTouchCallbacks: undefined, |
|
4787 |
+ touchStartTime: undefined, |
|
4788 |
+ isScrolling: undefined, |
|
4789 |
+ currentTranslate: undefined, |
|
4790 |
+ startTranslate: undefined, |
|
4791 |
+ allowThresholdMove: undefined, |
|
4792 |
+ // Form elements to match |
|
4793 |
+ formElements: 'input, select, option, textarea, button, video, label', |
|
4794 |
+ // Last click time |
|
4795 |
+ lastClickTime: now(), |
|
4796 |
+ clickTimeout: undefined, |
|
4797 |
+ // Velocities |
|
4798 |
+ velocities: [], |
|
4799 |
+ allowMomentumBounce: undefined, |
|
4800 |
+ isTouchEvent: undefined, |
|
4801 |
+ startMoving: undefined |
|
4802 |
+ }, |
|
4803 |
+ // Clicks |
|
4804 |
+ allowClick: true, |
|
4805 |
+ // Touches |
|
4806 |
+ allowTouchMove: swiper.params.allowTouchMove, |
|
4807 |
+ touches: { |
|
4808 |
+ startX: 0, |
|
4809 |
+ startY: 0, |
|
4810 |
+ currentX: 0, |
|
4811 |
+ currentY: 0, |
|
4812 |
+ diff: 0 |
|
4813 |
+ }, |
|
4814 |
+ // Images |
|
4815 |
+ imagesToLoad: [], |
|
4816 |
+ imagesLoaded: 0 |
|
4817 |
+ }); // Install Modules |
|
4818 |
+ |
|
4819 |
+ swiper.useModules(); |
|
4820 |
+ swiper.emit('_swiper'); // Init |
|
4821 |
+ |
|
4822 |
+ if (swiper.params.init) { |
|
4823 |
+ swiper.init(); |
|
4824 |
+ } // Return app instance |
|
4825 |
+ |
|
4826 |
+ |
|
4827 |
+ return swiper; |
|
4828 |
+ } |
|
4829 |
+ |
|
4830 |
+ var _proto = Swiper.prototype; |
|
4831 |
+ |
|
4832 |
+ _proto.emitContainerClasses = function emitContainerClasses() { |
|
4833 |
+ var swiper = this; |
|
4834 |
+ if (!swiper.params._emitClasses || !swiper.el) return; |
|
4835 |
+ var classes = swiper.el.className.split(' ').filter(function (className) { |
|
4836 |
+ return className.indexOf('swiper-container') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0; |
|
4837 |
+ }); |
|
4838 |
+ swiper.emit('_containerClasses', classes.join(' ')); |
|
4839 |
+ }; |
|
4840 |
+ |
|
4841 |
+ _proto.getSlideClasses = function getSlideClasses(slideEl) { |
|
4842 |
+ var swiper = this; |
|
4843 |
+ return slideEl.className.split(' ').filter(function (className) { |
|
4844 |
+ return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0; |
|
4845 |
+ }).join(' '); |
|
4846 |
+ }; |
|
4847 |
+ |
|
4848 |
+ _proto.emitSlidesClasses = function emitSlidesClasses() { |
|
4849 |
+ var swiper = this; |
|
4850 |
+ if (!swiper.params._emitClasses || !swiper.el) return; |
|
4851 |
+ swiper.slides.each(function (slideEl) { |
|
4852 |
+ var classNames = swiper.getSlideClasses(slideEl); |
|
4853 |
+ swiper.emit('_slideClass', slideEl, classNames); |
|
4854 |
+ }); |
|
4855 |
+ }; |
|
4856 |
+ |
|
4857 |
+ _proto.slidesPerViewDynamic = function slidesPerViewDynamic() { |
|
4858 |
+ var swiper = this; |
|
4859 |
+ var params = swiper.params, |
|
4860 |
+ slides = swiper.slides, |
|
4861 |
+ slidesGrid = swiper.slidesGrid, |
|
4862 |
+ swiperSize = swiper.size, |
|
4863 |
+ activeIndex = swiper.activeIndex; |
|
4864 |
+ var spv = 1; |
|
4865 |
+ |
|
4866 |
+ if (params.centeredSlides) { |
|
4867 |
+ var slideSize = slides[activeIndex].swiperSlideSize; |
|
4868 |
+ var breakLoop; |
|
4869 |
+ |
|
4870 |
+ for (var i = activeIndex + 1; i < slides.length; i += 1) { |
|
4871 |
+ if (slides[i] && !breakLoop) { |
|
4872 |
+ slideSize += slides[i].swiperSlideSize; |
|
4873 |
+ spv += 1; |
|
4874 |
+ if (slideSize > swiperSize) breakLoop = true; |
|
4875 |
+ } |
|
4876 |
+ } |
|
4877 |
+ |
|
4878 |
+ for (var _i = activeIndex - 1; _i >= 0; _i -= 1) { |
|
4879 |
+ if (slides[_i] && !breakLoop) { |
|
4880 |
+ slideSize += slides[_i].swiperSlideSize; |
|
4881 |
+ spv += 1; |
|
4882 |
+ if (slideSize > swiperSize) breakLoop = true; |
|
4883 |
+ } |
|
4884 |
+ } |
|
4885 |
+ } else { |
|
4886 |
+ for (var _i2 = activeIndex + 1; _i2 < slides.length; _i2 += 1) { |
|
4887 |
+ if (slidesGrid[_i2] - slidesGrid[activeIndex] < swiperSize) { |
|
4888 |
+ spv += 1; |
|
4889 |
+ } |
|
4890 |
+ } |
|
4891 |
+ } |
|
4892 |
+ |
|
4893 |
+ return spv; |
|
4894 |
+ }; |
|
4895 |
+ |
|
4896 |
+ _proto.update = function update() { |
|
4897 |
+ var swiper = this; |
|
4898 |
+ if (!swiper || swiper.destroyed) return; |
|
4899 |
+ var snapGrid = swiper.snapGrid, |
|
4900 |
+ params = swiper.params; // Breakpoints |
|
4901 |
+ |
|
4902 |
+ if (params.breakpoints) { |
|
4903 |
+ swiper.setBreakpoint(); |
|
4904 |
+ } |
|
4905 |
+ |
|
4906 |
+ swiper.updateSize(); |
|
4907 |
+ swiper.updateSlides(); |
|
4908 |
+ swiper.updateProgress(); |
|
4909 |
+ swiper.updateSlidesClasses(); |
|
4910 |
+ |
|
4911 |
+ function setTranslate() { |
|
4912 |
+ var translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate; |
|
4913 |
+ var newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate()); |
|
4914 |
+ swiper.setTranslate(newTranslate); |
|
4915 |
+ swiper.updateActiveIndex(); |
|
4916 |
+ swiper.updateSlidesClasses(); |
|
4917 |
+ } |
|
4918 |
+ |
|
4919 |
+ var translated; |
|
4920 |
+ |
|
4921 |
+ if (swiper.params.freeMode) { |
|
4922 |
+ setTranslate(); |
|
4923 |
+ |
|
4924 |
+ if (swiper.params.autoHeight) { |
|
4925 |
+ swiper.updateAutoHeight(); |
|
4926 |
+ } |
|
4927 |
+ } else { |
|
4928 |
+ if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) { |
|
4929 |
+ translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true); |
|
4930 |
+ } else { |
|
4931 |
+ translated = swiper.slideTo(swiper.activeIndex, 0, false, true); |
|
4932 |
+ } |
|
4933 |
+ |
|
4934 |
+ if (!translated) { |
|
4935 |
+ setTranslate(); |
|
4936 |
+ } |
|
4937 |
+ } |
|
4938 |
+ |
|
4939 |
+ if (params.watchOverflow && snapGrid !== swiper.snapGrid) { |
|
4940 |
+ swiper.checkOverflow(); |
|
4941 |
+ } |
|
4942 |
+ |
|
4943 |
+ swiper.emit('update'); |
|
4944 |
+ }; |
|
4945 |
+ |
|
4946 |
+ _proto.changeDirection = function changeDirection(newDirection, needUpdate) { |
|
4947 |
+ if (needUpdate === void 0) { |
|
4948 |
+ needUpdate = true; |
|
4949 |
+ } |
|
4950 |
+ |
|
4951 |
+ var swiper = this; |
|
4952 |
+ var currentDirection = swiper.params.direction; |
|
4953 |
+ |
|
4954 |
+ if (!newDirection) { |
|
4955 |
+ // eslint-disable-next-line |
|
4956 |
+ newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal'; |
|
4957 |
+ } |
|
4958 |
+ |
|
4959 |
+ if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') { |
|
4960 |
+ return swiper; |
|
4961 |
+ } |
|
4962 |
+ |
|
4963 |
+ swiper.$el.removeClass("" + swiper.params.containerModifierClass + currentDirection).addClass("" + swiper.params.containerModifierClass + newDirection); |
|
4964 |
+ swiper.emitContainerClasses(); |
|
4965 |
+ swiper.params.direction = newDirection; |
|
4966 |
+ swiper.slides.each(function (slideEl) { |
|
4967 |
+ if (newDirection === 'vertical') { |
|
4968 |
+ slideEl.style.width = ''; |
|
4969 |
+ } else { |
|
4970 |
+ slideEl.style.height = ''; |
|
4971 |
+ } |
|
4972 |
+ }); |
|
4973 |
+ swiper.emit('changeDirection'); |
|
4974 |
+ if (needUpdate) swiper.update(); |
|
4975 |
+ return swiper; |
|
4976 |
+ }; |
|
4977 |
+ |
|
4978 |
+ _proto.init = function init() { |
|
4979 |
+ var swiper = this; |
|
4980 |
+ if (swiper.initialized) return; |
|
4981 |
+ swiper.emit('beforeInit'); // Set breakpoint |
|
4982 |
+ |
|
4983 |
+ if (swiper.params.breakpoints) { |
|
4984 |
+ swiper.setBreakpoint(); |
|
4985 |
+ } // Add Classes |
|
4986 |
+ |
|
4987 |
+ |
|
4988 |
+ swiper.addClasses(); // Create loop |
|
4989 |
+ |
|
4990 |
+ if (swiper.params.loop) { |
|
4991 |
+ swiper.loopCreate(); |
|
4992 |
+ } // Update size |
|
4993 |
+ |
|
4994 |
+ |
|
4995 |
+ swiper.updateSize(); // Update slides |
|
4996 |
+ |
|
4997 |
+ swiper.updateSlides(); |
|
4998 |
+ |
|
4999 |
+ if (swiper.params.watchOverflow) { |
|
5000 |
+ swiper.checkOverflow(); |
|
5001 |
+ } // Set Grab Cursor |
|
5002 |
+ |
|
5003 |
+ |
|
5004 |
+ if (swiper.params.grabCursor) { |
|
5005 |
+ swiper.setGrabCursor(); |
|
5006 |
+ } |
|
5007 |
+ |
|
5008 |
+ if (swiper.params.preloadImages) { |
|
5009 |
+ swiper.preloadImages(); |
|
5010 |
+ } // Slide To Initial Slide |
|
5011 |
+ |
|
5012 |
+ |
|
5013 |
+ if (swiper.params.loop) { |
|
5014 |
+ swiper.slideTo(swiper.params.initialSlide + swiper.loopedSlides, 0, swiper.params.runCallbacksOnInit); |
|
5015 |
+ } else { |
|
5016 |
+ swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit); |
|
5017 |
+ } // Attach events |
|
5018 |
+ |
|
5019 |
+ |
|
5020 |
+ swiper.attachEvents(); // Init Flag |
|
5021 |
+ |
|
5022 |
+ swiper.initialized = true; // Emit |
|
5023 |
+ |
|
5024 |
+ swiper.emit('init'); |
|
5025 |
+ swiper.emit('afterInit'); |
|
5026 |
+ }; |
|
5027 |
+ |
|
5028 |
+ _proto.destroy = function destroy(deleteInstance, cleanStyles) { |
|
5029 |
+ if (deleteInstance === void 0) { |
|
5030 |
+ deleteInstance = true; |
|
5031 |
+ } |
|
5032 |
+ |
|
5033 |
+ if (cleanStyles === void 0) { |
|
5034 |
+ cleanStyles = true; |
|
5035 |
+ } |
|
5036 |
+ |
|
5037 |
+ var swiper = this; |
|
5038 |
+ var params = swiper.params, |
|
5039 |
+ $el = swiper.$el, |
|
5040 |
+ $wrapperEl = swiper.$wrapperEl, |
|
5041 |
+ slides = swiper.slides; |
|
5042 |
+ |
|
5043 |
+ if (typeof swiper.params === 'undefined' || swiper.destroyed) { |
|
5044 |
+ return null; |
|
5045 |
+ } |
|
5046 |
+ |
|
5047 |
+ swiper.emit('beforeDestroy'); // Init Flag |
|
5048 |
+ |
|
5049 |
+ swiper.initialized = false; // Detach events |
|
5050 |
+ |
|
5051 |
+ swiper.detachEvents(); // Destroy loop |
|
5052 |
+ |
|
5053 |
+ if (params.loop) { |
|
5054 |
+ swiper.loopDestroy(); |
|
5055 |
+ } // Cleanup styles |
|
5056 |
+ |
|
5057 |
+ |
|
5058 |
+ if (cleanStyles) { |
|
5059 |
+ swiper.removeClasses(); |
|
5060 |
+ $el.removeAttr('style'); |
|
5061 |
+ $wrapperEl.removeAttr('style'); |
|
5062 |
+ |
|
5063 |
+ if (slides && slides.length) { |
|
5064 |
+ slides.removeClass([params.slideVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass].join(' ')).removeAttr('style').removeAttr('data-swiper-slide-index'); |
|
5065 |
+ } |
|
5066 |
+ } |
|
5067 |
+ |
|
5068 |
+ swiper.emit('destroy'); // Detach emitter events |
|
5069 |
+ |
|
5070 |
+ Object.keys(swiper.eventsListeners).forEach(function (eventName) { |
|
5071 |
+ swiper.off(eventName); |
|
5072 |
+ }); |
|
5073 |
+ |
|
5074 |
+ if (deleteInstance !== false) { |
|
5075 |
+ swiper.$el[0].swiper = null; |
|
5076 |
+ deleteProps(swiper); |
|
5077 |
+ } |
|
5078 |
+ |
|
5079 |
+ swiper.destroyed = true; |
|
5080 |
+ return null; |
|
5081 |
+ }; |
|
5082 |
+ |
|
5083 |
+ Swiper.extendDefaults = function extendDefaults(newDefaults) { |
|
5084 |
+ extend$1(extendedDefaults, newDefaults); |
|
5085 |
+ }; |
|
5086 |
+ |
|
5087 |
+ Swiper.installModule = function installModule(module) { |
|
5088 |
+ if (!Swiper.prototype.modules) Swiper.prototype.modules = {}; |
|
5089 |
+ var name = module.name || Object.keys(Swiper.prototype.modules).length + "_" + now(); |
|
5090 |
+ Swiper.prototype.modules[name] = module; |
|
5091 |
+ }; |
|
5092 |
+ |
|
5093 |
+ Swiper.use = function use(module) { |
|
5094 |
+ if (Array.isArray(module)) { |
|
5095 |
+ module.forEach(function (m) { |
|
5096 |
+ return Swiper.installModule(m); |
|
5097 |
+ }); |
|
5098 |
+ return Swiper; |
|
5099 |
+ } |
|
5100 |
+ |
|
5101 |
+ Swiper.installModule(module); |
|
5102 |
+ return Swiper; |
|
5103 |
+ }; |
|
5104 |
+ |
|
5105 |
+ _createClass(Swiper, null, [{ |
|
5106 |
+ key: "extendedDefaults", |
|
5107 |
+ get: function get() { |
|
5108 |
+ return extendedDefaults; |
|
5109 |
+ } |
|
5110 |
+ }, { |
|
5111 |
+ key: "defaults", |
|
5112 |
+ get: function get() { |
|
5113 |
+ return defaults; |
|
5114 |
+ } |
|
5115 |
+ }]); |
|
5116 |
+ |
|
5117 |
+ return Swiper; |
|
5118 |
+}(); |
|
5119 |
+ |
|
5120 |
+Object.keys(prototypes).forEach(function (prototypeGroup) { |
|
5121 |
+ Object.keys(prototypes[prototypeGroup]).forEach(function (protoMethod) { |
|
5122 |
+ Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod]; |
|
5123 |
+ }); |
|
5124 |
+}); |
|
5125 |
+Swiper.use([Resize, Observer$1]); |
|
5126 |
+ |
|
5127 |
+var Virtual = { |
|
5128 |
+ update: function update(force) { |
|
5129 |
+ var swiper = this; |
|
5130 |
+ var _swiper$params = swiper.params, |
|
5131 |
+ slidesPerView = _swiper$params.slidesPerView, |
|
5132 |
+ slidesPerGroup = _swiper$params.slidesPerGroup, |
|
5133 |
+ centeredSlides = _swiper$params.centeredSlides; |
|
5134 |
+ var _swiper$params$virtua = swiper.params.virtual, |
|
5135 |
+ addSlidesBefore = _swiper$params$virtua.addSlidesBefore, |
|
5136 |
+ addSlidesAfter = _swiper$params$virtua.addSlidesAfter; |
|
5137 |
+ var _swiper$virtual = swiper.virtual, |
|
5138 |
+ previousFrom = _swiper$virtual.from, |
|
5139 |
+ previousTo = _swiper$virtual.to, |
|
5140 |
+ slides = _swiper$virtual.slides, |
|
5141 |
+ previousSlidesGrid = _swiper$virtual.slidesGrid, |
|
5142 |
+ renderSlide = _swiper$virtual.renderSlide, |
|
5143 |
+ previousOffset = _swiper$virtual.offset; |
|
5144 |
+ swiper.updateActiveIndex(); |
|
5145 |
+ var activeIndex = swiper.activeIndex || 0; |
|
5146 |
+ var offsetProp; |
|
5147 |
+ if (swiper.rtlTranslate) offsetProp = 'right';else offsetProp = swiper.isHorizontal() ? 'left' : 'top'; |
|
5148 |
+ var slidesAfter; |
|
5149 |
+ var slidesBefore; |
|
5150 |
+ |
|
5151 |
+ if (centeredSlides) { |
|
5152 |
+ slidesAfter = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesAfter; |
|
5153 |
+ slidesBefore = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesBefore; |
|
5154 |
+ } else { |
|
5155 |
+ slidesAfter = slidesPerView + (slidesPerGroup - 1) + addSlidesAfter; |
|
5156 |
+ slidesBefore = slidesPerGroup + addSlidesBefore; |
|
5157 |
+ } |
|
5158 |
+ |
|
5159 |
+ var from = Math.max((activeIndex || 0) - slidesBefore, 0); |
|
5160 |
+ var to = Math.min((activeIndex || 0) + slidesAfter, slides.length - 1); |
|
5161 |
+ var offset = (swiper.slidesGrid[from] || 0) - (swiper.slidesGrid[0] || 0); |
|
5162 |
+ extend$1(swiper.virtual, { |
|
5163 |
+ from: from, |
|
5164 |
+ to: to, |
|
5165 |
+ offset: offset, |
|
5166 |
+ slidesGrid: swiper.slidesGrid |
|
5167 |
+ }); |
|
5168 |
+ |
|
5169 |
+ function onRendered() { |
|
5170 |
+ swiper.updateSlides(); |
|
5171 |
+ swiper.updateProgress(); |
|
5172 |
+ swiper.updateSlidesClasses(); |
|
5173 |
+ |
|
5174 |
+ if (swiper.lazy && swiper.params.lazy.enabled) { |
|
5175 |
+ swiper.lazy.load(); |
|
5176 |
+ } |
|
5177 |
+ } |
|
5178 |
+ |
|
5179 |
+ if (previousFrom === from && previousTo === to && !force) { |
|
5180 |
+ if (swiper.slidesGrid !== previousSlidesGrid && offset !== previousOffset) { |
|
5181 |
+ swiper.slides.css(offsetProp, offset + "px"); |
|
5182 |
+ } |
|
5183 |
+ |
|
5184 |
+ swiper.updateProgress(); |
|
5185 |
+ return; |
|
5186 |
+ } |
|
5187 |
+ |
|
5188 |
+ if (swiper.params.virtual.renderExternal) { |
|
5189 |
+ swiper.params.virtual.renderExternal.call(swiper, { |
|
5190 |
+ offset: offset, |
|
5191 |
+ from: from, |
|
5192 |
+ to: to, |
|
5193 |
+ slides: function getSlides() { |
|
5194 |
+ var slidesToRender = []; |
|
5195 |
+ |
|
5196 |
+ for (var i = from; i <= to; i += 1) { |
|
5197 |
+ slidesToRender.push(slides[i]); |
|
5198 |
+ } |
|
5199 |
+ |
|
5200 |
+ return slidesToRender; |
|
5201 |
+ }() |
|
5202 |
+ }); |
|
5203 |
+ |
|
5204 |
+ if (swiper.params.virtual.renderExternalUpdate) { |
|
5205 |
+ onRendered(); |
|
5206 |
+ } |
|
5207 |
+ |
|
5208 |
+ return; |
|
5209 |
+ } |
|
5210 |
+ |
|
5211 |
+ var prependIndexes = []; |
|
5212 |
+ var appendIndexes = []; |
|
5213 |
+ |
|
5214 |
+ if (force) { |
|
5215 |
+ swiper.$wrapperEl.find("." + swiper.params.slideClass).remove(); |
|
5216 |
+ } else { |
|
5217 |
+ for (var i = previousFrom; i <= previousTo; i += 1) { |
|
5218 |
+ if (i < from || i > to) { |
|
5219 |
+ swiper.$wrapperEl.find("." + swiper.params.slideClass + "[data-swiper-slide-index=\"" + i + "\"]").remove(); |
|
5220 |
+ } |
|
5221 |
+ } |
|
5222 |
+ } |
|
5223 |
+ |
|
5224 |
+ for (var _i = 0; _i < slides.length; _i += 1) { |
|
5225 |
+ if (_i >= from && _i <= to) { |
|
5226 |
+ if (typeof previousTo === 'undefined' || force) { |
|
5227 |
+ appendIndexes.push(_i); |
|
5228 |
+ } else { |
|
5229 |
+ if (_i > previousTo) appendIndexes.push(_i); |
|
5230 |
+ if (_i < previousFrom) prependIndexes.push(_i); |
|
5231 |
+ } |
|
5232 |
+ } |
|
5233 |
+ } |
|
5234 |
+ |
|
5235 |
+ appendIndexes.forEach(function (index) { |
|
5236 |
+ swiper.$wrapperEl.append(renderSlide(slides[index], index)); |
|
5237 |
+ }); |
|
5238 |
+ prependIndexes.sort(function (a, b) { |
|
5239 |
+ return b - a; |
|
5240 |
+ }).forEach(function (index) { |
|
5241 |
+ swiper.$wrapperEl.prepend(renderSlide(slides[index], index)); |
|
5242 |
+ }); |
|
5243 |
+ swiper.$wrapperEl.children('.swiper-slide').css(offsetProp, offset + "px"); |
|
5244 |
+ onRendered(); |
|
5245 |
+ }, |
|
5246 |
+ renderSlide: function renderSlide(slide, index) { |
|
5247 |
+ var swiper = this; |
|
5248 |
+ var params = swiper.params.virtual; |
|
5249 |
+ |
|
5250 |
+ if (params.cache && swiper.virtual.cache[index]) { |
|
5251 |
+ return swiper.virtual.cache[index]; |
|
5252 |
+ } |
|
5253 |
+ |
|
5254 |
+ var $slideEl = params.renderSlide ? $(params.renderSlide.call(swiper, slide, index)) : $("<div class=\"" + swiper.params.slideClass + "\" data-swiper-slide-index=\"" + index + "\">" + slide + "</div>"); |
|
5255 |
+ if (!$slideEl.attr('data-swiper-slide-index')) $slideEl.attr('data-swiper-slide-index', index); |
|
5256 |
+ if (params.cache) swiper.virtual.cache[index] = $slideEl; |
|
5257 |
+ return $slideEl; |
|
5258 |
+ }, |
|
5259 |
+ appendSlide: function appendSlide(slides) { |
|
5260 |
+ var swiper = this; |
|
5261 |
+ |
|
5262 |
+ if (typeof slides === 'object' && 'length' in slides) { |
|
5263 |
+ for (var i = 0; i < slides.length; i += 1) { |
|
5264 |
+ if (slides[i]) swiper.virtual.slides.push(slides[i]); |
|
5265 |
+ } |
|
5266 |
+ } else { |
|
5267 |
+ swiper.virtual.slides.push(slides); |
|
5268 |
+ } |
|
5269 |
+ |
|
5270 |
+ swiper.virtual.update(true); |
|
5271 |
+ }, |
|
5272 |
+ prependSlide: function prependSlide(slides) { |
|
5273 |
+ var swiper = this; |
|
5274 |
+ var activeIndex = swiper.activeIndex; |
|
5275 |
+ var newActiveIndex = activeIndex + 1; |
|
5276 |
+ var numberOfNewSlides = 1; |
|
5277 |
+ |
|
5278 |
+ if (Array.isArray(slides)) { |
|
5279 |
+ for (var i = 0; i < slides.length; i += 1) { |
|
5280 |
+ if (slides[i]) swiper.virtual.slides.unshift(slides[i]); |
|
5281 |
+ } |
|
5282 |
+ |
|
5283 |
+ newActiveIndex = activeIndex + slides.length; |
|
5284 |
+ numberOfNewSlides = slides.length; |
|
5285 |
+ } else { |
|
5286 |
+ swiper.virtual.slides.unshift(slides); |
|
5287 |
+ } |
|
5288 |
+ |
|
5289 |
+ if (swiper.params.virtual.cache) { |
|
5290 |
+ var cache = swiper.virtual.cache; |
|
5291 |
+ var newCache = {}; |
|
5292 |
+ Object.keys(cache).forEach(function (cachedIndex) { |
|
5293 |
+ var $cachedEl = cache[cachedIndex]; |
|
5294 |
+ var cachedElIndex = $cachedEl.attr('data-swiper-slide-index'); |
|
5295 |
+ |
|
5296 |
+ if (cachedElIndex) { |
|
5297 |
+ $cachedEl.attr('data-swiper-slide-index', parseInt(cachedElIndex, 10) + 1); |
|
5298 |
+ } |
|
5299 |
+ |
|
5300 |
+ newCache[parseInt(cachedIndex, 10) + numberOfNewSlides] = $cachedEl; |
|
5301 |
+ }); |
|
5302 |
+ swiper.virtual.cache = newCache; |
|
5303 |
+ } |
|
5304 |
+ |
|
5305 |
+ swiper.virtual.update(true); |
|
5306 |
+ swiper.slideTo(newActiveIndex, 0); |
|
5307 |
+ }, |
|
5308 |
+ removeSlide: function removeSlide(slidesIndexes) { |
|
5309 |
+ var swiper = this; |
|
5310 |
+ if (typeof slidesIndexes === 'undefined' || slidesIndexes === null) return; |
|
5311 |
+ var activeIndex = swiper.activeIndex; |
|
5312 |
+ |
|
5313 |
+ if (Array.isArray(slidesIndexes)) { |
|
5314 |
+ for (var i = slidesIndexes.length - 1; i >= 0; i -= 1) { |
|
5315 |
+ swiper.virtual.slides.splice(slidesIndexes[i], 1); |
|
5316 |
+ |
|
5317 |
+ if (swiper.params.virtual.cache) { |
|
5318 |
+ delete swiper.virtual.cache[slidesIndexes[i]]; |
|
5319 |
+ } |
|
5320 |
+ |
|
5321 |
+ if (slidesIndexes[i] < activeIndex) activeIndex -= 1; |
|
5322 |
+ activeIndex = Math.max(activeIndex, 0); |
|
5323 |
+ } |
|
5324 |
+ } else { |
|
5325 |
+ swiper.virtual.slides.splice(slidesIndexes, 1); |
|
5326 |
+ |
|
5327 |
+ if (swiper.params.virtual.cache) { |
|
5328 |
+ delete swiper.virtual.cache[slidesIndexes]; |
|
5329 |
+ } |
|
5330 |
+ |
|
5331 |
+ if (slidesIndexes < activeIndex) activeIndex -= 1; |
|
5332 |
+ activeIndex = Math.max(activeIndex, 0); |
|
5333 |
+ } |
|
5334 |
+ |
|
5335 |
+ swiper.virtual.update(true); |
|
5336 |
+ swiper.slideTo(activeIndex, 0); |
|
5337 |
+ }, |
|
5338 |
+ removeAllSlides: function removeAllSlides() { |
|
5339 |
+ var swiper = this; |
|
5340 |
+ swiper.virtual.slides = []; |
|
5341 |
+ |
|
5342 |
+ if (swiper.params.virtual.cache) { |
|
5343 |
+ swiper.virtual.cache = {}; |
|
5344 |
+ } |
|
5345 |
+ |
|
5346 |
+ swiper.virtual.update(true); |
|
5347 |
+ swiper.slideTo(0, 0); |
|
5348 |
+ } |
|
5349 |
+}; |
|
5350 |
+var Virtual$1 = { |
|
5351 |
+ name: 'virtual', |
|
5352 |
+ params: { |
|
5353 |
+ virtual: { |
|
5354 |
+ enabled: false, |
|
5355 |
+ slides: [], |
|
5356 |
+ cache: true, |
|
5357 |
+ renderSlide: null, |
|
5358 |
+ renderExternal: null, |
|
5359 |
+ renderExternalUpdate: true, |
|
5360 |
+ addSlidesBefore: 0, |
|
5361 |
+ addSlidesAfter: 0 |
|
5362 |
+ } |
|
5363 |
+ }, |
|
5364 |
+ create: function create() { |
|
5365 |
+ var swiper = this; |
|
5366 |
+ bindModuleMethods(swiper, { |
|
5367 |
+ virtual: _extends(_extends({}, Virtual), {}, { |
|
5368 |
+ slides: swiper.params.virtual.slides, |
|
5369 |
+ cache: {} |
|
5370 |
+ }) |
|
5371 |
+ }); |
|
5372 |
+ }, |
|
5373 |
+ on: { |
|
5374 |
+ beforeInit: function beforeInit(swiper) { |
|
5375 |
+ if (!swiper.params.virtual.enabled) return; |
|
5376 |
+ swiper.classNames.push(swiper.params.containerModifierClass + "virtual"); |
|
5377 |
+ var overwriteParams = { |
|
5378 |
+ watchSlidesProgress: true |
|
5379 |
+ }; |
|
5380 |
+ extend$1(swiper.params, overwriteParams); |
|
5381 |
+ extend$1(swiper.originalParams, overwriteParams); |
|
5382 |
+ |
|
5383 |
+ if (!swiper.params.initialSlide) { |
|
5384 |
+ swiper.virtual.update(); |
|
5385 |
+ } |
|
5386 |
+ }, |
|
5387 |
+ setTranslate: function setTranslate(swiper) { |
|
5388 |
+ if (!swiper.params.virtual.enabled) return; |
|
5389 |
+ swiper.virtual.update(); |
|
5390 |
+ } |
|
5391 |
+ } |
|
5392 |
+}; |
|
5393 |
+ |
|
5394 |
+var Keyboard = { |
|
5395 |
+ handle: function handle(event) { |
|
5396 |
+ var swiper = this; |
|
5397 |
+ var window = getWindow(); |
|
5398 |
+ var document = getDocument(); |
|
5399 |
+ var rtl = swiper.rtlTranslate; |
|
5400 |
+ var e = event; |
|
5401 |
+ if (e.originalEvent) e = e.originalEvent; // jquery fix |
|
5402 |
+ |
|
5403 |
+ var kc = e.keyCode || e.charCode; |
|
5404 |
+ var pageUpDown = swiper.params.keyboard.pageUpDown; |
|
5405 |
+ var isPageUp = pageUpDown && kc === 33; |
|
5406 |
+ var isPageDown = pageUpDown && kc === 34; |
|
5407 |
+ var isArrowLeft = kc === 37; |
|
5408 |
+ var isArrowRight = kc === 39; |
|
5409 |
+ var isArrowUp = kc === 38; |
|
5410 |
+ var isArrowDown = kc === 40; // Directions locks |
|
5411 |
+ |
|
5412 |
+ if (!swiper.allowSlideNext && (swiper.isHorizontal() && isArrowRight || swiper.isVertical() && isArrowDown || isPageDown)) { |
|
5413 |
+ return false; |
|
5414 |
+ } |
|
5415 |
+ |
|
5416 |
+ if (!swiper.allowSlidePrev && (swiper.isHorizontal() && isArrowLeft || swiper.isVertical() && isArrowUp || isPageUp)) { |
|
5417 |
+ return false; |
|
5418 |
+ } |
|
5419 |
+ |
|
5420 |
+ if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) { |
|
5421 |
+ return undefined; |
|
5422 |
+ } |
|
5423 |
+ |
|
5424 |
+ if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) { |
|
5425 |
+ return undefined; |
|
5426 |
+ } |
|
5427 |
+ |
|
5428 |
+ if (swiper.params.keyboard.onlyInViewport && (isPageUp || isPageDown || isArrowLeft || isArrowRight || isArrowUp || isArrowDown)) { |
|
5429 |
+ var inView = false; // Check that swiper should be inside of visible area of window |
|
5430 |
+ |
|
5431 |
+ if (swiper.$el.parents("." + swiper.params.slideClass).length > 0 && swiper.$el.parents("." + swiper.params.slideActiveClass).length === 0) { |
|
5432 |
+ return undefined; |
|
5433 |
+ } |
|
5434 |
+ |
|
5435 |
+ var windowWidth = window.innerWidth; |
|
5436 |
+ var windowHeight = window.innerHeight; |
|
5437 |
+ var swiperOffset = swiper.$el.offset(); |
|
5438 |
+ if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft; |
|
5439 |
+ var swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiper.width, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiper.height], [swiperOffset.left + swiper.width, swiperOffset.top + swiper.height]]; |
|
5440 |
+ |
|
5441 |
+ for (var i = 0; i < swiperCoord.length; i += 1) { |
|
5442 |
+ var point = swiperCoord[i]; |
|
5443 |
+ |
|
5444 |
+ if (point[0] >= 0 && point[0] <= windowWidth && point[1] >= 0 && point[1] <= windowHeight) { |
|
5445 |
+ inView = true; |
|
5446 |
+ } |
|
5447 |
+ } |
|
5448 |
+ |
|
5449 |
+ if (!inView) return undefined; |
|
5450 |
+ } |
|
5451 |
+ |
|
5452 |
+ if (swiper.isHorizontal()) { |
|
5453 |
+ if (isPageUp || isPageDown || isArrowLeft || isArrowRight) { |
|
5454 |
+ if (e.preventDefault) e.preventDefault();else e.returnValue = false; |
|
5455 |
+ } |
|
5456 |
+ |
|
5457 |
+ if ((isPageDown || isArrowRight) && !rtl || (isPageUp || isArrowLeft) && rtl) swiper.slideNext(); |
|
5458 |
+ if ((isPageUp || isArrowLeft) && !rtl || (isPageDown || isArrowRight) && rtl) swiper.slidePrev(); |
|
5459 |
+ } else { |
|
5460 |
+ if (isPageUp || isPageDown || isArrowUp || isArrowDown) { |
|
5461 |
+ if (e.preventDefault) e.preventDefault();else e.returnValue = false; |
|
5462 |
+ } |
|
5463 |
+ |
|
5464 |
+ if (isPageDown || isArrowDown) swiper.slideNext(); |
|
5465 |
+ if (isPageUp || isArrowUp) swiper.slidePrev(); |
|
5466 |
+ } |
|
5467 |
+ |
|
5468 |
+ swiper.emit('keyPress', kc); |
|
5469 |
+ return undefined; |
|
5470 |
+ }, |
|
5471 |
+ enable: function enable() { |
|
5472 |
+ var swiper = this; |
|
5473 |
+ var document = getDocument(); |
|
5474 |
+ if (swiper.keyboard.enabled) return; |
|
5475 |
+ $(document).on('keydown', swiper.keyboard.handle); |
|
5476 |
+ swiper.keyboard.enabled = true; |
|
5477 |
+ }, |
|
5478 |
+ disable: function disable() { |
|
5479 |
+ var swiper = this; |
|
5480 |
+ var document = getDocument(); |
|
5481 |
+ if (!swiper.keyboard.enabled) return; |
|
5482 |
+ $(document).off('keydown', swiper.keyboard.handle); |
|
5483 |
+ swiper.keyboard.enabled = false; |
|
5484 |
+ } |
|
5485 |
+}; |
|
5486 |
+var Keyboard$1 = { |
|
5487 |
+ name: 'keyboard', |
|
5488 |
+ params: { |
|
5489 |
+ keyboard: { |
|
5490 |
+ enabled: false, |
|
5491 |
+ onlyInViewport: true, |
|
5492 |
+ pageUpDown: true |
|
5493 |
+ } |
|
5494 |
+ }, |
|
5495 |
+ create: function create() { |
|
5496 |
+ var swiper = this; |
|
5497 |
+ bindModuleMethods(swiper, { |
|
5498 |
+ keyboard: _extends({ |
|
5499 |
+ enabled: false |
|
5500 |
+ }, Keyboard) |
|
5501 |
+ }); |
|
5502 |
+ }, |
|
5503 |
+ on: { |
|
5504 |
+ init: function init(swiper) { |
|
5505 |
+ if (swiper.params.keyboard.enabled) { |
|
5506 |
+ swiper.keyboard.enable(); |
|
5507 |
+ } |
|
5508 |
+ }, |
|
5509 |
+ destroy: function destroy(swiper) { |
|
5510 |
+ if (swiper.keyboard.enabled) { |
|
5511 |
+ swiper.keyboard.disable(); |
|
5512 |
+ } |
|
5513 |
+ } |
|
5514 |
+ } |
|
5515 |
+}; |
|
5516 |
+ |
|
5517 |
+function isEventSupported() { |
|
5518 |
+ var document = getDocument(); |
|
5519 |
+ var eventName = 'onwheel'; |
|
5520 |
+ var isSupported = (eventName in document); |
|
5521 |
+ |
|
5522 |
+ if (!isSupported) { |
|
5523 |
+ var element = document.createElement('div'); |
|
5524 |
+ element.setAttribute(eventName, 'return;'); |
|
5525 |
+ isSupported = typeof element[eventName] === 'function'; |
|
5526 |
+ } |
|
5527 |
+ |
|
5528 |
+ if (!isSupported && document.implementation && document.implementation.hasFeature && // always returns true in newer browsers as per the standard. |
|
5529 |
+ // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature |
|
5530 |
+ document.implementation.hasFeature('', '') !== true) { |
|
5531 |
+ // This is the only way to test support for the `wheel` event in IE9+. |
|
5532 |
+ isSupported = document.implementation.hasFeature('Events.wheel', '3.0'); |
|
5533 |
+ } |
|
5534 |
+ |
|
5535 |
+ return isSupported; |
|
5536 |
+} |
|
5537 |
+ |
|
5538 |
+var Mousewheel = { |
|
5539 |
+ lastScrollTime: now(), |
|
5540 |
+ lastEventBeforeSnap: undefined, |
|
5541 |
+ recentWheelEvents: [], |
|
5542 |
+ event: function event() { |
|
5543 |
+ var window = getWindow(); |
|
5544 |
+ if (window.navigator.userAgent.indexOf('firefox') > -1) return 'DOMMouseScroll'; |
|
5545 |
+ return isEventSupported() ? 'wheel' : 'mousewheel'; |
|
5546 |
+ }, |
|
5547 |
+ normalize: function normalize(e) { |
|
5548 |
+ // Reasonable defaults |
|
5549 |
+ var PIXEL_STEP = 10; |
|
5550 |
+ var LINE_HEIGHT = 40; |
|
5551 |
+ var PAGE_HEIGHT = 800; |
|
5552 |
+ var sX = 0; |
|
5553 |
+ var sY = 0; // spinX, spinY |
|
5554 |
+ |
|
5555 |
+ var pX = 0; |
|
5556 |
+ var pY = 0; // pixelX, pixelY |
|
5557 |
+ // Legacy |
|
5558 |
+ |
|
5559 |
+ if ('detail' in e) { |
|
5560 |
+ sY = e.detail; |
|
5561 |
+ } |
|
5562 |
+ |
|
5563 |
+ if ('wheelDelta' in e) { |
|
5564 |
+ sY = -e.wheelDelta / 120; |
|
5565 |
+ } |
|
5566 |
+ |
|
5567 |
+ if ('wheelDeltaY' in e) { |
|
5568 |
+ sY = -e.wheelDeltaY / 120; |
|
5569 |
+ } |
|
5570 |
+ |
|
5571 |
+ if ('wheelDeltaX' in e) { |
|
5572 |
+ sX = -e.wheelDeltaX / 120; |
|
5573 |
+ } // side scrolling on FF with DOMMouseScroll |
|
5574 |
+ |
|
5575 |
+ |
|
5576 |
+ if ('axis' in e && e.axis === e.HORIZONTAL_AXIS) { |
|
5577 |
+ sX = sY; |
|
5578 |
+ sY = 0; |
|
5579 |
+ } |
|
5580 |
+ |
|
5581 |
+ pX = sX * PIXEL_STEP; |
|
5582 |
+ pY = sY * PIXEL_STEP; |
|
5583 |
+ |
|
5584 |
+ if ('deltaY' in e) { |
|
5585 |
+ pY = e.deltaY; |
|
5586 |
+ } |
|
5587 |
+ |
|
5588 |
+ if ('deltaX' in e) { |
|
5589 |
+ pX = e.deltaX; |
|
5590 |
+ } |
|
5591 |
+ |
|
5592 |
+ if (e.shiftKey && !pX) { |
|
5593 |
+ // if user scrolls with shift he wants horizontal scroll |
|
5594 |
+ pX = pY; |
|
5595 |
+ pY = 0; |
|
5596 |
+ } |
|
5597 |
+ |
|
5598 |
+ if ((pX || pY) && e.deltaMode) { |
|
5599 |
+ if (e.deltaMode === 1) { |
|
5600 |
+ // delta in LINE units |
|
5601 |
+ pX *= LINE_HEIGHT; |
|
5602 |
+ pY *= LINE_HEIGHT; |
|
5603 |
+ } else { |
|
5604 |
+ // delta in PAGE units |
|
5605 |
+ pX *= PAGE_HEIGHT; |
|
5606 |
+ pY *= PAGE_HEIGHT; |
|
5607 |
+ } |
|
5608 |
+ } // Fall-back if spin cannot be determined |
|
5609 |
+ |
|
5610 |
+ |
|
5611 |
+ if (pX && !sX) { |
|
5612 |
+ sX = pX < 1 ? -1 : 1; |
|
5613 |
+ } |
|
5614 |
+ |
|
5615 |
+ if (pY && !sY) { |
|
5616 |
+ sY = pY < 1 ? -1 : 1; |
|
5617 |
+ } |
|
5618 |
+ |
|
5619 |
+ return { |
|
5620 |
+ spinX: sX, |
|
5621 |
+ spinY: sY, |
|
5622 |
+ pixelX: pX, |
|
5623 |
+ pixelY: pY |
|
5624 |
+ }; |
|
5625 |
+ }, |
|
5626 |
+ handleMouseEnter: function handleMouseEnter() { |
|
5627 |
+ var swiper = this; |
|
5628 |
+ swiper.mouseEntered = true; |
|
5629 |
+ }, |
|
5630 |
+ handleMouseLeave: function handleMouseLeave() { |
|
5631 |
+ var swiper = this; |
|
5632 |
+ swiper.mouseEntered = false; |
|
5633 |
+ }, |
|
5634 |
+ handle: function handle(event) { |
|
5635 |
+ var e = event; |
|
5636 |
+ var swiper = this; |
|
5637 |
+ var params = swiper.params.mousewheel; |
|
5638 |
+ |
|
5639 |
+ if (swiper.params.cssMode) { |
|
5640 |
+ e.preventDefault(); |
|
5641 |
+ } |
|
5642 |
+ |
|
5643 |
+ var target = swiper.$el; |
|
5644 |
+ |
|
5645 |
+ if (swiper.params.mousewheel.eventsTarget !== 'container') { |
|
5646 |
+ target = $(swiper.params.mousewheel.eventsTarget); |
|
5647 |
+ } |
|
5648 |
+ |
|
5649 |
+ if (!swiper.mouseEntered && !target[0].contains(e.target) && !params.releaseOnEdges) return true; |
|
5650 |
+ if (e.originalEvent) e = e.originalEvent; // jquery fix |
|
5651 |
+ |
|
5652 |
+ var delta = 0; |
|
5653 |
+ var rtlFactor = swiper.rtlTranslate ? -1 : 1; |
|
5654 |
+ var data = Mousewheel.normalize(e); |
|
5655 |
+ |
|
5656 |
+ if (params.forceToAxis) { |
|
5657 |
+ if (swiper.isHorizontal()) { |
|
5658 |
+ if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) delta = -data.pixelX * rtlFactor;else return true; |
|
5659 |
+ } else if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) delta = -data.pixelY;else return true; |
|
5660 |
+ } else { |
|
5661 |
+ delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY; |
|
5662 |
+ } |
|
5663 |
+ |
|
5664 |
+ if (delta === 0) return true; |
|
5665 |
+ if (params.invert) delta = -delta; |
|
5666 |
+ |
|
5667 |
+ if (!swiper.params.freeMode) { |
|
5668 |
+ // Register the new event in a variable which stores the relevant data |
|
5669 |
+ var newEvent = { |
|
5670 |
+ time: now(), |
|
5671 |
+ delta: Math.abs(delta), |
|
5672 |
+ direction: Math.sign(delta), |
|
5673 |
+ raw: event |
|
5674 |
+ }; // Keep the most recent events |
|
5675 |
+ |
|
5676 |
+ var recentWheelEvents = swiper.mousewheel.recentWheelEvents; |
|
5677 |
+ |
|
5678 |
+ if (recentWheelEvents.length >= 2) { |
|
5679 |
+ recentWheelEvents.shift(); // only store the last N events |
|
5680 |
+ } |
|
5681 |
+ |
|
5682 |
+ var prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined; |
|
5683 |
+ recentWheelEvents.push(newEvent); // If there is at least one previous recorded event: |
|
5684 |
+ // If direction has changed or |
|
5685 |
+ // if the scroll is quicker than the previous one: |
|
5686 |
+ // Animate the slider. |
|
5687 |
+ // Else (this is the first time the wheel is moved): |
|
5688 |
+ // Animate the slider. |
|
5689 |
+ |
|
5690 |
+ if (prevEvent) { |
|
5691 |
+ if (newEvent.direction !== prevEvent.direction || newEvent.delta > prevEvent.delta || newEvent.time > prevEvent.time + 150) { |
|
5692 |
+ swiper.mousewheel.animateSlider(newEvent); |
|
5693 |
+ } |
|
5694 |
+ } else { |
|
5695 |
+ swiper.mousewheel.animateSlider(newEvent); |
|
5696 |
+ } // If it's time to release the scroll: |
|
5697 |
+ // Return now so you don't hit the preventDefault. |
|
5698 |
+ |
|
5699 |
+ |
|
5700 |
+ if (swiper.mousewheel.releaseScroll(newEvent)) { |
|
5701 |
+ return true; |
|
5702 |
+ } |
|
5703 |
+ } else { |
|
5704 |
+ // Freemode or scrollContainer: |
|
5705 |
+ // If we recently snapped after a momentum scroll, then ignore wheel events |
|
5706 |
+ // to give time for the deceleration to finish. Stop ignoring after 500 msecs |
|
5707 |
+ // or if it's a new scroll (larger delta or inverse sign as last event before |
|
5708 |
+ // an end-of-momentum snap). |
|
5709 |
+ var _newEvent = { |
|
5710 |
+ time: now(), |
|
5711 |
+ delta: Math.abs(delta), |
|
5712 |
+ direction: Math.sign(delta) |
|
5713 |
+ }; |
|
5714 |
+ var lastEventBeforeSnap = swiper.mousewheel.lastEventBeforeSnap; |
|
5715 |
+ var ignoreWheelEvents = lastEventBeforeSnap && _newEvent.time < lastEventBeforeSnap.time + 500 && _newEvent.delta <= lastEventBeforeSnap.delta && _newEvent.direction === lastEventBeforeSnap.direction; |
|
5716 |
+ |
|
5717 |
+ if (!ignoreWheelEvents) { |
|
5718 |
+ swiper.mousewheel.lastEventBeforeSnap = undefined; |
|
5719 |
+ |
|
5720 |
+ if (swiper.params.loop) { |
|
5721 |
+ swiper.loopFix(); |
|
5722 |
+ } |
|
5723 |
+ |
|
5724 |
+ var position = swiper.getTranslate() + delta * params.sensitivity; |
|
5725 |
+ var wasBeginning = swiper.isBeginning; |
|
5726 |
+ var wasEnd = swiper.isEnd; |
|
5727 |
+ if (position >= swiper.minTranslate()) position = swiper.minTranslate(); |
|
5728 |
+ if (position <= swiper.maxTranslate()) position = swiper.maxTranslate(); |
|
5729 |
+ swiper.setTransition(0); |
|
5730 |
+ swiper.setTranslate(position); |
|
5731 |
+ swiper.updateProgress(); |
|
5732 |
+ swiper.updateActiveIndex(); |
|
5733 |
+ swiper.updateSlidesClasses(); |
|
5734 |
+ |
|
5735 |
+ if (!wasBeginning && swiper.isBeginning || !wasEnd && swiper.isEnd) { |
|
5736 |
+ swiper.updateSlidesClasses(); |
|
5737 |
+ } |
|
5738 |
+ |
|
5739 |
+ if (swiper.params.freeModeSticky) { |
|
5740 |
+ // When wheel scrolling starts with sticky (aka snap) enabled, then detect |
|
5741 |
+ // the end of a momentum scroll by storing recent (N=15?) wheel events. |
|
5742 |
+ // 1. do all N events have decreasing or same (absolute value) delta? |
|
5743 |
+ // 2. did all N events arrive in the last M (M=500?) msecs? |
|
5744 |
+ // 3. does the earliest event have an (absolute value) delta that's |
|
5745 |
+ // at least P (P=1?) larger than the most recent event's delta? |
|
5746 |
+ // 4. does the latest event have a delta that's smaller than Q (Q=6?) pixels? |
|
5747 |
+ // If 1-4 are "yes" then we're near the end of a momentum scroll deceleration. |
|
5748 |
+ // Snap immediately and ignore remaining wheel events in this scroll. |
|
5749 |
+ // See comment above for "remaining wheel events in this scroll" determination. |
|
5750 |
+ // If 1-4 aren't satisfied, then wait to snap until 500ms after the last event. |
|
5751 |
+ clearTimeout(swiper.mousewheel.timeout); |
|
5752 |
+ swiper.mousewheel.timeout = undefined; |
|
5753 |
+ var _recentWheelEvents = swiper.mousewheel.recentWheelEvents; |
|
5754 |
+ |
|
5755 |
+ if (_recentWheelEvents.length >= 15) { |
|
5756 |
+ _recentWheelEvents.shift(); // only store the last N events |
|
5757 |
+ |
|
5758 |
+ } |
|
5759 |
+ |
|
5760 |
+ var _prevEvent = _recentWheelEvents.length ? _recentWheelEvents[_recentWheelEvents.length - 1] : undefined; |
|
5761 |
+ |
|
5762 |
+ var firstEvent = _recentWheelEvents[0]; |
|
5763 |
+ |
|
5764 |
+ _recentWheelEvents.push(_newEvent); |
|
5765 |
+ |
|
5766 |
+ if (_prevEvent && (_newEvent.delta > _prevEvent.delta || _newEvent.direction !== _prevEvent.direction)) { |
|
5767 |
+ // Increasing or reverse-sign delta means the user started scrolling again. Clear the wheel event log. |
|
5768 |
+ _recentWheelEvents.splice(0); |
|
5769 |
+ } else if (_recentWheelEvents.length >= 15 && _newEvent.time - firstEvent.time < 500 && firstEvent.delta - _newEvent.delta >= 1 && _newEvent.delta <= 6) { |
|
5770 |
+ // We're at the end of the deceleration of a momentum scroll, so there's no need |
|
5771 |
+ // to wait for more events. Snap ASAP on the next tick. |
|
5772 |
+ // Also, because there's some remaining momentum we'll bias the snap in the |
|
5773 |
+ // direction of the ongoing scroll because it's better UX for the scroll to snap |
|
5774 |
+ // in the same direction as the scroll instead of reversing to snap. Therefore, |
|
5775 |
+ // if it's already scrolled more than 20% in the current direction, keep going. |
|
5776 |
+ var snapToThreshold = delta > 0 ? 0.8 : 0.2; |
|
5777 |
+ swiper.mousewheel.lastEventBeforeSnap = _newEvent; |
|
5778 |
+ |
|
5779 |
+ _recentWheelEvents.splice(0); |
|
5780 |
+ |
|
5781 |
+ swiper.mousewheel.timeout = nextTick(function () { |
|
5782 |
+ swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold); |
|
5783 |
+ }, 0); // no delay; move on next tick |
|
5784 |
+ } |
|
5785 |
+ |
|
5786 |
+ if (!swiper.mousewheel.timeout) { |
|
5787 |
+ // if we get here, then we haven't detected the end of a momentum scroll, so |
|
5788 |
+ // we'll consider a scroll "complete" when there haven't been any wheel events |
|
5789 |
+ // for 500ms. |
|
5790 |
+ swiper.mousewheel.timeout = nextTick(function () { |
|
5791 |
+ var snapToThreshold = 0.5; |
|
5792 |
+ swiper.mousewheel.lastEventBeforeSnap = _newEvent; |
|
5793 |
+ |
|
5794 |
+ _recentWheelEvents.splice(0); |
|
5795 |
+ |
|
5796 |
+ swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold); |
|
5797 |
+ }, 500); |
|
5798 |
+ } |
|
5799 |
+ } // Emit event |
|
5800 |
+ |
|
5801 |
+ |
|
5802 |
+ if (!ignoreWheelEvents) swiper.emit('scroll', e); // Stop autoplay |
|
5803 |
+ |
|
5804 |
+ if (swiper.params.autoplay && swiper.params.autoplayDisableOnInteraction) swiper.autoplay.stop(); // Return page scroll on edge positions |
|
5805 |
+ |
|
5806 |
+ if (position === swiper.minTranslate() || position === swiper.maxTranslate()) return true; |
|
5807 |
+ } |
|
5808 |
+ } |
|
5809 |
+ |
|
5810 |
+ if (e.preventDefault) e.preventDefault();else e.returnValue = false; |
|
5811 |
+ return false; |
|
5812 |
+ }, |
|
5813 |
+ animateSlider: function animateSlider(newEvent) { |
|
5814 |
+ var swiper = this; |
|
5815 |
+ var window = getWindow(); |
|
5816 |
+ |
|
5817 |
+ if (this.params.mousewheel.thresholdDelta && newEvent.delta < this.params.mousewheel.thresholdDelta) { |
|
5818 |
+ // Prevent if delta of wheel scroll delta is below configured threshold |
|
5819 |
+ return false; |
|
5820 |
+ } |
|
5821 |
+ |
|
5822 |
+ if (this.params.mousewheel.thresholdTime && now() - swiper.mousewheel.lastScrollTime < this.params.mousewheel.thresholdTime) { |
|
5823 |
+ // Prevent if time between scrolls is below configured threshold |
|
5824 |
+ return false; |
|
5825 |
+ } // If the movement is NOT big enough and |
|
5826 |
+ // if the last time the user scrolled was too close to the current one (avoid continuously triggering the slider): |
|
5827 |
+ // Don't go any further (avoid insignificant scroll movement). |
|
5828 |
+ |
|
5829 |
+ |
|
5830 |
+ if (newEvent.delta >= 6 && now() - swiper.mousewheel.lastScrollTime < 60) { |
|
5831 |
+ // Return false as a default |
|
5832 |
+ return true; |
|
5833 |
+ } // If user is scrolling towards the end: |
|
5834 |
+ // If the slider hasn't hit the latest slide or |
|
5835 |
+ // if the slider is a loop and |
|
5836 |
+ // if the slider isn't moving right now: |
|
5837 |
+ // Go to next slide and |
|
5838 |
+ // emit a scroll event. |
|
5839 |
+ // Else (the user is scrolling towards the beginning) and |
|
5840 |
+ // if the slider hasn't hit the first slide or |
|
5841 |
+ // if the slider is a loop and |
|
5842 |
+ // if the slider isn't moving right now: |
|
5843 |
+ // Go to prev slide and |
|
5844 |
+ // emit a scroll event. |
|
5845 |
+ |
|
5846 |
+ |
|
5847 |
+ if (newEvent.direction < 0) { |
|
5848 |
+ if ((!swiper.isEnd || swiper.params.loop) && !swiper.animating) { |
|
5849 |
+ swiper.slideNext(); |
|
5850 |
+ swiper.emit('scroll', newEvent.raw); |
|
5851 |
+ } |
|
5852 |
+ } else if ((!swiper.isBeginning || swiper.params.loop) && !swiper.animating) { |
|
5853 |
+ swiper.slidePrev(); |
|
5854 |
+ swiper.emit('scroll', newEvent.raw); |
|
5855 |
+ } // If you got here is because an animation has been triggered so store the current time |
|
5856 |
+ |
|
5857 |
+ |
|
5858 |
+ swiper.mousewheel.lastScrollTime = new window.Date().getTime(); // Return false as a default |
|
5859 |
+ |
|
5860 |
+ return false; |
|
5861 |
+ }, |
|
5862 |
+ releaseScroll: function releaseScroll(newEvent) { |
|
5863 |
+ var swiper = this; |
|
5864 |
+ var params = swiper.params.mousewheel; |
|
5865 |
+ |
|
5866 |
+ if (newEvent.direction < 0) { |
|
5867 |
+ if (swiper.isEnd && !swiper.params.loop && params.releaseOnEdges) { |
|
5868 |
+ // Return true to animate scroll on edges |
|
5869 |
+ return true; |
|
5870 |
+ } |
|
5871 |
+ } else if (swiper.isBeginning && !swiper.params.loop && params.releaseOnEdges) { |
|
5872 |
+ // Return true to animate scroll on edges |
|
5873 |
+ return true; |
|
5874 |
+ } |
|
5875 |
+ |
|
5876 |
+ return false; |
|
5877 |
+ }, |
|
5878 |
+ enable: function enable() { |
|
5879 |
+ var swiper = this; |
|
5880 |
+ var event = Mousewheel.event(); |
|
5881 |
+ |
|
5882 |
+ if (swiper.params.cssMode) { |
|
5883 |
+ swiper.wrapperEl.removeEventListener(event, swiper.mousewheel.handle); |
|
5884 |
+ return true; |
|
5885 |
+ } |
|
5886 |
+ |
|
5887 |
+ if (!event) return false; |
|
5888 |
+ if (swiper.mousewheel.enabled) return false; |
|
5889 |
+ var target = swiper.$el; |
|
5890 |
+ |
|
5891 |
+ if (swiper.params.mousewheel.eventsTarget !== 'container') { |
|
5892 |
+ target = $(swiper.params.mousewheel.eventsTarget); |
|
5893 |
+ } |
|
5894 |
+ |
|
5895 |
+ target.on('mouseenter', swiper.mousewheel.handleMouseEnter); |
|
5896 |
+ target.on('mouseleave', swiper.mousewheel.handleMouseLeave); |
|
5897 |
+ target.on(event, swiper.mousewheel.handle); |
|
5898 |
+ swiper.mousewheel.enabled = true; |
|
5899 |
+ return true; |
|
5900 |
+ }, |
|
5901 |
+ disable: function disable() { |
|
5902 |
+ var swiper = this; |
|
5903 |
+ var event = Mousewheel.event(); |
|
5904 |
+ |
|
5905 |
+ if (swiper.params.cssMode) { |
|
5906 |
+ swiper.wrapperEl.addEventListener(event, swiper.mousewheel.handle); |
|
5907 |
+ return true; |
|
5908 |
+ } |
|
5909 |
+ |
|
5910 |
+ if (!event) return false; |
|
5911 |
+ if (!swiper.mousewheel.enabled) return false; |
|
5912 |
+ var target = swiper.$el; |
|
5913 |
+ |
|
5914 |
+ if (swiper.params.mousewheel.eventsTarget !== 'container') { |
|
5915 |
+ target = $(swiper.params.mousewheel.eventsTarget); |
|
5916 |
+ } |
|
5917 |
+ |
|
5918 |
+ target.off(event, swiper.mousewheel.handle); |
|
5919 |
+ swiper.mousewheel.enabled = false; |
|
5920 |
+ return true; |
|
5921 |
+ } |
|
5922 |
+}; |
|
5923 |
+var Mousewheel$1 = { |
|
5924 |
+ name: 'mousewheel', |
|
5925 |
+ params: { |
|
5926 |
+ mousewheel: { |
|
5927 |
+ enabled: false, |
|
5928 |
+ releaseOnEdges: false, |
|
5929 |
+ invert: false, |
|
5930 |
+ forceToAxis: false, |
|
5931 |
+ sensitivity: 1, |
|
5932 |
+ eventsTarget: 'container', |
|
5933 |
+ thresholdDelta: null, |
|
5934 |
+ thresholdTime: null |
|
5935 |
+ } |
|
5936 |
+ }, |
|
5937 |
+ create: function create() { |
|
5938 |
+ var swiper = this; |
|
5939 |
+ bindModuleMethods(swiper, { |
|
5940 |
+ mousewheel: { |
|
5941 |
+ enabled: false, |
|
5942 |
+ lastScrollTime: now(), |
|
5943 |
+ lastEventBeforeSnap: undefined, |
|
5944 |
+ recentWheelEvents: [], |
|
5945 |
+ enable: Mousewheel.enable, |
|
5946 |
+ disable: Mousewheel.disable, |
|
5947 |
+ handle: Mousewheel.handle, |
|
5948 |
+ handleMouseEnter: Mousewheel.handleMouseEnter, |
|
5949 |
+ handleMouseLeave: Mousewheel.handleMouseLeave, |
|
5950 |
+ animateSlider: Mousewheel.animateSlider, |
|
5951 |
+ releaseScroll: Mousewheel.releaseScroll |
|
5952 |
+ } |
|
5953 |
+ }); |
|
5954 |
+ }, |
|
5955 |
+ on: { |
|
5956 |
+ init: function init(swiper) { |
|
5957 |
+ if (!swiper.params.mousewheel.enabled && swiper.params.cssMode) { |
|
5958 |
+ swiper.mousewheel.disable(); |
|
5959 |
+ } |
|
5960 |
+ |
|
5961 |
+ if (swiper.params.mousewheel.enabled) swiper.mousewheel.enable(); |
|
5962 |
+ }, |
|
5963 |
+ destroy: function destroy(swiper) { |
|
5964 |
+ if (swiper.params.cssMode) { |
|
5965 |
+ swiper.mousewheel.enable(); |
|
5966 |
+ } |
|
5967 |
+ |
|
5968 |
+ if (swiper.mousewheel.enabled) swiper.mousewheel.disable(); |
|
5969 |
+ } |
|
5970 |
+ } |
|
5971 |
+}; |
|
5972 |
+ |
|
5973 |
+var Navigation = { |
|
5974 |
+ update: function update() { |
|
5975 |
+ // Update Navigation Buttons |
|
5976 |
+ var swiper = this; |
|
5977 |
+ var params = swiper.params.navigation; |
|
5978 |
+ if (swiper.params.loop) return; |
|
5979 |
+ var _swiper$navigation = swiper.navigation, |
|
5980 |
+ $nextEl = _swiper$navigation.$nextEl, |
|
5981 |
+ $prevEl = _swiper$navigation.$prevEl; |
|
5982 |
+ |
|
5983 |
+ if ($prevEl && $prevEl.length > 0) { |
|
5984 |
+ if (swiper.isBeginning) { |
|
5985 |
+ $prevEl.addClass(params.disabledClass); |
|
5986 |
+ } else { |
|
5987 |
+ $prevEl.removeClass(params.disabledClass); |
|
5988 |
+ } |
|
5989 |
+ |
|
5990 |
+ $prevEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); |
|
5991 |
+ } |
|
5992 |
+ |
|
5993 |
+ if ($nextEl && $nextEl.length > 0) { |
|
5994 |
+ if (swiper.isEnd) { |
|
5995 |
+ $nextEl.addClass(params.disabledClass); |
|
5996 |
+ } else { |
|
5997 |
+ $nextEl.removeClass(params.disabledClass); |
|
5998 |
+ } |
|
5999 |
+ |
|
6000 |
+ $nextEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); |
|
6001 |
+ } |
|
6002 |
+ }, |
|
6003 |
+ onPrevClick: function onPrevClick(e) { |
|
6004 |
+ var swiper = this; |
|
6005 |
+ e.preventDefault(); |
|
6006 |
+ if (swiper.isBeginning && !swiper.params.loop) return; |
|
6007 |
+ swiper.slidePrev(); |
|
6008 |
+ }, |
|
6009 |
+ onNextClick: function onNextClick(e) { |
|
6010 |
+ var swiper = this; |
|
6011 |
+ e.preventDefault(); |
|
6012 |
+ if (swiper.isEnd && !swiper.params.loop) return; |
|
6013 |
+ swiper.slideNext(); |
|
6014 |
+ }, |
|
6015 |
+ init: function init() { |
|
6016 |
+ var swiper = this; |
|
6017 |
+ var params = swiper.params.navigation; |
|
6018 |
+ if (!(params.nextEl || params.prevEl)) return; |
|
6019 |
+ var $nextEl; |
|
6020 |
+ var $prevEl; |
|
6021 |
+ |
|
6022 |
+ if (params.nextEl) { |
|
6023 |
+ $nextEl = $(params.nextEl); |
|
6024 |
+ |
|
6025 |
+ if (swiper.params.uniqueNavElements && typeof params.nextEl === 'string' && $nextEl.length > 1 && swiper.$el.find(params.nextEl).length === 1) { |
|
6026 |
+ $nextEl = swiper.$el.find(params.nextEl); |
|
6027 |
+ } |
|
6028 |
+ } |
|
6029 |
+ |
|
6030 |
+ if (params.prevEl) { |
|
6031 |
+ $prevEl = $(params.prevEl); |
|
6032 |
+ |
|
6033 |
+ if (swiper.params.uniqueNavElements && typeof params.prevEl === 'string' && $prevEl.length > 1 && swiper.$el.find(params.prevEl).length === 1) { |
|
6034 |
+ $prevEl = swiper.$el.find(params.prevEl); |
|
6035 |
+ } |
|
6036 |
+ } |
|
6037 |
+ |
|
6038 |
+ if ($nextEl && $nextEl.length > 0) { |
|
6039 |
+ $nextEl.on('click', swiper.navigation.onNextClick); |
|
6040 |
+ } |
|
6041 |
+ |
|
6042 |
+ if ($prevEl && $prevEl.length > 0) { |
|
6043 |
+ $prevEl.on('click', swiper.navigation.onPrevClick); |
|
6044 |
+ } |
|
6045 |
+ |
|
6046 |
+ extend$1(swiper.navigation, { |
|
6047 |
+ $nextEl: $nextEl, |
|
6048 |
+ nextEl: $nextEl && $nextEl[0], |
|
6049 |
+ $prevEl: $prevEl, |
|
6050 |
+ prevEl: $prevEl && $prevEl[0] |
|
6051 |
+ }); |
|
6052 |
+ }, |
|
6053 |
+ destroy: function destroy() { |
|
6054 |
+ var swiper = this; |
|
6055 |
+ var _swiper$navigation2 = swiper.navigation, |
|
6056 |
+ $nextEl = _swiper$navigation2.$nextEl, |
|
6057 |
+ $prevEl = _swiper$navigation2.$prevEl; |
|
6058 |
+ |
|
6059 |
+ if ($nextEl && $nextEl.length) { |
|
6060 |
+ $nextEl.off('click', swiper.navigation.onNextClick); |
|
6061 |
+ $nextEl.removeClass(swiper.params.navigation.disabledClass); |
|
6062 |
+ } |
|
6063 |
+ |
|
6064 |
+ if ($prevEl && $prevEl.length) { |
|
6065 |
+ $prevEl.off('click', swiper.navigation.onPrevClick); |
|
6066 |
+ $prevEl.removeClass(swiper.params.navigation.disabledClass); |
|
6067 |
+ } |
|
6068 |
+ } |
|
6069 |
+}; |
|
6070 |
+var Navigation$1 = { |
|
6071 |
+ name: 'navigation', |
|
6072 |
+ params: { |
|
6073 |
+ navigation: { |
|
6074 |
+ nextEl: null, |
|
6075 |
+ prevEl: null, |
|
6076 |
+ hideOnClick: false, |
|
6077 |
+ disabledClass: 'swiper-button-disabled', |
|
6078 |
+ hiddenClass: 'swiper-button-hidden', |
|
6079 |
+ lockClass: 'swiper-button-lock' |
|
6080 |
+ } |
|
6081 |
+ }, |
|
6082 |
+ create: function create() { |
|
6083 |
+ var swiper = this; |
|
6084 |
+ bindModuleMethods(swiper, { |
|
6085 |
+ navigation: _extends({}, Navigation) |
|
6086 |
+ }); |
|
6087 |
+ }, |
|
6088 |
+ on: { |
|
6089 |
+ init: function init(swiper) { |
|
6090 |
+ swiper.navigation.init(); |
|
6091 |
+ swiper.navigation.update(); |
|
6092 |
+ }, |
|
6093 |
+ toEdge: function toEdge(swiper) { |
|
6094 |
+ swiper.navigation.update(); |
|
6095 |
+ }, |
|
6096 |
+ fromEdge: function fromEdge(swiper) { |
|
6097 |
+ swiper.navigation.update(); |
|
6098 |
+ }, |
|
6099 |
+ destroy: function destroy(swiper) { |
|
6100 |
+ swiper.navigation.destroy(); |
|
6101 |
+ }, |
|
6102 |
+ click: function click(swiper, e) { |
|
6103 |
+ var _swiper$navigation3 = swiper.navigation, |
|
6104 |
+ $nextEl = _swiper$navigation3.$nextEl, |
|
6105 |
+ $prevEl = _swiper$navigation3.$prevEl; |
|
6106 |
+ |
|
6107 |
+ if (swiper.params.navigation.hideOnClick && !$(e.target).is($prevEl) && !$(e.target).is($nextEl)) { |
|
6108 |
+ var isHidden; |
|
6109 |
+ |
|
6110 |
+ if ($nextEl) { |
|
6111 |
+ isHidden = $nextEl.hasClass(swiper.params.navigation.hiddenClass); |
|
6112 |
+ } else if ($prevEl) { |
|
6113 |
+ isHidden = $prevEl.hasClass(swiper.params.navigation.hiddenClass); |
|
6114 |
+ } |
|
6115 |
+ |
|
6116 |
+ if (isHidden === true) { |
|
6117 |
+ swiper.emit('navigationShow'); |
|
6118 |
+ } else { |
|
6119 |
+ swiper.emit('navigationHide'); |
|
6120 |
+ } |
|
6121 |
+ |
|
6122 |
+ if ($nextEl) { |
|
6123 |
+ $nextEl.toggleClass(swiper.params.navigation.hiddenClass); |
|
6124 |
+ } |
|
6125 |
+ |
|
6126 |
+ if ($prevEl) { |
|
6127 |
+ $prevEl.toggleClass(swiper.params.navigation.hiddenClass); |
|
6128 |
+ } |
|
6129 |
+ } |
|
6130 |
+ } |
|
6131 |
+ } |
|
6132 |
+}; |
|
6133 |
+ |
|
6134 |
+var Pagination = { |
|
6135 |
+ update: function update() { |
|
6136 |
+ // Render || Update Pagination bullets/items |
|
6137 |
+ var swiper = this; |
|
6138 |
+ var rtl = swiper.rtl; |
|
6139 |
+ var params = swiper.params.pagination; |
|
6140 |
+ if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) return; |
|
6141 |
+ var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; |
|
6142 |
+ var $el = swiper.pagination.$el; // Current/Total |
|
6143 |
+ |
|
6144 |
+ var current; |
|
6145 |
+ var total = swiper.params.loop ? Math.ceil((slidesLength - swiper.loopedSlides * 2) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; |
|
6146 |
+ |
|
6147 |
+ if (swiper.params.loop) { |
|
6148 |
+ current = Math.ceil((swiper.activeIndex - swiper.loopedSlides) / swiper.params.slidesPerGroup); |
|
6149 |
+ |
|
6150 |
+ if (current > slidesLength - 1 - swiper.loopedSlides * 2) { |
|
6151 |
+ current -= slidesLength - swiper.loopedSlides * 2; |
|
6152 |
+ } |
|
6153 |
+ |
|
6154 |
+ if (current > total - 1) current -= total; |
|
6155 |
+ if (current < 0 && swiper.params.paginationType !== 'bullets') current = total + current; |
|
6156 |
+ } else if (typeof swiper.snapIndex !== 'undefined') { |
|
6157 |
+ current = swiper.snapIndex; |
|
6158 |
+ } else { |
|
6159 |
+ current = swiper.activeIndex || 0; |
|
6160 |
+ } // Types |
|
6161 |
+ |
|
6162 |
+ |
|
6163 |
+ if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) { |
|
6164 |
+ var bullets = swiper.pagination.bullets; |
|
6165 |
+ var firstIndex; |
|
6166 |
+ var lastIndex; |
|
6167 |
+ var midIndex; |
|
6168 |
+ |
|
6169 |
+ if (params.dynamicBullets) { |
|
6170 |
+ swiper.pagination.bulletSize = bullets.eq(0)[swiper.isHorizontal() ? 'outerWidth' : 'outerHeight'](true); |
|
6171 |
+ $el.css(swiper.isHorizontal() ? 'width' : 'height', swiper.pagination.bulletSize * (params.dynamicMainBullets + 4) + "px"); |
|
6172 |
+ |
|
6173 |
+ if (params.dynamicMainBullets > 1 && swiper.previousIndex !== undefined) { |
|
6174 |
+ swiper.pagination.dynamicBulletIndex += current - swiper.previousIndex; |
|
6175 |
+ |
|
6176 |
+ if (swiper.pagination.dynamicBulletIndex > params.dynamicMainBullets - 1) { |
|
6177 |
+ swiper.pagination.dynamicBulletIndex = params.dynamicMainBullets - 1; |
|
6178 |
+ } else if (swiper.pagination.dynamicBulletIndex < 0) { |
|
6179 |
+ swiper.pagination.dynamicBulletIndex = 0; |
|
6180 |
+ } |
|
6181 |
+ } |
|
6182 |
+ |
|
6183 |
+ firstIndex = current - swiper.pagination.dynamicBulletIndex; |
|
6184 |
+ lastIndex = firstIndex + (Math.min(bullets.length, params.dynamicMainBullets) - 1); |
|
6185 |
+ midIndex = (lastIndex + firstIndex) / 2; |
|
6186 |
+ } |
|
6187 |
+ |
|
6188 |
+ bullets.removeClass(params.bulletActiveClass + " " + params.bulletActiveClass + "-next " + params.bulletActiveClass + "-next-next " + params.bulletActiveClass + "-prev " + params.bulletActiveClass + "-prev-prev " + params.bulletActiveClass + "-main"); |
|
6189 |
+ |
|
6190 |
+ if ($el.length > 1) { |
|
6191 |
+ bullets.each(function (bullet) { |
|
6192 |
+ var $bullet = $(bullet); |
|
6193 |
+ var bulletIndex = $bullet.index(); |
|
6194 |
+ |
|
6195 |
+ if (bulletIndex === current) { |
|
6196 |
+ $bullet.addClass(params.bulletActiveClass); |
|
6197 |
+ } |
|
6198 |
+ |
|
6199 |
+ if (params.dynamicBullets) { |
|
6200 |
+ if (bulletIndex >= firstIndex && bulletIndex <= lastIndex) { |
|
6201 |
+ $bullet.addClass(params.bulletActiveClass + "-main"); |
|
6202 |
+ } |
|
6203 |
+ |
|
6204 |
+ if (bulletIndex === firstIndex) { |
|
6205 |
+ $bullet.prev().addClass(params.bulletActiveClass + "-prev").prev().addClass(params.bulletActiveClass + "-prev-prev"); |
|
6206 |
+ } |
|
6207 |
+ |
|
6208 |
+ if (bulletIndex === lastIndex) { |
|
6209 |
+ $bullet.next().addClass(params.bulletActiveClass + "-next").next().addClass(params.bulletActiveClass + "-next-next"); |
|
6210 |
+ } |
|
6211 |
+ } |
|
6212 |
+ }); |
|
6213 |
+ } else { |
|
6214 |
+ var $bullet = bullets.eq(current); |
|
6215 |
+ var bulletIndex = $bullet.index(); |
|
6216 |
+ $bullet.addClass(params.bulletActiveClass); |
|
6217 |
+ |
|
6218 |
+ if (params.dynamicBullets) { |
|
6219 |
+ var $firstDisplayedBullet = bullets.eq(firstIndex); |
|
6220 |
+ var $lastDisplayedBullet = bullets.eq(lastIndex); |
|
6221 |
+ |
|
6222 |
+ for (var i = firstIndex; i <= lastIndex; i += 1) { |
|
6223 |
+ bullets.eq(i).addClass(params.bulletActiveClass + "-main"); |
|
6224 |
+ } |
|
6225 |
+ |
|
6226 |
+ if (swiper.params.loop) { |
|
6227 |
+ if (bulletIndex >= bullets.length - params.dynamicMainBullets) { |
|
6228 |
+ for (var _i = params.dynamicMainBullets; _i >= 0; _i -= 1) { |
|
6229 |
+ bullets.eq(bullets.length - _i).addClass(params.bulletActiveClass + "-main"); |
|
6230 |
+ } |
|
6231 |
+ |
|
6232 |
+ bullets.eq(bullets.length - params.dynamicMainBullets - 1).addClass(params.bulletActiveClass + "-prev"); |
|
6233 |
+ } else { |
|
6234 |
+ $firstDisplayedBullet.prev().addClass(params.bulletActiveClass + "-prev").prev().addClass(params.bulletActiveClass + "-prev-prev"); |
|
6235 |
+ $lastDisplayedBullet.next().addClass(params.bulletActiveClass + "-next").next().addClass(params.bulletActiveClass + "-next-next"); |
|
6236 |
+ } |
|
6237 |
+ } else { |
|
6238 |
+ $firstDisplayedBullet.prev().addClass(params.bulletActiveClass + "-prev").prev().addClass(params.bulletActiveClass + "-prev-prev"); |
|
6239 |
+ $lastDisplayedBullet.next().addClass(params.bulletActiveClass + "-next").next().addClass(params.bulletActiveClass + "-next-next"); |
|
6240 |
+ } |
|
6241 |
+ } |
|
6242 |
+ } |
|
6243 |
+ |
|
6244 |
+ if (params.dynamicBullets) { |
|
6245 |
+ var dynamicBulletsLength = Math.min(bullets.length, params.dynamicMainBullets + 4); |
|
6246 |
+ var bulletsOffset = (swiper.pagination.bulletSize * dynamicBulletsLength - swiper.pagination.bulletSize) / 2 - midIndex * swiper.pagination.bulletSize; |
|
6247 |
+ var offsetProp = rtl ? 'right' : 'left'; |
|
6248 |
+ bullets.css(swiper.isHorizontal() ? offsetProp : 'top', bulletsOffset + "px"); |
|
6249 |
+ } |
|
6250 |
+ } |
|
6251 |
+ |
|
6252 |
+ if (params.type === 'fraction') { |
|
6253 |
+ $el.find("." + params.currentClass).text(params.formatFractionCurrent(current + 1)); |
|
6254 |
+ $el.find("." + params.totalClass).text(params.formatFractionTotal(total)); |
|
6255 |
+ } |
|
6256 |
+ |
|
6257 |
+ if (params.type === 'progressbar') { |
|
6258 |
+ var progressbarDirection; |
|
6259 |
+ |
|
6260 |
+ if (params.progressbarOpposite) { |
|
6261 |
+ progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal'; |
|
6262 |
+ } else { |
|
6263 |
+ progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical'; |
|
6264 |
+ } |
|
6265 |
+ |
|
6266 |
+ var scale = (current + 1) / total; |
|
6267 |
+ var scaleX = 1; |
|
6268 |
+ var scaleY = 1; |
|
6269 |
+ |
|
6270 |
+ if (progressbarDirection === 'horizontal') { |
|
6271 |
+ scaleX = scale; |
|
6272 |
+ } else { |
|
6273 |
+ scaleY = scale; |
|
6274 |
+ } |
|
6275 |
+ |
|
6276 |
+ $el.find("." + params.progressbarFillClass).transform("translate3d(0,0,0) scaleX(" + scaleX + ") scaleY(" + scaleY + ")").transition(swiper.params.speed); |
|
6277 |
+ } |
|
6278 |
+ |
|
6279 |
+ if (params.type === 'custom' && params.renderCustom) { |
|
6280 |
+ $el.html(params.renderCustom(swiper, current + 1, total)); |
|
6281 |
+ swiper.emit('paginationRender', $el[0]); |
|
6282 |
+ } else { |
|
6283 |
+ swiper.emit('paginationUpdate', $el[0]); |
|
6284 |
+ } |
|
6285 |
+ |
|
6286 |
+ $el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); |
|
6287 |
+ }, |
|
6288 |
+ render: function render() { |
|
6289 |
+ // Render Container |
|
6290 |
+ var swiper = this; |
|
6291 |
+ var params = swiper.params.pagination; |
|
6292 |
+ if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) return; |
|
6293 |
+ var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; |
|
6294 |
+ var $el = swiper.pagination.$el; |
|
6295 |
+ var paginationHTML = ''; |
|
6296 |
+ |
|
6297 |
+ if (params.type === 'bullets') { |
|
6298 |
+ var numberOfBullets = swiper.params.loop ? Math.ceil((slidesLength - swiper.loopedSlides * 2) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; |
|
6299 |
+ |
|
6300 |
+ for (var i = 0; i < numberOfBullets; i += 1) { |
|
6301 |
+ if (params.renderBullet) { |
|
6302 |
+ paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass); |
|
6303 |
+ } else { |
|
6304 |
+ paginationHTML += "<" + params.bulletElement + " class=\"" + params.bulletClass + "\"></" + params.bulletElement + ">"; |
|
6305 |
+ } |
|
6306 |
+ } |
|
6307 |
+ |
|
6308 |
+ $el.html(paginationHTML); |
|
6309 |
+ swiper.pagination.bullets = $el.find("." + params.bulletClass); |
|
6310 |
+ } |
|
6311 |
+ |
|
6312 |
+ if (params.type === 'fraction') { |
|
6313 |
+ if (params.renderFraction) { |
|
6314 |
+ paginationHTML = params.renderFraction.call(swiper, params.currentClass, params.totalClass); |
|
6315 |
+ } else { |
|
6316 |
+ paginationHTML = "<span class=\"" + params.currentClass + "\"></span>" + ' / ' + ("<span class=\"" + params.totalClass + "\"></span>"); |
|
6317 |
+ } |
|
6318 |
+ |
|
6319 |
+ $el.html(paginationHTML); |
|
6320 |
+ } |
|
6321 |
+ |
|
6322 |
+ if (params.type === 'progressbar') { |
|
6323 |
+ if (params.renderProgressbar) { |
|
6324 |
+ paginationHTML = params.renderProgressbar.call(swiper, params.progressbarFillClass); |
|
6325 |
+ } else { |
|
6326 |
+ paginationHTML = "<span class=\"" + params.progressbarFillClass + "\"></span>"; |
|
6327 |
+ } |
|
6328 |
+ |
|
6329 |
+ $el.html(paginationHTML); |
|
6330 |
+ } |
|
6331 |
+ |
|
6332 |
+ if (params.type !== 'custom') { |
|
6333 |
+ swiper.emit('paginationRender', swiper.pagination.$el[0]); |
|
6334 |
+ } |
|
6335 |
+ }, |
|
6336 |
+ init: function init() { |
|
6337 |
+ var swiper = this; |
|
6338 |
+ var params = swiper.params.pagination; |
|
6339 |
+ if (!params.el) return; |
|
6340 |
+ var $el = $(params.el); |
|
6341 |
+ if ($el.length === 0) return; |
|
6342 |
+ |
|
6343 |
+ if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1) { |
|
6344 |
+ $el = swiper.$el.find(params.el); |
|
6345 |
+ } |
|
6346 |
+ |
|
6347 |
+ if (params.type === 'bullets' && params.clickable) { |
|
6348 |
+ $el.addClass(params.clickableClass); |
|
6349 |
+ } |
|
6350 |
+ |
|
6351 |
+ $el.addClass(params.modifierClass + params.type); |
|
6352 |
+ |
|
6353 |
+ if (params.type === 'bullets' && params.dynamicBullets) { |
|
6354 |
+ $el.addClass("" + params.modifierClass + params.type + "-dynamic"); |
|
6355 |
+ swiper.pagination.dynamicBulletIndex = 0; |
|
6356 |
+ |
|
6357 |
+ if (params.dynamicMainBullets < 1) { |
|
6358 |
+ params.dynamicMainBullets = 1; |
|
6359 |
+ } |
|
6360 |
+ } |
|
6361 |
+ |
|
6362 |
+ if (params.type === 'progressbar' && params.progressbarOpposite) { |
|
6363 |
+ $el.addClass(params.progressbarOppositeClass); |
|
6364 |
+ } |
|
6365 |
+ |
|
6366 |
+ if (params.clickable) { |
|
6367 |
+ $el.on('click', "." + params.bulletClass, function onClick(e) { |
|
6368 |
+ e.preventDefault(); |
|
6369 |
+ var index = $(this).index() * swiper.params.slidesPerGroup; |
|
6370 |
+ if (swiper.params.loop) index += swiper.loopedSlides; |
|
6371 |
+ swiper.slideTo(index); |
|
6372 |
+ }); |
|
6373 |
+ } |
|
6374 |
+ |
|
6375 |
+ extend$1(swiper.pagination, { |
|
6376 |
+ $el: $el, |
|
6377 |
+ el: $el[0] |
|
6378 |
+ }); |
|
6379 |
+ }, |
|
6380 |
+ destroy: function destroy() { |
|
6381 |
+ var swiper = this; |
|
6382 |
+ var params = swiper.params.pagination; |
|
6383 |
+ if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) return; |
|
6384 |
+ var $el = swiper.pagination.$el; |
|
6385 |
+ $el.removeClass(params.hiddenClass); |
|
6386 |
+ $el.removeClass(params.modifierClass + params.type); |
|
6387 |
+ if (swiper.pagination.bullets) swiper.pagination.bullets.removeClass(params.bulletActiveClass); |
|
6388 |
+ |
|
6389 |
+ if (params.clickable) { |
|
6390 |
+ $el.off('click', "." + params.bulletClass); |
|
6391 |
+ } |
|
6392 |
+ } |
|
6393 |
+}; |
|
6394 |
+var Pagination$1 = { |
|
6395 |
+ name: 'pagination', |
|
6396 |
+ params: { |
|
6397 |
+ pagination: { |
|
6398 |
+ el: null, |
|
6399 |
+ bulletElement: 'span', |
|
6400 |
+ clickable: false, |
|
6401 |
+ hideOnClick: false, |
|
6402 |
+ renderBullet: null, |
|
6403 |
+ renderProgressbar: null, |
|
6404 |
+ renderFraction: null, |
|
6405 |
+ renderCustom: null, |
|
6406 |
+ progressbarOpposite: false, |
|
6407 |
+ type: 'bullets', |
|
6408 |
+ // 'bullets' or 'progressbar' or 'fraction' or 'custom' |
|
6409 |
+ dynamicBullets: false, |
|
6410 |
+ dynamicMainBullets: 1, |
|
6411 |
+ formatFractionCurrent: function formatFractionCurrent(number) { |
|
6412 |
+ return number; |
|
6413 |
+ }, |
|
6414 |
+ formatFractionTotal: function formatFractionTotal(number) { |
|
6415 |
+ return number; |
|
6416 |
+ }, |
|
6417 |
+ bulletClass: 'swiper-pagination-bullet', |
|
6418 |
+ bulletActiveClass: 'swiper-pagination-bullet-active', |
|
6419 |
+ modifierClass: 'swiper-pagination-', |
|
6420 |
+ // NEW |
|
6421 |
+ currentClass: 'swiper-pagination-current', |
|
6422 |
+ totalClass: 'swiper-pagination-total', |
|
6423 |
+ hiddenClass: 'swiper-pagination-hidden', |
|
6424 |
+ progressbarFillClass: 'swiper-pagination-progressbar-fill', |
|
6425 |
+ progressbarOppositeClass: 'swiper-pagination-progressbar-opposite', |
|
6426 |
+ clickableClass: 'swiper-pagination-clickable', |
|
6427 |
+ // NEW |
|
6428 |
+ lockClass: 'swiper-pagination-lock' |
|
6429 |
+ } |
|
6430 |
+ }, |
|
6431 |
+ create: function create() { |
|
6432 |
+ var swiper = this; |
|
6433 |
+ bindModuleMethods(swiper, { |
|
6434 |
+ pagination: _extends({ |
|
6435 |
+ dynamicBulletIndex: 0 |
|
6436 |
+ }, Pagination) |
|
6437 |
+ }); |
|
6438 |
+ }, |
|
6439 |
+ on: { |
|
6440 |
+ init: function init(swiper) { |
|
6441 |
+ swiper.pagination.init(); |
|
6442 |
+ swiper.pagination.render(); |
|
6443 |
+ swiper.pagination.update(); |
|
6444 |
+ }, |
|
6445 |
+ activeIndexChange: function activeIndexChange(swiper) { |
|
6446 |
+ if (swiper.params.loop) { |
|
6447 |
+ swiper.pagination.update(); |
|
6448 |
+ } else if (typeof swiper.snapIndex === 'undefined') { |
|
6449 |
+ swiper.pagination.update(); |
|
6450 |
+ } |
|
6451 |
+ }, |
|
6452 |
+ snapIndexChange: function snapIndexChange(swiper) { |
|
6453 |
+ if (!swiper.params.loop) { |
|
6454 |
+ swiper.pagination.update(); |
|
6455 |
+ } |
|
6456 |
+ }, |
|
6457 |
+ slidesLengthChange: function slidesLengthChange(swiper) { |
|
6458 |
+ if (swiper.params.loop) { |
|
6459 |
+ swiper.pagination.render(); |
|
6460 |
+ swiper.pagination.update(); |
|
6461 |
+ } |
|
6462 |
+ }, |
|
6463 |
+ snapGridLengthChange: function snapGridLengthChange(swiper) { |
|
6464 |
+ if (!swiper.params.loop) { |
|
6465 |
+ swiper.pagination.render(); |
|
6466 |
+ swiper.pagination.update(); |
|
6467 |
+ } |
|
6468 |
+ }, |
|
6469 |
+ destroy: function destroy(swiper) { |
|
6470 |
+ swiper.pagination.destroy(); |
|
6471 |
+ }, |
|
6472 |
+ click: function click(swiper, e) { |
|
6473 |
+ if (swiper.params.pagination.el && swiper.params.pagination.hideOnClick && swiper.pagination.$el.length > 0 && !$(e.target).hasClass(swiper.params.pagination.bulletClass)) { |
|
6474 |
+ var isHidden = swiper.pagination.$el.hasClass(swiper.params.pagination.hiddenClass); |
|
6475 |
+ |
|
6476 |
+ if (isHidden === true) { |
|
6477 |
+ swiper.emit('paginationShow'); |
|
6478 |
+ } else { |
|
6479 |
+ swiper.emit('paginationHide'); |
|
6480 |
+ } |
|
6481 |
+ |
|
6482 |
+ swiper.pagination.$el.toggleClass(swiper.params.pagination.hiddenClass); |
|
6483 |
+ } |
|
6484 |
+ } |
|
6485 |
+ } |
|
6486 |
+}; |
|
6487 |
+ |
|
6488 |
+var Scrollbar = { |
|
6489 |
+ setTranslate: function setTranslate() { |
|
6490 |
+ var swiper = this; |
|
6491 |
+ if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; |
|
6492 |
+ var scrollbar = swiper.scrollbar, |
|
6493 |
+ rtl = swiper.rtlTranslate, |
|
6494 |
+ progress = swiper.progress; |
|
6495 |
+ var dragSize = scrollbar.dragSize, |
|
6496 |
+ trackSize = scrollbar.trackSize, |
|
6497 |
+ $dragEl = scrollbar.$dragEl, |
|
6498 |
+ $el = scrollbar.$el; |
|
6499 |
+ var params = swiper.params.scrollbar; |
|
6500 |
+ var newSize = dragSize; |
|
6501 |
+ var newPos = (trackSize - dragSize) * progress; |
|
6502 |
+ |
|
6503 |
+ if (rtl) { |
|
6504 |
+ newPos = -newPos; |
|
6505 |
+ |
|
6506 |
+ if (newPos > 0) { |
|
6507 |
+ newSize = dragSize - newPos; |
|
6508 |
+ newPos = 0; |
|
6509 |
+ } else if (-newPos + dragSize > trackSize) { |
|
6510 |
+ newSize = trackSize + newPos; |
|
6511 |
+ } |
|
6512 |
+ } else if (newPos < 0) { |
|
6513 |
+ newSize = dragSize + newPos; |
|
6514 |
+ newPos = 0; |
|
6515 |
+ } else if (newPos + dragSize > trackSize) { |
|
6516 |
+ newSize = trackSize - newPos; |
|
6517 |
+ } |
|
6518 |
+ |
|
6519 |
+ if (swiper.isHorizontal()) { |
|
6520 |
+ $dragEl.transform("translate3d(" + newPos + "px, 0, 0)"); |
|
6521 |
+ $dragEl[0].style.width = newSize + "px"; |
|
6522 |
+ } else { |
|
6523 |
+ $dragEl.transform("translate3d(0px, " + newPos + "px, 0)"); |
|
6524 |
+ $dragEl[0].style.height = newSize + "px"; |
|
6525 |
+ } |
|
6526 |
+ |
|
6527 |
+ if (params.hide) { |
|
6528 |
+ clearTimeout(swiper.scrollbar.timeout); |
|
6529 |
+ $el[0].style.opacity = 1; |
|
6530 |
+ swiper.scrollbar.timeout = setTimeout(function () { |
|
6531 |
+ $el[0].style.opacity = 0; |
|
6532 |
+ $el.transition(400); |
|
6533 |
+ }, 1000); |
|
6534 |
+ } |
|
6535 |
+ }, |
|
6536 |
+ setTransition: function setTransition(duration) { |
|
6537 |
+ var swiper = this; |
|
6538 |
+ if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; |
|
6539 |
+ swiper.scrollbar.$dragEl.transition(duration); |
|
6540 |
+ }, |
|
6541 |
+ updateSize: function updateSize() { |
|
6542 |
+ var swiper = this; |
|
6543 |
+ if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; |
|
6544 |
+ var scrollbar = swiper.scrollbar; |
|
6545 |
+ var $dragEl = scrollbar.$dragEl, |
|
6546 |
+ $el = scrollbar.$el; |
|
6547 |
+ $dragEl[0].style.width = ''; |
|
6548 |
+ $dragEl[0].style.height = ''; |
|
6549 |
+ var trackSize = swiper.isHorizontal() ? $el[0].offsetWidth : $el[0].offsetHeight; |
|
6550 |
+ var divider = swiper.size / swiper.virtualSize; |
|
6551 |
+ var moveDivider = divider * (trackSize / swiper.size); |
|
6552 |
+ var dragSize; |
|
6553 |
+ |
|
6554 |
+ if (swiper.params.scrollbar.dragSize === 'auto') { |
|
6555 |
+ dragSize = trackSize * divider; |
|
6556 |
+ } else { |
|
6557 |
+ dragSize = parseInt(swiper.params.scrollbar.dragSize, 10); |
|
6558 |
+ } |
|
6559 |
+ |
|
6560 |
+ if (swiper.isHorizontal()) { |
|
6561 |
+ $dragEl[0].style.width = dragSize + "px"; |
|
6562 |
+ } else { |
|
6563 |
+ $dragEl[0].style.height = dragSize + "px"; |
|
6564 |
+ } |
|
6565 |
+ |
|
6566 |
+ if (divider >= 1) { |
|
6567 |
+ $el[0].style.display = 'none'; |
|
6568 |
+ } else { |
|
6569 |
+ $el[0].style.display = ''; |
|
6570 |
+ } |
|
6571 |
+ |
|
6572 |
+ if (swiper.params.scrollbar.hide) { |
|
6573 |
+ $el[0].style.opacity = 0; |
|
6574 |
+ } |
|
6575 |
+ |
|
6576 |
+ extend$1(scrollbar, { |
|
6577 |
+ trackSize: trackSize, |
|
6578 |
+ divider: divider, |
|
6579 |
+ moveDivider: moveDivider, |
|
6580 |
+ dragSize: dragSize |
|
6581 |
+ }); |
|
6582 |
+ scrollbar.$el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](swiper.params.scrollbar.lockClass); |
|
6583 |
+ }, |
|
6584 |
+ getPointerPosition: function getPointerPosition(e) { |
|
6585 |
+ var swiper = this; |
|
6586 |
+ |
|
6587 |
+ if (swiper.isHorizontal()) { |
|
6588 |
+ return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientX : e.clientX; |
|
6589 |
+ } |
|
6590 |
+ |
|
6591 |
+ return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientY : e.clientY; |
|
6592 |
+ }, |
|
6593 |
+ setDragPosition: function setDragPosition(e) { |
|
6594 |
+ var swiper = this; |
|
6595 |
+ var scrollbar = swiper.scrollbar, |
|
6596 |
+ rtl = swiper.rtlTranslate; |
|
6597 |
+ var $el = scrollbar.$el, |
|
6598 |
+ dragSize = scrollbar.dragSize, |
|
6599 |
+ trackSize = scrollbar.trackSize, |
|
6600 |
+ dragStartPos = scrollbar.dragStartPos; |
|
6601 |
+ var positionRatio; |
|
6602 |
+ positionRatio = (scrollbar.getPointerPosition(e) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top'] - (dragStartPos !== null ? dragStartPos : dragSize / 2)) / (trackSize - dragSize); |
|
6603 |
+ positionRatio = Math.max(Math.min(positionRatio, 1), 0); |
|
6604 |
+ |
|
6605 |
+ if (rtl) { |
|
6606 |
+ positionRatio = 1 - positionRatio; |
|
6607 |
+ } |
|
6608 |
+ |
|
6609 |
+ var position = swiper.minTranslate() + (swiper.maxTranslate() - swiper.minTranslate()) * positionRatio; |
|
6610 |
+ swiper.updateProgress(position); |
|
6611 |
+ swiper.setTranslate(position); |
|
6612 |
+ swiper.updateActiveIndex(); |
|
6613 |
+ swiper.updateSlidesClasses(); |
|
6614 |
+ }, |
|
6615 |
+ onDragStart: function onDragStart(e) { |
|
6616 |
+ var swiper = this; |
|
6617 |
+ var params = swiper.params.scrollbar; |
|
6618 |
+ var scrollbar = swiper.scrollbar, |
|
6619 |
+ $wrapperEl = swiper.$wrapperEl; |
|
6620 |
+ var $el = scrollbar.$el, |
|
6621 |
+ $dragEl = scrollbar.$dragEl; |
|
6622 |
+ swiper.scrollbar.isTouched = true; |
|
6623 |
+ swiper.scrollbar.dragStartPos = e.target === $dragEl[0] || e.target === $dragEl ? scrollbar.getPointerPosition(e) - e.target.getBoundingClientRect()[swiper.isHorizontal() ? 'left' : 'top'] : null; |
|
6624 |
+ e.preventDefault(); |
|
6625 |
+ e.stopPropagation(); |
|
6626 |
+ $wrapperEl.transition(100); |
|
6627 |
+ $dragEl.transition(100); |
|
6628 |
+ scrollbar.setDragPosition(e); |
|
6629 |
+ clearTimeout(swiper.scrollbar.dragTimeout); |
|
6630 |
+ $el.transition(0); |
|
6631 |
+ |
|
6632 |
+ if (params.hide) { |
|
6633 |
+ $el.css('opacity', 1); |
|
6634 |
+ } |
|
6635 |
+ |
|
6636 |
+ if (swiper.params.cssMode) { |
|
6637 |
+ swiper.$wrapperEl.css('scroll-snap-type', 'none'); |
|
6638 |
+ } |
|
6639 |
+ |
|
6640 |
+ swiper.emit('scrollbarDragStart', e); |
|
6641 |
+ }, |
|
6642 |
+ onDragMove: function onDragMove(e) { |
|
6643 |
+ var swiper = this; |
|
6644 |
+ var scrollbar = swiper.scrollbar, |
|
6645 |
+ $wrapperEl = swiper.$wrapperEl; |
|
6646 |
+ var $el = scrollbar.$el, |
|
6647 |
+ $dragEl = scrollbar.$dragEl; |
|
6648 |
+ if (!swiper.scrollbar.isTouched) return; |
|
6649 |
+ if (e.preventDefault) e.preventDefault();else e.returnValue = false; |
|
6650 |
+ scrollbar.setDragPosition(e); |
|
6651 |
+ $wrapperEl.transition(0); |
|
6652 |
+ $el.transition(0); |
|
6653 |
+ $dragEl.transition(0); |
|
6654 |
+ swiper.emit('scrollbarDragMove', e); |
|
6655 |
+ }, |
|
6656 |
+ onDragEnd: function onDragEnd(e) { |
|
6657 |
+ var swiper = this; |
|
6658 |
+ var params = swiper.params.scrollbar; |
|
6659 |
+ var scrollbar = swiper.scrollbar, |
|
6660 |
+ $wrapperEl = swiper.$wrapperEl; |
|
6661 |
+ var $el = scrollbar.$el; |
|
6662 |
+ if (!swiper.scrollbar.isTouched) return; |
|
6663 |
+ swiper.scrollbar.isTouched = false; |
|
6664 |
+ |
|
6665 |
+ if (swiper.params.cssMode) { |
|
6666 |
+ swiper.$wrapperEl.css('scroll-snap-type', ''); |
|
6667 |
+ $wrapperEl.transition(''); |
|
6668 |
+ } |
|
6669 |
+ |
|
6670 |
+ if (params.hide) { |
|
6671 |
+ clearTimeout(swiper.scrollbar.dragTimeout); |
|
6672 |
+ swiper.scrollbar.dragTimeout = nextTick(function () { |
|
6673 |
+ $el.css('opacity', 0); |
|
6674 |
+ $el.transition(400); |
|
6675 |
+ }, 1000); |
|
6676 |
+ } |
|
6677 |
+ |
|
6678 |
+ swiper.emit('scrollbarDragEnd', e); |
|
6679 |
+ |
|
6680 |
+ if (params.snapOnRelease) { |
|
6681 |
+ swiper.slideToClosest(); |
|
6682 |
+ } |
|
6683 |
+ }, |
|
6684 |
+ enableDraggable: function enableDraggable() { |
|
6685 |
+ var swiper = this; |
|
6686 |
+ if (!swiper.params.scrollbar.el) return; |
|
6687 |
+ var document = getDocument(); |
|
6688 |
+ var scrollbar = swiper.scrollbar, |
|
6689 |
+ touchEventsTouch = swiper.touchEventsTouch, |
|
6690 |
+ touchEventsDesktop = swiper.touchEventsDesktop, |
|
6691 |
+ params = swiper.params, |
|
6692 |
+ support = swiper.support; |
|
6693 |
+ var $el = scrollbar.$el; |
|
6694 |
+ var target = $el[0]; |
|
6695 |
+ var activeListener = support.passiveListener && params.passiveListeners ? { |
|
6696 |
+ passive: false, |
|
6697 |
+ capture: false |
|
6698 |
+ } : false; |
|
6699 |
+ var passiveListener = support.passiveListener && params.passiveListeners ? { |
|
6700 |
+ passive: true, |
|
6701 |
+ capture: false |
|
6702 |
+ } : false; |
|
6703 |
+ |
|
6704 |
+ if (!support.touch) { |
|
6705 |
+ target.addEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener); |
|
6706 |
+ document.addEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener); |
|
6707 |
+ document.addEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener); |
|
6708 |
+ } else { |
|
6709 |
+ target.addEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener); |
|
6710 |
+ target.addEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener); |
|
6711 |
+ target.addEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener); |
|
6712 |
+ } |
|
6713 |
+ }, |
|
6714 |
+ disableDraggable: function disableDraggable() { |
|
6715 |
+ var swiper = this; |
|
6716 |
+ if (!swiper.params.scrollbar.el) return; |
|
6717 |
+ var document = getDocument(); |
|
6718 |
+ var scrollbar = swiper.scrollbar, |
|
6719 |
+ touchEventsTouch = swiper.touchEventsTouch, |
|
6720 |
+ touchEventsDesktop = swiper.touchEventsDesktop, |
|
6721 |
+ params = swiper.params, |
|
6722 |
+ support = swiper.support; |
|
6723 |
+ var $el = scrollbar.$el; |
|
6724 |
+ var target = $el[0]; |
|
6725 |
+ var activeListener = support.passiveListener && params.passiveListeners ? { |
|
6726 |
+ passive: false, |
|
6727 |
+ capture: false |
|
6728 |
+ } : false; |
|
6729 |
+ var passiveListener = support.passiveListener && params.passiveListeners ? { |
|
6730 |
+ passive: true, |
|
6731 |
+ capture: false |
|
6732 |
+ } : false; |
|
6733 |
+ |
|
6734 |
+ if (!support.touch) { |
|
6735 |
+ target.removeEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener); |
|
6736 |
+ document.removeEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener); |
|
6737 |
+ document.removeEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener); |
|
6738 |
+ } else { |
|
6739 |
+ target.removeEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener); |
|
6740 |
+ target.removeEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener); |
|
6741 |
+ target.removeEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener); |
|
6742 |
+ } |
|
6743 |
+ }, |
|
6744 |
+ init: function init() { |
|
6745 |
+ var swiper = this; |
|
6746 |
+ if (!swiper.params.scrollbar.el) return; |
|
6747 |
+ var scrollbar = swiper.scrollbar, |
|
6748 |
+ $swiperEl = swiper.$el; |
|
6749 |
+ var params = swiper.params.scrollbar; |
|
6750 |
+ var $el = $(params.el); |
|
6751 |
+ |
|
6752 |
+ if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) { |
|
6753 |
+ $el = $swiperEl.find(params.el); |
|
6754 |
+ } |
|
6755 |
+ |
|
6756 |
+ var $dragEl = $el.find("." + swiper.params.scrollbar.dragClass); |
|
6757 |
+ |
|
6758 |
+ if ($dragEl.length === 0) { |
|
6759 |
+ $dragEl = $("<div class=\"" + swiper.params.scrollbar.dragClass + "\"></div>"); |
|
6760 |
+ $el.append($dragEl); |
|
6761 |
+ } |
|
6762 |
+ |
|
6763 |
+ extend$1(scrollbar, { |
|
6764 |
+ $el: $el, |
|
6765 |
+ el: $el[0], |
|
6766 |
+ $dragEl: $dragEl, |
|
6767 |
+ dragEl: $dragEl[0] |
|
6768 |
+ }); |
|
6769 |
+ |
|
6770 |
+ if (params.draggable) { |
|
6771 |
+ scrollbar.enableDraggable(); |
|
6772 |
+ } |
|
6773 |
+ }, |
|
6774 |
+ destroy: function destroy() { |
|
6775 |
+ var swiper = this; |
|
6776 |
+ swiper.scrollbar.disableDraggable(); |
|
6777 |
+ } |
|
6778 |
+}; |
|
6779 |
+var Scrollbar$1 = { |
|
6780 |
+ name: 'scrollbar', |
|
6781 |
+ params: { |
|
6782 |
+ scrollbar: { |
|
6783 |
+ el: null, |
|
6784 |
+ dragSize: 'auto', |
|
6785 |
+ hide: false, |
|
6786 |
+ draggable: false, |
|
6787 |
+ snapOnRelease: true, |
|
6788 |
+ lockClass: 'swiper-scrollbar-lock', |
|
6789 |
+ dragClass: 'swiper-scrollbar-drag' |
|
6790 |
+ } |
|
6791 |
+ }, |
|
6792 |
+ create: function create() { |
|
6793 |
+ var swiper = this; |
|
6794 |
+ bindModuleMethods(swiper, { |
|
6795 |
+ scrollbar: _extends({ |
|
6796 |
+ isTouched: false, |
|
6797 |
+ timeout: null, |
|
6798 |
+ dragTimeout: null |
|
6799 |
+ }, Scrollbar) |
|
6800 |
+ }); |
|
6801 |
+ }, |
|
6802 |
+ on: { |
|
6803 |
+ init: function init(swiper) { |
|
6804 |
+ swiper.scrollbar.init(); |
|
6805 |
+ swiper.scrollbar.updateSize(); |
|
6806 |
+ swiper.scrollbar.setTranslate(); |
|
6807 |
+ }, |
|
6808 |
+ update: function update(swiper) { |
|
6809 |
+ swiper.scrollbar.updateSize(); |
|
6810 |
+ }, |
|
6811 |
+ resize: function resize(swiper) { |
|
6812 |
+ swiper.scrollbar.updateSize(); |
|
6813 |
+ }, |
|
6814 |
+ observerUpdate: function observerUpdate(swiper) { |
|
6815 |
+ swiper.scrollbar.updateSize(); |
|
6816 |
+ }, |
|
6817 |
+ setTranslate: function setTranslate(swiper) { |
|
6818 |
+ swiper.scrollbar.setTranslate(); |
|
6819 |
+ }, |
|
6820 |
+ setTransition: function setTransition(swiper, duration) { |
|
6821 |
+ swiper.scrollbar.setTransition(duration); |
|
6822 |
+ }, |
|
6823 |
+ destroy: function destroy(swiper) { |
|
6824 |
+ swiper.scrollbar.destroy(); |
|
6825 |
+ } |
|
6826 |
+ } |
|
6827 |
+}; |
|
6828 |
+ |
|
6829 |
+var Parallax = { |
|
6830 |
+ setTransform: function setTransform(el, progress) { |
|
6831 |
+ var swiper = this; |
|
6832 |
+ var rtl = swiper.rtl; |
|
6833 |
+ var $el = $(el); |
|
6834 |
+ var rtlFactor = rtl ? -1 : 1; |
|
6835 |
+ var p = $el.attr('data-swiper-parallax') || '0'; |
|
6836 |
+ var x = $el.attr('data-swiper-parallax-x'); |
|
6837 |
+ var y = $el.attr('data-swiper-parallax-y'); |
|
6838 |
+ var scale = $el.attr('data-swiper-parallax-scale'); |
|
6839 |
+ var opacity = $el.attr('data-swiper-parallax-opacity'); |
|
6840 |
+ |
|
6841 |
+ if (x || y) { |
|
6842 |
+ x = x || '0'; |
|
6843 |
+ y = y || '0'; |
|
6844 |
+ } else if (swiper.isHorizontal()) { |
|
6845 |
+ x = p; |
|
6846 |
+ y = '0'; |
|
6847 |
+ } else { |
|
6848 |
+ y = p; |
|
6849 |
+ x = '0'; |
|
6850 |
+ } |
|
6851 |
+ |
|
6852 |
+ if (x.indexOf('%') >= 0) { |
|
6853 |
+ x = parseInt(x, 10) * progress * rtlFactor + "%"; |
|
6854 |
+ } else { |
|
6855 |
+ x = x * progress * rtlFactor + "px"; |
|
6856 |
+ } |
|
6857 |
+ |
|
6858 |
+ if (y.indexOf('%') >= 0) { |
|
6859 |
+ y = parseInt(y, 10) * progress + "%"; |
|
6860 |
+ } else { |
|
6861 |
+ y = y * progress + "px"; |
|
6862 |
+ } |
|
6863 |
+ |
|
6864 |
+ if (typeof opacity !== 'undefined' && opacity !== null) { |
|
6865 |
+ var currentOpacity = opacity - (opacity - 1) * (1 - Math.abs(progress)); |
|
6866 |
+ $el[0].style.opacity = currentOpacity; |
|
6867 |
+ } |
|
6868 |
+ |
|
6869 |
+ if (typeof scale === 'undefined' || scale === null) { |
|
6870 |
+ $el.transform("translate3d(" + x + ", " + y + ", 0px)"); |
|
6871 |
+ } else { |
|
6872 |
+ var currentScale = scale - (scale - 1) * (1 - Math.abs(progress)); |
|
6873 |
+ $el.transform("translate3d(" + x + ", " + y + ", 0px) scale(" + currentScale + ")"); |
|
6874 |
+ } |
|
6875 |
+ }, |
|
6876 |
+ setTranslate: function setTranslate() { |
|
6877 |
+ var swiper = this; |
|
6878 |
+ var $el = swiper.$el, |
|
6879 |
+ slides = swiper.slides, |
|
6880 |
+ progress = swiper.progress, |
|
6881 |
+ snapGrid = swiper.snapGrid; |
|
6882 |
+ $el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(function (el) { |
|
6883 |
+ swiper.parallax.setTransform(el, progress); |
|
6884 |
+ }); |
|
6885 |
+ slides.each(function (slideEl, slideIndex) { |
|
6886 |
+ var slideProgress = slideEl.progress; |
|
6887 |
+ |
|
6888 |
+ if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') { |
|
6889 |
+ slideProgress += Math.ceil(slideIndex / 2) - progress * (snapGrid.length - 1); |
|
6890 |
+ } |
|
6891 |
+ |
|
6892 |
+ slideProgress = Math.min(Math.max(slideProgress, -1), 1); |
|
6893 |
+ $(slideEl).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(function (el) { |
|
6894 |
+ swiper.parallax.setTransform(el, slideProgress); |
|
6895 |
+ }); |
|
6896 |
+ }); |
|
6897 |
+ }, |
|
6898 |
+ setTransition: function setTransition(duration) { |
|
6899 |
+ if (duration === void 0) { |
|
6900 |
+ duration = this.params.speed; |
|
6901 |
+ } |
|
6902 |
+ |
|
6903 |
+ var swiper = this; |
|
6904 |
+ var $el = swiper.$el; |
|
6905 |
+ $el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(function (parallaxEl) { |
|
6906 |
+ var $parallaxEl = $(parallaxEl); |
|
6907 |
+ var parallaxDuration = parseInt($parallaxEl.attr('data-swiper-parallax-duration'), 10) || duration; |
|
6908 |
+ if (duration === 0) parallaxDuration = 0; |
|
6909 |
+ $parallaxEl.transition(parallaxDuration); |
|
6910 |
+ }); |
|
6911 |
+ } |
|
6912 |
+}; |
|
6913 |
+var Parallax$1 = { |
|
6914 |
+ name: 'parallax', |
|
6915 |
+ params: { |
|
6916 |
+ parallax: { |
|
6917 |
+ enabled: false |
|
6918 |
+ } |
|
6919 |
+ }, |
|
6920 |
+ create: function create() { |
|
6921 |
+ var swiper = this; |
|
6922 |
+ bindModuleMethods(swiper, { |
|
6923 |
+ parallax: _extends({}, Parallax) |
|
6924 |
+ }); |
|
6925 |
+ }, |
|
6926 |
+ on: { |
|
6927 |
+ beforeInit: function beforeInit(swiper) { |
|
6928 |
+ if (!swiper.params.parallax.enabled) return; |
|
6929 |
+ swiper.params.watchSlidesProgress = true; |
|
6930 |
+ swiper.originalParams.watchSlidesProgress = true; |
|
6931 |
+ }, |
|
6932 |
+ init: function init(swiper) { |
|
6933 |
+ if (!swiper.params.parallax.enabled) return; |
|
6934 |
+ swiper.parallax.setTranslate(); |
|
6935 |
+ }, |
|
6936 |
+ setTranslate: function setTranslate(swiper) { |
|
6937 |
+ if (!swiper.params.parallax.enabled) return; |
|
6938 |
+ swiper.parallax.setTranslate(); |
|
6939 |
+ }, |
|
6940 |
+ setTransition: function setTransition(swiper, duration) { |
|
6941 |
+ if (!swiper.params.parallax.enabled) return; |
|
6942 |
+ swiper.parallax.setTransition(duration); |
|
6943 |
+ } |
|
6944 |
+ } |
|
6945 |
+}; |
|
6946 |
+ |
|
6947 |
+var Zoom = { |
|
6948 |
+ // Calc Scale From Multi-touches |
|
6949 |
+ getDistanceBetweenTouches: function getDistanceBetweenTouches(e) { |
|
6950 |
+ if (e.targetTouches.length < 2) return 1; |
|
6951 |
+ var x1 = e.targetTouches[0].pageX; |
|
6952 |
+ var y1 = e.targetTouches[0].pageY; |
|
6953 |
+ var x2 = e.targetTouches[1].pageX; |
|
6954 |
+ var y2 = e.targetTouches[1].pageY; |
|
6955 |
+ var distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)); |
|
6956 |
+ return distance; |
|
6957 |
+ }, |
|
6958 |
+ // Events |
|
6959 |
+ onGestureStart: function onGestureStart(e) { |
|
6960 |
+ var swiper = this; |
|
6961 |
+ var support = swiper.support; |
|
6962 |
+ var params = swiper.params.zoom; |
|
6963 |
+ var zoom = swiper.zoom; |
|
6964 |
+ var gesture = zoom.gesture; |
|
6965 |
+ zoom.fakeGestureTouched = false; |
|
6966 |
+ zoom.fakeGestureMoved = false; |
|
6967 |
+ |
|
6968 |
+ if (!support.gestures) { |
|
6969 |
+ if (e.type !== 'touchstart' || e.type === 'touchstart' && e.targetTouches.length < 2) { |
|
6970 |
+ return; |
|
6971 |
+ } |
|
6972 |
+ |
|
6973 |
+ zoom.fakeGestureTouched = true; |
|
6974 |
+ gesture.scaleStart = Zoom.getDistanceBetweenTouches(e); |
|
6975 |
+ } |
|
6976 |
+ |
|
6977 |
+ if (!gesture.$slideEl || !gesture.$slideEl.length) { |
|
6978 |
+ gesture.$slideEl = $(e.target).closest("." + swiper.params.slideClass); |
|
6979 |
+ if (gesture.$slideEl.length === 0) gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); |
|
6980 |
+ gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target'); |
|
6981 |
+ gesture.$imageWrapEl = gesture.$imageEl.parent("." + params.containerClass); |
|
6982 |
+ gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; |
|
6983 |
+ |
|
6984 |
+ if (gesture.$imageWrapEl.length === 0) { |
|
6985 |
+ gesture.$imageEl = undefined; |
|
6986 |
+ return; |
|
6987 |
+ } |
|
6988 |
+ } |
|
6989 |
+ |
|
6990 |
+ if (gesture.$imageEl) { |
|
6991 |
+ gesture.$imageEl.transition(0); |
|
6992 |
+ } |
|
6993 |
+ |
|
6994 |
+ swiper.zoom.isScaling = true; |
|
6995 |
+ }, |
|
6996 |
+ onGestureChange: function onGestureChange(e) { |
|
6997 |
+ var swiper = this; |
|
6998 |
+ var support = swiper.support; |
|
6999 |
+ var params = swiper.params.zoom; |
|
7000 |
+ var zoom = swiper.zoom; |
|
7001 |
+ var gesture = zoom.gesture; |
|
7002 |
+ |
|
7003 |
+ if (!support.gestures) { |
|
7004 |
+ if (e.type !== 'touchmove' || e.type === 'touchmove' && e.targetTouches.length < 2) { |
|
7005 |
+ return; |
|
7006 |
+ } |
|
7007 |
+ |
|
7008 |
+ zoom.fakeGestureMoved = true; |
|
7009 |
+ gesture.scaleMove = Zoom.getDistanceBetweenTouches(e); |
|
7010 |
+ } |
|
7011 |
+ |
|
7012 |
+ if (!gesture.$imageEl || gesture.$imageEl.length === 0) { |
|
7013 |
+ if (e.type === 'gesturechange') zoom.onGestureStart(e); |
|
7014 |
+ return; |
|
7015 |
+ } |
|
7016 |
+ |
|
7017 |
+ if (support.gestures) { |
|
7018 |
+ zoom.scale = e.scale * zoom.currentScale; |
|
7019 |
+ } else { |
|
7020 |
+ zoom.scale = gesture.scaleMove / gesture.scaleStart * zoom.currentScale; |
|
7021 |
+ } |
|
7022 |
+ |
|
7023 |
+ if (zoom.scale > gesture.maxRatio) { |
|
7024 |
+ zoom.scale = gesture.maxRatio - 1 + Math.pow(zoom.scale - gesture.maxRatio + 1, 0.5); |
|
7025 |
+ } |
|
7026 |
+ |
|
7027 |
+ if (zoom.scale < params.minRatio) { |
|
7028 |
+ zoom.scale = params.minRatio + 1 - Math.pow(params.minRatio - zoom.scale + 1, 0.5); |
|
7029 |
+ } |
|
7030 |
+ |
|
7031 |
+ gesture.$imageEl.transform("translate3d(0,0,0) scale(" + zoom.scale + ")"); |
|
7032 |
+ }, |
|
7033 |
+ onGestureEnd: function onGestureEnd(e) { |
|
7034 |
+ var swiper = this; |
|
7035 |
+ var device = swiper.device; |
|
7036 |
+ var support = swiper.support; |
|
7037 |
+ var params = swiper.params.zoom; |
|
7038 |
+ var zoom = swiper.zoom; |
|
7039 |
+ var gesture = zoom.gesture; |
|
7040 |
+ |
|
7041 |
+ if (!support.gestures) { |
|
7042 |
+ if (!zoom.fakeGestureTouched || !zoom.fakeGestureMoved) { |
|
7043 |
+ return; |
|
7044 |
+ } |
|
7045 |
+ |
|
7046 |
+ if (e.type !== 'touchend' || e.type === 'touchend' && e.changedTouches.length < 2 && !device.android) { |
|
7047 |
+ return; |
|
7048 |
+ } |
|
7049 |
+ |
|
7050 |
+ zoom.fakeGestureTouched = false; |
|
7051 |
+ zoom.fakeGestureMoved = false; |
|
7052 |
+ } |
|
7053 |
+ |
|
7054 |
+ if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; |
|
7055 |
+ zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio); |
|
7056 |
+ gesture.$imageEl.transition(swiper.params.speed).transform("translate3d(0,0,0) scale(" + zoom.scale + ")"); |
|
7057 |
+ zoom.currentScale = zoom.scale; |
|
7058 |
+ zoom.isScaling = false; |
|
7059 |
+ if (zoom.scale === 1) gesture.$slideEl = undefined; |
|
7060 |
+ }, |
|
7061 |
+ onTouchStart: function onTouchStart(e) { |
|
7062 |
+ var swiper = this; |
|
7063 |
+ var device = swiper.device; |
|
7064 |
+ var zoom = swiper.zoom; |
|
7065 |
+ var gesture = zoom.gesture, |
|
7066 |
+ image = zoom.image; |
|
7067 |
+ if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; |
|
7068 |
+ if (image.isTouched) return; |
|
7069 |
+ if (device.android && e.cancelable) e.preventDefault(); |
|
7070 |
+ image.isTouched = true; |
|
7071 |
+ image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; |
|
7072 |
+ image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; |
|
7073 |
+ }, |
|
7074 |
+ onTouchMove: function onTouchMove(e) { |
|
7075 |
+ var swiper = this; |
|
7076 |
+ var zoom = swiper.zoom; |
|
7077 |
+ var gesture = zoom.gesture, |
|
7078 |
+ image = zoom.image, |
|
7079 |
+ velocity = zoom.velocity; |
|
7080 |
+ if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; |
|
7081 |
+ swiper.allowClick = false; |
|
7082 |
+ if (!image.isTouched || !gesture.$slideEl) return; |
|
7083 |
+ |
|
7084 |
+ if (!image.isMoved) { |
|
7085 |
+ image.width = gesture.$imageEl[0].offsetWidth; |
|
7086 |
+ image.height = gesture.$imageEl[0].offsetHeight; |
|
7087 |
+ image.startX = getTranslate(gesture.$imageWrapEl[0], 'x') || 0; |
|
7088 |
+ image.startY = getTranslate(gesture.$imageWrapEl[0], 'y') || 0; |
|
7089 |
+ gesture.slideWidth = gesture.$slideEl[0].offsetWidth; |
|
7090 |
+ gesture.slideHeight = gesture.$slideEl[0].offsetHeight; |
|
7091 |
+ gesture.$imageWrapEl.transition(0); |
|
7092 |
+ |
|
7093 |
+ if (swiper.rtl) { |
|
7094 |
+ image.startX = -image.startX; |
|
7095 |
+ image.startY = -image.startY; |
|
7096 |
+ } |
|
7097 |
+ } // Define if we need image drag |
|
7098 |
+ |
|
7099 |
+ |
|
7100 |
+ var scaledWidth = image.width * zoom.scale; |
|
7101 |
+ var scaledHeight = image.height * zoom.scale; |
|
7102 |
+ if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) return; |
|
7103 |
+ image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0); |
|
7104 |
+ image.maxX = -image.minX; |
|
7105 |
+ image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0); |
|
7106 |
+ image.maxY = -image.minY; |
|
7107 |
+ image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; |
|
7108 |
+ image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; |
|
7109 |
+ |
|
7110 |
+ if (!image.isMoved && !zoom.isScaling) { |
|
7111 |
+ if (swiper.isHorizontal() && (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x || Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x)) { |
|
7112 |
+ image.isTouched = false; |
|
7113 |
+ return; |
|
7114 |
+ } |
|
7115 |
+ |
|
7116 |
+ if (!swiper.isHorizontal() && (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y || Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y)) { |
|
7117 |
+ image.isTouched = false; |
|
7118 |
+ return; |
|
7119 |
+ } |
|
7120 |
+ } |
|
7121 |
+ |
|
7122 |
+ if (e.cancelable) { |
|
7123 |
+ e.preventDefault(); |
|
7124 |
+ } |
|
7125 |
+ |
|
7126 |
+ e.stopPropagation(); |
|
7127 |
+ image.isMoved = true; |
|
7128 |
+ image.currentX = image.touchesCurrent.x - image.touchesStart.x + image.startX; |
|
7129 |
+ image.currentY = image.touchesCurrent.y - image.touchesStart.y + image.startY; |
|
7130 |
+ |
|
7131 |
+ if (image.currentX < image.minX) { |
|
7132 |
+ image.currentX = image.minX + 1 - Math.pow(image.minX - image.currentX + 1, 0.8); |
|
7133 |
+ } |
|
7134 |
+ |
|
7135 |
+ if (image.currentX > image.maxX) { |
|
7136 |
+ image.currentX = image.maxX - 1 + Math.pow(image.currentX - image.maxX + 1, 0.8); |
|
7137 |
+ } |
|
7138 |
+ |
|
7139 |
+ if (image.currentY < image.minY) { |
|
7140 |
+ image.currentY = image.minY + 1 - Math.pow(image.minY - image.currentY + 1, 0.8); |
|
7141 |
+ } |
|
7142 |
+ |
|
7143 |
+ if (image.currentY > image.maxY) { |
|
7144 |
+ image.currentY = image.maxY - 1 + Math.pow(image.currentY - image.maxY + 1, 0.8); |
|
7145 |
+ } // Velocity |
|
7146 |
+ |
|
7147 |
+ |
|
7148 |
+ if (!velocity.prevPositionX) velocity.prevPositionX = image.touchesCurrent.x; |
|
7149 |
+ if (!velocity.prevPositionY) velocity.prevPositionY = image.touchesCurrent.y; |
|
7150 |
+ if (!velocity.prevTime) velocity.prevTime = Date.now(); |
|
7151 |
+ velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2; |
|
7152 |
+ velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2; |
|
7153 |
+ if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) velocity.x = 0; |
|
7154 |
+ if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) velocity.y = 0; |
|
7155 |
+ velocity.prevPositionX = image.touchesCurrent.x; |
|
7156 |
+ velocity.prevPositionY = image.touchesCurrent.y; |
|
7157 |
+ velocity.prevTime = Date.now(); |
|
7158 |
+ gesture.$imageWrapEl.transform("translate3d(" + image.currentX + "px, " + image.currentY + "px,0)"); |
|
7159 |
+ }, |
|
7160 |
+ onTouchEnd: function onTouchEnd() { |
|
7161 |
+ var swiper = this; |
|
7162 |
+ var zoom = swiper.zoom; |
|
7163 |
+ var gesture = zoom.gesture, |
|
7164 |
+ image = zoom.image, |
|
7165 |
+ velocity = zoom.velocity; |
|
7166 |
+ if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; |
|
7167 |
+ |
|
7168 |
+ if (!image.isTouched || !image.isMoved) { |
|
7169 |
+ image.isTouched = false; |
|
7170 |
+ image.isMoved = false; |
|
7171 |
+ return; |
|
7172 |
+ } |
|
7173 |
+ |
|
7174 |
+ image.isTouched = false; |
|
7175 |
+ image.isMoved = false; |
|
7176 |
+ var momentumDurationX = 300; |
|
7177 |
+ var momentumDurationY = 300; |
|
7178 |
+ var momentumDistanceX = velocity.x * momentumDurationX; |
|
7179 |
+ var newPositionX = image.currentX + momentumDistanceX; |
|
7180 |
+ var momentumDistanceY = velocity.y * momentumDurationY; |
|
7181 |
+ var newPositionY = image.currentY + momentumDistanceY; // Fix duration |
|
7182 |
+ |
|
7183 |
+ if (velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x); |
|
7184 |
+ if (velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y); |
|
7185 |
+ var momentumDuration = Math.max(momentumDurationX, momentumDurationY); |
|
7186 |
+ image.currentX = newPositionX; |
|
7187 |
+ image.currentY = newPositionY; // Define if we need image drag |
|
7188 |
+ |
|
7189 |
+ var scaledWidth = image.width * zoom.scale; |
|
7190 |
+ var scaledHeight = image.height * zoom.scale; |
|
7191 |
+ image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0); |
|
7192 |
+ image.maxX = -image.minX; |
|
7193 |
+ image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0); |
|
7194 |
+ image.maxY = -image.minY; |
|
7195 |
+ image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX); |
|
7196 |
+ image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY); |
|
7197 |
+ gesture.$imageWrapEl.transition(momentumDuration).transform("translate3d(" + image.currentX + "px, " + image.currentY + "px,0)"); |
|
7198 |
+ }, |
|
7199 |
+ onTransitionEnd: function onTransitionEnd() { |
|
7200 |
+ var swiper = this; |
|
7201 |
+ var zoom = swiper.zoom; |
|
7202 |
+ var gesture = zoom.gesture; |
|
7203 |
+ |
|
7204 |
+ if (gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex) { |
|
7205 |
+ if (gesture.$imageEl) { |
|
7206 |
+ gesture.$imageEl.transform('translate3d(0,0,0) scale(1)'); |
|
7207 |
+ } |
|
7208 |
+ |
|
7209 |
+ if (gesture.$imageWrapEl) { |
|
7210 |
+ gesture.$imageWrapEl.transform('translate3d(0,0,0)'); |
|
7211 |
+ } |
|
7212 |
+ |
|
7213 |
+ zoom.scale = 1; |
|
7214 |
+ zoom.currentScale = 1; |
|
7215 |
+ gesture.$slideEl = undefined; |
|
7216 |
+ gesture.$imageEl = undefined; |
|
7217 |
+ gesture.$imageWrapEl = undefined; |
|
7218 |
+ } |
|
7219 |
+ }, |
|
7220 |
+ // Toggle Zoom |
|
7221 |
+ toggle: function toggle(e) { |
|
7222 |
+ var swiper = this; |
|
7223 |
+ var zoom = swiper.zoom; |
|
7224 |
+ |
|
7225 |
+ if (zoom.scale && zoom.scale !== 1) { |
|
7226 |
+ // Zoom Out |
|
7227 |
+ zoom.out(); |
|
7228 |
+ } else { |
|
7229 |
+ // Zoom In |
|
7230 |
+ zoom.in(e); |
|
7231 |
+ } |
|
7232 |
+ }, |
|
7233 |
+ in: function _in(e) { |
|
7234 |
+ var swiper = this; |
|
7235 |
+ var zoom = swiper.zoom; |
|
7236 |
+ var params = swiper.params.zoom; |
|
7237 |
+ var gesture = zoom.gesture, |
|
7238 |
+ image = zoom.image; |
|
7239 |
+ |
|
7240 |
+ if (!gesture.$slideEl) { |
|
7241 |
+ if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) { |
|
7242 |
+ gesture.$slideEl = swiper.$wrapperEl.children("." + swiper.params.slideActiveClass); |
|
7243 |
+ } else { |
|
7244 |
+ gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); |
|
7245 |
+ } |
|
7246 |
+ |
|
7247 |
+ gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target'); |
|
7248 |
+ gesture.$imageWrapEl = gesture.$imageEl.parent("." + params.containerClass); |
|
7249 |
+ } |
|
7250 |
+ |
|
7251 |
+ if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; |
|
7252 |
+ gesture.$slideEl.addClass("" + params.zoomedSlideClass); |
|
7253 |
+ var touchX; |
|
7254 |
+ var touchY; |
|
7255 |
+ var offsetX; |
|
7256 |
+ var offsetY; |
|
7257 |
+ var diffX; |
|
7258 |
+ var diffY; |
|
7259 |
+ var translateX; |
|
7260 |
+ var translateY; |
|
7261 |
+ var imageWidth; |
|
7262 |
+ var imageHeight; |
|
7263 |
+ var scaledWidth; |
|
7264 |
+ var scaledHeight; |
|
7265 |
+ var translateMinX; |
|
7266 |
+ var translateMinY; |
|
7267 |
+ var translateMaxX; |
|
7268 |
+ var translateMaxY; |
|
7269 |
+ var slideWidth; |
|
7270 |
+ var slideHeight; |
|
7271 |
+ |
|
7272 |
+ if (typeof image.touchesStart.x === 'undefined' && e) { |
|
7273 |
+ touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX; |
|
7274 |
+ touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY; |
|
7275 |
+ } else { |
|
7276 |
+ touchX = image.touchesStart.x; |
|
7277 |
+ touchY = image.touchesStart.y; |
|
7278 |
+ } |
|
7279 |
+ |
|
7280 |
+ zoom.scale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; |
|
7281 |
+ zoom.currentScale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; |
|
7282 |
+ |
|
7283 |
+ if (e) { |
|
7284 |
+ slideWidth = gesture.$slideEl[0].offsetWidth; |
|
7285 |
+ slideHeight = gesture.$slideEl[0].offsetHeight; |
|
7286 |
+ offsetX = gesture.$slideEl.offset().left; |
|
7287 |
+ offsetY = gesture.$slideEl.offset().top; |
|
7288 |
+ diffX = offsetX + slideWidth / 2 - touchX; |
|
7289 |
+ diffY = offsetY + slideHeight / 2 - touchY; |
|
7290 |
+ imageWidth = gesture.$imageEl[0].offsetWidth; |
|
7291 |
+ imageHeight = gesture.$imageEl[0].offsetHeight; |
|
7292 |
+ scaledWidth = imageWidth * zoom.scale; |
|
7293 |
+ scaledHeight = imageHeight * zoom.scale; |
|
7294 |
+ translateMinX = Math.min(slideWidth / 2 - scaledWidth / 2, 0); |
|
7295 |
+ translateMinY = Math.min(slideHeight / 2 - scaledHeight / 2, 0); |
|
7296 |
+ translateMaxX = -translateMinX; |
|
7297 |
+ translateMaxY = -translateMinY; |
|
7298 |
+ translateX = diffX * zoom.scale; |
|
7299 |
+ translateY = diffY * zoom.scale; |
|
7300 |
+ |
|
7301 |
+ if (translateX < translateMinX) { |
|
7302 |
+ translateX = translateMinX; |
|
7303 |
+ } |
|
7304 |
+ |
|
7305 |
+ if (translateX > translateMaxX) { |
|
7306 |
+ translateX = translateMaxX; |
|
7307 |
+ } |
|
7308 |
+ |
|
7309 |
+ if (translateY < translateMinY) { |
|
7310 |
+ translateY = translateMinY; |
|
7311 |
+ } |
|
7312 |
+ |
|
7313 |
+ if (translateY > translateMaxY) { |
|
7314 |
+ translateY = translateMaxY; |
|
7315 |
+ } |
|
7316 |
+ } else { |
|
7317 |
+ translateX = 0; |
|
7318 |
+ translateY = 0; |
|
7319 |
+ } |
|
7320 |
+ |
|
7321 |
+ gesture.$imageWrapEl.transition(300).transform("translate3d(" + translateX + "px, " + translateY + "px,0)"); |
|
7322 |
+ gesture.$imageEl.transition(300).transform("translate3d(0,0,0) scale(" + zoom.scale + ")"); |
|
7323 |
+ }, |
|
7324 |
+ out: function out() { |
|
7325 |
+ var swiper = this; |
|
7326 |
+ var zoom = swiper.zoom; |
|
7327 |
+ var params = swiper.params.zoom; |
|
7328 |
+ var gesture = zoom.gesture; |
|
7329 |
+ |
|
7330 |
+ if (!gesture.$slideEl) { |
|
7331 |
+ if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) { |
|
7332 |
+ gesture.$slideEl = swiper.$wrapperEl.children("." + swiper.params.slideActiveClass); |
|
7333 |
+ } else { |
|
7334 |
+ gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); |
|
7335 |
+ } |
|
7336 |
+ |
|
7337 |
+ gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target'); |
|
7338 |
+ gesture.$imageWrapEl = gesture.$imageEl.parent("." + params.containerClass); |
|
7339 |
+ } |
|
7340 |
+ |
|
7341 |
+ if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; |
|
7342 |
+ zoom.scale = 1; |
|
7343 |
+ zoom.currentScale = 1; |
|
7344 |
+ gesture.$imageWrapEl.transition(300).transform('translate3d(0,0,0)'); |
|
7345 |
+ gesture.$imageEl.transition(300).transform('translate3d(0,0,0) scale(1)'); |
|
7346 |
+ gesture.$slideEl.removeClass("" + params.zoomedSlideClass); |
|
7347 |
+ gesture.$slideEl = undefined; |
|
7348 |
+ }, |
|
7349 |
+ toggleGestures: function toggleGestures(method) { |
|
7350 |
+ var swiper = this; |
|
7351 |
+ var zoom = swiper.zoom; |
|
7352 |
+ var selector = zoom.slideSelector, |
|
7353 |
+ passive = zoom.passiveListener; |
|
7354 |
+ swiper.$wrapperEl[method]('gesturestart', selector, zoom.onGestureStart, passive); |
|
7355 |
+ swiper.$wrapperEl[method]('gesturechange', selector, zoom.onGestureChange, passive); |
|
7356 |
+ swiper.$wrapperEl[method]('gestureend', selector, zoom.onGestureEnd, passive); |
|
7357 |
+ }, |
|
7358 |
+ enableGestures: function enableGestures() { |
|
7359 |
+ if (this.zoom.gesturesEnabled) return; |
|
7360 |
+ this.zoom.gesturesEnabled = true; |
|
7361 |
+ this.zoom.toggleGestures('on'); |
|
7362 |
+ }, |
|
7363 |
+ disableGestures: function disableGestures() { |
|
7364 |
+ if (!this.zoom.gesturesEnabled) return; |
|
7365 |
+ this.zoom.gesturesEnabled = false; |
|
7366 |
+ this.zoom.toggleGestures('off'); |
|
7367 |
+ }, |
|
7368 |
+ // Attach/Detach Events |
|
7369 |
+ enable: function enable() { |
|
7370 |
+ var swiper = this; |
|
7371 |
+ var support = swiper.support; |
|
7372 |
+ var zoom = swiper.zoom; |
|
7373 |
+ if (zoom.enabled) return; |
|
7374 |
+ zoom.enabled = true; |
|
7375 |
+ var passiveListener = swiper.touchEvents.start === 'touchstart' && support.passiveListener && swiper.params.passiveListeners ? { |
|
7376 |
+ passive: true, |
|
7377 |
+ capture: false |
|
7378 |
+ } : false; |
|
7379 |
+ var activeListenerWithCapture = support.passiveListener ? { |
|
7380 |
+ passive: false, |
|
7381 |
+ capture: true |
|
7382 |
+ } : true; |
|
7383 |
+ var slideSelector = "." + swiper.params.slideClass; |
|
7384 |
+ swiper.zoom.passiveListener = passiveListener; |
|
7385 |
+ swiper.zoom.slideSelector = slideSelector; // Scale image |
|
7386 |
+ |
|
7387 |
+ if (support.gestures) { |
|
7388 |
+ swiper.$wrapperEl.on(swiper.touchEvents.start, swiper.zoom.enableGestures, passiveListener); |
|
7389 |
+ swiper.$wrapperEl.on(swiper.touchEvents.end, swiper.zoom.disableGestures, passiveListener); |
|
7390 |
+ } else if (swiper.touchEvents.start === 'touchstart') { |
|
7391 |
+ swiper.$wrapperEl.on(swiper.touchEvents.start, slideSelector, zoom.onGestureStart, passiveListener); |
|
7392 |
+ swiper.$wrapperEl.on(swiper.touchEvents.move, slideSelector, zoom.onGestureChange, activeListenerWithCapture); |
|
7393 |
+ swiper.$wrapperEl.on(swiper.touchEvents.end, slideSelector, zoom.onGestureEnd, passiveListener); |
|
7394 |
+ |
|
7395 |
+ if (swiper.touchEvents.cancel) { |
|
7396 |
+ swiper.$wrapperEl.on(swiper.touchEvents.cancel, slideSelector, zoom.onGestureEnd, passiveListener); |
|
7397 |
+ } |
|
7398 |
+ } // Move image |
|
7399 |
+ |
|
7400 |
+ |
|
7401 |
+ swiper.$wrapperEl.on(swiper.touchEvents.move, "." + swiper.params.zoom.containerClass, zoom.onTouchMove, activeListenerWithCapture); |
|
7402 |
+ }, |
|
7403 |
+ disable: function disable() { |
|
7404 |
+ var swiper = this; |
|
7405 |
+ var zoom = swiper.zoom; |
|
7406 |
+ if (!zoom.enabled) return; |
|
7407 |
+ var support = swiper.support; |
|
7408 |
+ swiper.zoom.enabled = false; |
|
7409 |
+ var passiveListener = swiper.touchEvents.start === 'touchstart' && support.passiveListener && swiper.params.passiveListeners ? { |
|
7410 |
+ passive: true, |
|
7411 |
+ capture: false |
|
7412 |
+ } : false; |
|
7413 |
+ var activeListenerWithCapture = support.passiveListener ? { |
|
7414 |
+ passive: false, |
|
7415 |
+ capture: true |
|
7416 |
+ } : true; |
|
7417 |
+ var slideSelector = "." + swiper.params.slideClass; // Scale image |
|
7418 |
+ |
|
7419 |
+ if (support.gestures) { |
|
7420 |
+ swiper.$wrapperEl.off(swiper.touchEvents.start, swiper.zoom.enableGestures, passiveListener); |
|
7421 |
+ swiper.$wrapperEl.off(swiper.touchEvents.end, swiper.zoom.disableGestures, passiveListener); |
|
7422 |
+ } else if (swiper.touchEvents.start === 'touchstart') { |
|
7423 |
+ swiper.$wrapperEl.off(swiper.touchEvents.start, slideSelector, zoom.onGestureStart, passiveListener); |
|
7424 |
+ swiper.$wrapperEl.off(swiper.touchEvents.move, slideSelector, zoom.onGestureChange, activeListenerWithCapture); |
|
7425 |
+ swiper.$wrapperEl.off(swiper.touchEvents.end, slideSelector, zoom.onGestureEnd, passiveListener); |
|
7426 |
+ |
|
7427 |
+ if (swiper.touchEvents.cancel) { |
|
7428 |
+ swiper.$wrapperEl.off(swiper.touchEvents.cancel, slideSelector, zoom.onGestureEnd, passiveListener); |
|
7429 |
+ } |
|
7430 |
+ } // Move image |
|
7431 |
+ |
|
7432 |
+ |
|
7433 |
+ swiper.$wrapperEl.off(swiper.touchEvents.move, "." + swiper.params.zoom.containerClass, zoom.onTouchMove, activeListenerWithCapture); |
|
7434 |
+ } |
|
7435 |
+}; |
|
7436 |
+var Zoom$1 = { |
|
7437 |
+ name: 'zoom', |
|
7438 |
+ params: { |
|
7439 |
+ zoom: { |
|
7440 |
+ enabled: false, |
|
7441 |
+ maxRatio: 3, |
|
7442 |
+ minRatio: 1, |
|
7443 |
+ toggle: true, |
|
7444 |
+ containerClass: 'swiper-zoom-container', |
|
7445 |
+ zoomedSlideClass: 'swiper-slide-zoomed' |
|
7446 |
+ } |
|
7447 |
+ }, |
|
7448 |
+ create: function create() { |
|
7449 |
+ var swiper = this; |
|
7450 |
+ bindModuleMethods(swiper, { |
|
7451 |
+ zoom: _extends({ |
|
7452 |
+ enabled: false, |
|
7453 |
+ scale: 1, |
|
7454 |
+ currentScale: 1, |
|
7455 |
+ isScaling: false, |
|
7456 |
+ gesture: { |
|
7457 |
+ $slideEl: undefined, |
|
7458 |
+ slideWidth: undefined, |
|
7459 |
+ slideHeight: undefined, |
|
7460 |
+ $imageEl: undefined, |
|
7461 |
+ $imageWrapEl: undefined, |
|
7462 |
+ maxRatio: 3 |
|
7463 |
+ }, |
|
7464 |
+ image: { |
|
7465 |
+ isTouched: undefined, |
|
7466 |
+ isMoved: undefined, |
|
7467 |
+ currentX: undefined, |
|
7468 |
+ currentY: undefined, |
|
7469 |
+ minX: undefined, |
|
7470 |
+ minY: undefined, |
|
7471 |
+ maxX: undefined, |
|
7472 |
+ maxY: undefined, |
|
7473 |
+ width: undefined, |
|
7474 |
+ height: undefined, |
|
7475 |
+ startX: undefined, |
|
7476 |
+ startY: undefined, |
|
7477 |
+ touchesStart: {}, |
|
7478 |
+ touchesCurrent: {} |
|
7479 |
+ }, |
|
7480 |
+ velocity: { |
|
7481 |
+ x: undefined, |
|
7482 |
+ y: undefined, |
|
7483 |
+ prevPositionX: undefined, |
|
7484 |
+ prevPositionY: undefined, |
|
7485 |
+ prevTime: undefined |
|
7486 |
+ } |
|
7487 |
+ }, Zoom) |
|
7488 |
+ }); |
|
7489 |
+ var scale = 1; |
|
7490 |
+ Object.defineProperty(swiper.zoom, 'scale', { |
|
7491 |
+ get: function get() { |
|
7492 |
+ return scale; |
|
7493 |
+ }, |
|
7494 |
+ set: function set(value) { |
|
7495 |
+ if (scale !== value) { |
|
7496 |
+ var imageEl = swiper.zoom.gesture.$imageEl ? swiper.zoom.gesture.$imageEl[0] : undefined; |
|
7497 |
+ var slideEl = swiper.zoom.gesture.$slideEl ? swiper.zoom.gesture.$slideEl[0] : undefined; |
|
7498 |
+ swiper.emit('zoomChange', value, imageEl, slideEl); |
|
7499 |
+ } |
|
7500 |
+ |
|
7501 |
+ scale = value; |
|
7502 |
+ } |
|
7503 |
+ }); |
|
7504 |
+ }, |
|
7505 |
+ on: { |
|
7506 |
+ init: function init(swiper) { |
|
7507 |
+ if (swiper.params.zoom.enabled) { |
|
7508 |
+ swiper.zoom.enable(); |
|
7509 |
+ } |
|
7510 |
+ }, |
|
7511 |
+ destroy: function destroy(swiper) { |
|
7512 |
+ swiper.zoom.disable(); |
|
7513 |
+ }, |
|
7514 |
+ touchStart: function touchStart(swiper, e) { |
|
7515 |
+ if (!swiper.zoom.enabled) return; |
|
7516 |
+ swiper.zoom.onTouchStart(e); |
|
7517 |
+ }, |
|
7518 |
+ touchEnd: function touchEnd(swiper, e) { |
|
7519 |
+ if (!swiper.zoom.enabled) return; |
|
7520 |
+ swiper.zoom.onTouchEnd(e); |
|
7521 |
+ }, |
|
7522 |
+ doubleTap: function doubleTap(swiper, e) { |
|
7523 |
+ if (swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) { |
|
7524 |
+ swiper.zoom.toggle(e); |
|
7525 |
+ } |
|
7526 |
+ }, |
|
7527 |
+ transitionEnd: function transitionEnd(swiper) { |
|
7528 |
+ if (swiper.zoom.enabled && swiper.params.zoom.enabled) { |
|
7529 |
+ swiper.zoom.onTransitionEnd(); |
|
7530 |
+ } |
|
7531 |
+ }, |
|
7532 |
+ slideChange: function slideChange(swiper) { |
|
7533 |
+ if (swiper.zoom.enabled && swiper.params.zoom.enabled && swiper.params.cssMode) { |
|
7534 |
+ swiper.zoom.onTransitionEnd(); |
|
7535 |
+ } |
|
7536 |
+ } |
|
7537 |
+ } |
|
7538 |
+}; |
|
7539 |
+ |
|
7540 |
+var Lazy = { |
|
7541 |
+ loadInSlide: function loadInSlide(index, loadInDuplicate) { |
|
7542 |
+ if (loadInDuplicate === void 0) { |
|
7543 |
+ loadInDuplicate = true; |
|
7544 |
+ } |
|
7545 |
+ |
|
7546 |
+ var swiper = this; |
|
7547 |
+ var params = swiper.params.lazy; |
|
7548 |
+ if (typeof index === 'undefined') return; |
|
7549 |
+ if (swiper.slides.length === 0) return; |
|
7550 |
+ var isVirtual = swiper.virtual && swiper.params.virtual.enabled; |
|
7551 |
+ var $slideEl = isVirtual ? swiper.$wrapperEl.children("." + swiper.params.slideClass + "[data-swiper-slide-index=\"" + index + "\"]") : swiper.slides.eq(index); |
|
7552 |
+ var $images = $slideEl.find("." + params.elementClass + ":not(." + params.loadedClass + "):not(." + params.loadingClass + ")"); |
|
7553 |
+ |
|
7554 |
+ if ($slideEl.hasClass(params.elementClass) && !$slideEl.hasClass(params.loadedClass) && !$slideEl.hasClass(params.loadingClass)) { |
|
7555 |
+ $images.push($slideEl[0]); |
|
7556 |
+ } |
|
7557 |
+ |
|
7558 |
+ if ($images.length === 0) return; |
|
7559 |
+ $images.each(function (imageEl) { |
|
7560 |
+ var $imageEl = $(imageEl); |
|
7561 |
+ $imageEl.addClass(params.loadingClass); |
|
7562 |
+ var background = $imageEl.attr('data-background'); |
|
7563 |
+ var src = $imageEl.attr('data-src'); |
|
7564 |
+ var srcset = $imageEl.attr('data-srcset'); |
|
7565 |
+ var sizes = $imageEl.attr('data-sizes'); |
|
7566 |
+ var $pictureEl = $imageEl.parent('picture'); |
|
7567 |
+ swiper.loadImage($imageEl[0], src || background, srcset, sizes, false, function () { |
|
7568 |
+ if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper && !swiper.params || swiper.destroyed) return; |
|
7569 |
+ |
|
7570 |
+ if (background) { |
|
7571 |
+ $imageEl.css('background-image', "url(\"" + background + "\")"); |
|
7572 |
+ $imageEl.removeAttr('data-background'); |
|
7573 |
+ } else { |
|
7574 |
+ if (srcset) { |
|
7575 |
+ $imageEl.attr('srcset', srcset); |
|
7576 |
+ $imageEl.removeAttr('data-srcset'); |
|
7577 |
+ } |
|
7578 |
+ |
|
7579 |
+ if (sizes) { |
|
7580 |
+ $imageEl.attr('sizes', sizes); |
|
7581 |
+ $imageEl.removeAttr('data-sizes'); |
|
7582 |
+ } |
|
7583 |
+ |
|
7584 |
+ if ($pictureEl.length) { |
|
7585 |
+ $pictureEl.children('source').each(function (sourceEl) { |
|
7586 |
+ var $source = $(sourceEl); |
|
7587 |
+ |
|
7588 |
+ if ($source.attr('data-srcset')) { |
|
7589 |
+ $source.attr('srcset', $source.attr('data-srcset')); |
|
7590 |
+ $source.removeAttr('data-srcset'); |
|
7591 |
+ } |
|
7592 |
+ }); |
|
7593 |
+ } |
|
7594 |
+ |
|
7595 |
+ if (src) { |
|
7596 |
+ $imageEl.attr('src', src); |
|
7597 |
+ $imageEl.removeAttr('data-src'); |
|
7598 |
+ } |
|
7599 |
+ } |
|
7600 |
+ |
|
7601 |
+ $imageEl.addClass(params.loadedClass).removeClass(params.loadingClass); |
|
7602 |
+ $slideEl.find("." + params.preloaderClass).remove(); |
|
7603 |
+ |
|
7604 |
+ if (swiper.params.loop && loadInDuplicate) { |
|
7605 |
+ var slideOriginalIndex = $slideEl.attr('data-swiper-slide-index'); |
|
7606 |
+ |
|
7607 |
+ if ($slideEl.hasClass(swiper.params.slideDuplicateClass)) { |
|
7608 |
+ var originalSlide = swiper.$wrapperEl.children("[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]:not(." + swiper.params.slideDuplicateClass + ")"); |
|
7609 |
+ swiper.lazy.loadInSlide(originalSlide.index(), false); |
|
7610 |
+ } else { |
|
7611 |
+ var duplicatedSlide = swiper.$wrapperEl.children("." + swiper.params.slideDuplicateClass + "[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]"); |
|
7612 |
+ swiper.lazy.loadInSlide(duplicatedSlide.index(), false); |
|
7613 |
+ } |
|
7614 |
+ } |
|
7615 |
+ |
|
7616 |
+ swiper.emit('lazyImageReady', $slideEl[0], $imageEl[0]); |
|
7617 |
+ |
|
7618 |
+ if (swiper.params.autoHeight) { |
|
7619 |
+ swiper.updateAutoHeight(); |
|
7620 |
+ } |
|
7621 |
+ }); |
|
7622 |
+ swiper.emit('lazyImageLoad', $slideEl[0], $imageEl[0]); |
|
7623 |
+ }); |
|
7624 |
+ }, |
|
7625 |
+ load: function load() { |
|
7626 |
+ var swiper = this; |
|
7627 |
+ var $wrapperEl = swiper.$wrapperEl, |
|
7628 |
+ swiperParams = swiper.params, |
|
7629 |
+ slides = swiper.slides, |
|
7630 |
+ activeIndex = swiper.activeIndex; |
|
7631 |
+ var isVirtual = swiper.virtual && swiperParams.virtual.enabled; |
|
7632 |
+ var params = swiperParams.lazy; |
|
7633 |
+ var slidesPerView = swiperParams.slidesPerView; |
|
7634 |
+ |
|
7635 |
+ if (slidesPerView === 'auto') { |
|
7636 |
+ slidesPerView = 0; |
|
7637 |
+ } |
|
7638 |
+ |
|
7639 |
+ function slideExist(index) { |
|
7640 |
+ if (isVirtual) { |
|
7641 |
+ if ($wrapperEl.children("." + swiperParams.slideClass + "[data-swiper-slide-index=\"" + index + "\"]").length) { |
|
7642 |
+ return true; |
|
7643 |
+ } |
|
7644 |
+ } else if (slides[index]) return true; |
|
7645 |
+ |
|
7646 |
+ return false; |
|
7647 |
+ } |
|
7648 |
+ |
|
7649 |
+ function slideIndex(slideEl) { |
|
7650 |
+ if (isVirtual) { |
|
7651 |
+ return $(slideEl).attr('data-swiper-slide-index'); |
|
7652 |
+ } |
|
7653 |
+ |
|
7654 |
+ return $(slideEl).index(); |
|
7655 |
+ } |
|
7656 |
+ |
|
7657 |
+ if (!swiper.lazy.initialImageLoaded) swiper.lazy.initialImageLoaded = true; |
|
7658 |
+ |
|
7659 |
+ if (swiper.params.watchSlidesVisibility) { |
|
7660 |
+ $wrapperEl.children("." + swiperParams.slideVisibleClass).each(function (slideEl) { |
|
7661 |
+ var index = isVirtual ? $(slideEl).attr('data-swiper-slide-index') : $(slideEl).index(); |
|
7662 |
+ swiper.lazy.loadInSlide(index); |
|
7663 |
+ }); |
|
7664 |
+ } else if (slidesPerView > 1) { |
|
7665 |
+ for (var i = activeIndex; i < activeIndex + slidesPerView; i += 1) { |
|
7666 |
+ if (slideExist(i)) swiper.lazy.loadInSlide(i); |
|
7667 |
+ } |
|
7668 |
+ } else { |
|
7669 |
+ swiper.lazy.loadInSlide(activeIndex); |
|
7670 |
+ } |
|
7671 |
+ |
|
7672 |
+ if (params.loadPrevNext) { |
|
7673 |
+ if (slidesPerView > 1 || params.loadPrevNextAmount && params.loadPrevNextAmount > 1) { |
|
7674 |
+ var amount = params.loadPrevNextAmount; |
|
7675 |
+ var spv = slidesPerView; |
|
7676 |
+ var maxIndex = Math.min(activeIndex + spv + Math.max(amount, spv), slides.length); |
|
7677 |
+ var minIndex = Math.max(activeIndex - Math.max(spv, amount), 0); // Next Slides |
|
7678 |
+ |
|
7679 |
+ for (var _i = activeIndex + slidesPerView; _i < maxIndex; _i += 1) { |
|
7680 |
+ if (slideExist(_i)) swiper.lazy.loadInSlide(_i); |
|
7681 |
+ } // Prev Slides |
|
7682 |
+ |
|
7683 |
+ |
|
7684 |
+ for (var _i2 = minIndex; _i2 < activeIndex; _i2 += 1) { |
|
7685 |
+ if (slideExist(_i2)) swiper.lazy.loadInSlide(_i2); |
|
7686 |
+ } |
|
7687 |
+ } else { |
|
7688 |
+ var nextSlide = $wrapperEl.children("." + swiperParams.slideNextClass); |
|
7689 |
+ if (nextSlide.length > 0) swiper.lazy.loadInSlide(slideIndex(nextSlide)); |
|
7690 |
+ var prevSlide = $wrapperEl.children("." + swiperParams.slidePrevClass); |
|
7691 |
+ if (prevSlide.length > 0) swiper.lazy.loadInSlide(slideIndex(prevSlide)); |
|
7692 |
+ } |
|
7693 |
+ } |
|
7694 |
+ } |
|
7695 |
+}; |
|
7696 |
+var Lazy$1 = { |
|
7697 |
+ name: 'lazy', |
|
7698 |
+ params: { |
|
7699 |
+ lazy: { |
|
7700 |
+ enabled: false, |
|
7701 |
+ loadPrevNext: false, |
|
7702 |
+ loadPrevNextAmount: 1, |
|
7703 |
+ loadOnTransitionStart: false, |
|
7704 |
+ elementClass: 'swiper-lazy', |
|
7705 |
+ loadingClass: 'swiper-lazy-loading', |
|
7706 |
+ loadedClass: 'swiper-lazy-loaded', |
|
7707 |
+ preloaderClass: 'swiper-lazy-preloader' |
|
7708 |
+ } |
|
7709 |
+ }, |
|
7710 |
+ create: function create() { |
|
7711 |
+ var swiper = this; |
|
7712 |
+ bindModuleMethods(swiper, { |
|
7713 |
+ lazy: _extends({ |
|
7714 |
+ initialImageLoaded: false |
|
7715 |
+ }, Lazy) |
|
7716 |
+ }); |
|
7717 |
+ }, |
|
7718 |
+ on: { |
|
7719 |
+ beforeInit: function beforeInit(swiper) { |
|
7720 |
+ if (swiper.params.lazy.enabled && swiper.params.preloadImages) { |
|
7721 |
+ swiper.params.preloadImages = false; |
|
7722 |
+ } |
|
7723 |
+ }, |
|
7724 |
+ init: function init(swiper) { |
|
7725 |
+ if (swiper.params.lazy.enabled && !swiper.params.loop && swiper.params.initialSlide === 0) { |
|
7726 |
+ swiper.lazy.load(); |
|
7727 |
+ } |
|
7728 |
+ }, |
|
7729 |
+ scroll: function scroll(swiper) { |
|
7730 |
+ if (swiper.params.freeMode && !swiper.params.freeModeSticky) { |
|
7731 |
+ swiper.lazy.load(); |
|
7732 |
+ } |
|
7733 |
+ }, |
|
7734 |
+ resize: function resize(swiper) { |
|
7735 |
+ if (swiper.params.lazy.enabled) { |
|
7736 |
+ swiper.lazy.load(); |
|
7737 |
+ } |
|
7738 |
+ }, |
|
7739 |
+ scrollbarDragMove: function scrollbarDragMove(swiper) { |
|
7740 |
+ if (swiper.params.lazy.enabled) { |
|
7741 |
+ swiper.lazy.load(); |
|
7742 |
+ } |
|
7743 |
+ }, |
|
7744 |
+ transitionStart: function transitionStart(swiper) { |
|
7745 |
+ if (swiper.params.lazy.enabled) { |
|
7746 |
+ if (swiper.params.lazy.loadOnTransitionStart || !swiper.params.lazy.loadOnTransitionStart && !swiper.lazy.initialImageLoaded) { |
|
7747 |
+ swiper.lazy.load(); |
|
7748 |
+ } |
|
7749 |
+ } |
|
7750 |
+ }, |
|
7751 |
+ transitionEnd: function transitionEnd(swiper) { |
|
7752 |
+ if (swiper.params.lazy.enabled && !swiper.params.lazy.loadOnTransitionStart) { |
|
7753 |
+ swiper.lazy.load(); |
|
7754 |
+ } |
|
7755 |
+ }, |
|
7756 |
+ slideChange: function slideChange(swiper) { |
|
7757 |
+ if (swiper.params.lazy.enabled && swiper.params.cssMode) { |
|
7758 |
+ swiper.lazy.load(); |
|
7759 |
+ } |
|
7760 |
+ } |
|
7761 |
+ } |
|
7762 |
+}; |
|
7763 |
+ |
|
7764 |
+var Controller = { |
|
7765 |
+ LinearSpline: function LinearSpline(x, y) { |
|
7766 |
+ var binarySearch = function search() { |
|
7767 |
+ var maxIndex; |
|
7768 |
+ var minIndex; |
|
7769 |
+ var guess; |
|
7770 |
+ return function (array, val) { |
|
7771 |
+ minIndex = -1; |
|
7772 |
+ maxIndex = array.length; |
|
7773 |
+ |
|
7774 |
+ while (maxIndex - minIndex > 1) { |
|
7775 |
+ guess = maxIndex + minIndex >> 1; |
|
7776 |
+ |
|
7777 |
+ if (array[guess] <= val) { |
|
7778 |
+ minIndex = guess; |
|
7779 |
+ } else { |
|
7780 |
+ maxIndex = guess; |
|
7781 |
+ } |
|
7782 |
+ } |
|
7783 |
+ |
|
7784 |
+ return maxIndex; |
|
7785 |
+ }; |
|
7786 |
+ }(); |
|
7787 |
+ |
|
7788 |
+ this.x = x; |
|
7789 |
+ this.y = y; |
|
7790 |
+ this.lastIndex = x.length - 1; // Given an x value (x2), return the expected y2 value: |
|
7791 |
+ // (x1,y1) is the known point before given value, |
|
7792 |
+ // (x3,y3) is the known point after given value. |
|
7793 |
+ |
|
7794 |
+ var i1; |
|
7795 |
+ var i3; |
|
7796 |
+ |
|
7797 |
+ this.interpolate = function interpolate(x2) { |
|
7798 |
+ if (!x2) return 0; // Get the indexes of x1 and x3 (the array indexes before and after given x2): |
|
7799 |
+ |
|
7800 |
+ i3 = binarySearch(this.x, x2); |
|
7801 |
+ i1 = i3 - 1; // We have our indexes i1 & i3, so we can calculate already: |
|
7802 |
+ // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1 |
|
7803 |
+ |
|
7804 |
+ return (x2 - this.x[i1]) * (this.y[i3] - this.y[i1]) / (this.x[i3] - this.x[i1]) + this.y[i1]; |
|
7805 |
+ }; |
|
7806 |
+ |
|
7807 |
+ return this; |
|
7808 |
+ }, |
|
7809 |
+ // xxx: for now i will just save one spline function to to |
|
7810 |
+ getInterpolateFunction: function getInterpolateFunction(c) { |
|
7811 |
+ var swiper = this; |
|
7812 |
+ |
|
7813 |
+ if (!swiper.controller.spline) { |
|
7814 |
+ swiper.controller.spline = swiper.params.loop ? new Controller.LinearSpline(swiper.slidesGrid, c.slidesGrid) : new Controller.LinearSpline(swiper.snapGrid, c.snapGrid); |
|
7815 |
+ } |
|
7816 |
+ }, |
|
7817 |
+ setTranslate: function setTranslate(_setTranslate, byController) { |
|
7818 |
+ var swiper = this; |
|
7819 |
+ var controlled = swiper.controller.control; |
|
7820 |
+ var multiplier; |
|
7821 |
+ var controlledTranslate; |
|
7822 |
+ var Swiper = swiper.constructor; |
|
7823 |
+ |
|
7824 |
+ function setControlledTranslate(c) { |
|
7825 |
+ // this will create an Interpolate function based on the snapGrids |
|
7826 |
+ // x is the Grid of the scrolled scroller and y will be the controlled scroller |
|
7827 |
+ // it makes sense to create this only once and recall it for the interpolation |
|
7828 |
+ // the function does a lot of value caching for performance |
|
7829 |
+ var translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate; |
|
7830 |
+ |
|
7831 |
+ if (swiper.params.controller.by === 'slide') { |
|
7832 |
+ swiper.controller.getInterpolateFunction(c); // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid |
|
7833 |
+ // but it did not work out |
|
7834 |
+ |
|
7835 |
+ controlledTranslate = -swiper.controller.spline.interpolate(-translate); |
|
7836 |
+ } |
|
7837 |
+ |
|
7838 |
+ if (!controlledTranslate || swiper.params.controller.by === 'container') { |
|
7839 |
+ multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate()); |
|
7840 |
+ controlledTranslate = (translate - swiper.minTranslate()) * multiplier + c.minTranslate(); |
|
7841 |
+ } |
|
7842 |
+ |
|
7843 |
+ if (swiper.params.controller.inverse) { |
|
7844 |
+ controlledTranslate = c.maxTranslate() - controlledTranslate; |
|
7845 |
+ } |
|
7846 |
+ |
|
7847 |
+ c.updateProgress(controlledTranslate); |
|
7848 |
+ c.setTranslate(controlledTranslate, swiper); |
|
7849 |
+ c.updateActiveIndex(); |
|
7850 |
+ c.updateSlidesClasses(); |
|
7851 |
+ } |
|
7852 |
+ |
|
7853 |
+ if (Array.isArray(controlled)) { |
|
7854 |
+ for (var i = 0; i < controlled.length; i += 1) { |
|
7855 |
+ if (controlled[i] !== byController && controlled[i] instanceof Swiper) { |
|
7856 |
+ setControlledTranslate(controlled[i]); |
|
7857 |
+ } |
|
7858 |
+ } |
|
7859 |
+ } else if (controlled instanceof Swiper && byController !== controlled) { |
|
7860 |
+ setControlledTranslate(controlled); |
|
7861 |
+ } |
|
7862 |
+ }, |
|
7863 |
+ setTransition: function setTransition(duration, byController) { |
|
7864 |
+ var swiper = this; |
|
7865 |
+ var Swiper = swiper.constructor; |
|
7866 |
+ var controlled = swiper.controller.control; |
|
7867 |
+ var i; |
|
7868 |
+ |
|
7869 |
+ function setControlledTransition(c) { |
|
7870 |
+ c.setTransition(duration, swiper); |
|
7871 |
+ |
|
7872 |
+ if (duration !== 0) { |
|
7873 |
+ c.transitionStart(); |
|
7874 |
+ |
|
7875 |
+ if (c.params.autoHeight) { |
|
7876 |
+ nextTick(function () { |
|
7877 |
+ c.updateAutoHeight(); |
|
7878 |
+ }); |
|
7879 |
+ } |
|
7880 |
+ |
|
7881 |
+ c.$wrapperEl.transitionEnd(function () { |
|
7882 |
+ if (!controlled) return; |
|
7883 |
+ |
|
7884 |
+ if (c.params.loop && swiper.params.controller.by === 'slide') { |
|
7885 |
+ c.loopFix(); |
|
7886 |
+ } |
|
7887 |
+ |
|
7888 |
+ c.transitionEnd(); |
|
7889 |
+ }); |
|
7890 |
+ } |
|
7891 |
+ } |
|
7892 |
+ |
|
7893 |
+ if (Array.isArray(controlled)) { |
|
7894 |
+ for (i = 0; i < controlled.length; i += 1) { |
|
7895 |
+ if (controlled[i] !== byController && controlled[i] instanceof Swiper) { |
|
7896 |
+ setControlledTransition(controlled[i]); |
|
7897 |
+ } |
|
7898 |
+ } |
|
7899 |
+ } else if (controlled instanceof Swiper && byController !== controlled) { |
|
7900 |
+ setControlledTransition(controlled); |
|
7901 |
+ } |
|
7902 |
+ } |
|
7903 |
+}; |
|
7904 |
+var Controller$1 = { |
|
7905 |
+ name: 'controller', |
|
7906 |
+ params: { |
|
7907 |
+ controller: { |
|
7908 |
+ control: undefined, |
|
7909 |
+ inverse: false, |
|
7910 |
+ by: 'slide' // or 'container' |
|
7911 |
+ |
|
7912 |
+ } |
|
7913 |
+ }, |
|
7914 |
+ create: function create() { |
|
7915 |
+ var swiper = this; |
|
7916 |
+ bindModuleMethods(swiper, { |
|
7917 |
+ controller: _extends({ |
|
7918 |
+ control: swiper.params.controller.control |
|
7919 |
+ }, Controller) |
|
7920 |
+ }); |
|
7921 |
+ }, |
|
7922 |
+ on: { |
|
7923 |
+ update: function update(swiper) { |
|
7924 |
+ if (!swiper.controller.control) return; |
|
7925 |
+ |
|
7926 |
+ if (swiper.controller.spline) { |
|
7927 |
+ swiper.controller.spline = undefined; |
|
7928 |
+ delete swiper.controller.spline; |
|
7929 |
+ } |
|
7930 |
+ }, |
|
7931 |
+ resize: function resize(swiper) { |
|
7932 |
+ if (!swiper.controller.control) return; |
|
7933 |
+ |
|
7934 |
+ if (swiper.controller.spline) { |
|
7935 |
+ swiper.controller.spline = undefined; |
|
7936 |
+ delete swiper.controller.spline; |
|
7937 |
+ } |
|
7938 |
+ }, |
|
7939 |
+ observerUpdate: function observerUpdate(swiper) { |
|
7940 |
+ if (!swiper.controller.control) return; |
|
7941 |
+ |
|
7942 |
+ if (swiper.controller.spline) { |
|
7943 |
+ swiper.controller.spline = undefined; |
|
7944 |
+ delete swiper.controller.spline; |
|
7945 |
+ } |
|
7946 |
+ }, |
|
7947 |
+ setTranslate: function setTranslate(swiper, translate, byController) { |
|
7948 |
+ if (!swiper.controller.control) return; |
|
7949 |
+ swiper.controller.setTranslate(translate, byController); |
|
7950 |
+ }, |
|
7951 |
+ setTransition: function setTransition(swiper, duration, byController) { |
|
7952 |
+ if (!swiper.controller.control) return; |
|
7953 |
+ swiper.controller.setTransition(duration, byController); |
|
7954 |
+ } |
|
7955 |
+ } |
|
7956 |
+}; |
|
7957 |
+ |
|
7958 |
+var A11y = { |
|
7959 |
+ getRandomNumber: function getRandomNumber(size) { |
|
7960 |
+ if (size === void 0) { |
|
7961 |
+ size = 16; |
|
7962 |
+ } |
|
7963 |
+ |
|
7964 |
+ var randomChar = function randomChar() { |
|
7965 |
+ return Math.round(16 * Math.random()).toString(16); |
|
7966 |
+ }; |
|
7967 |
+ |
|
7968 |
+ return 'x'.repeat(size).replace(/x/g, randomChar); |
|
7969 |
+ }, |
|
7970 |
+ makeElFocusable: function makeElFocusable($el) { |
|
7971 |
+ $el.attr('tabIndex', '0'); |
|
7972 |
+ return $el; |
|
7973 |
+ }, |
|
7974 |
+ makeElNotFocusable: function makeElNotFocusable($el) { |
|
7975 |
+ $el.attr('tabIndex', '-1'); |
|
7976 |
+ return $el; |
|
7977 |
+ }, |
|
7978 |
+ addElRole: function addElRole($el, role) { |
|
7979 |
+ $el.attr('role', role); |
|
7980 |
+ return $el; |
|
7981 |
+ }, |
|
7982 |
+ addElRoleDescription: function addElRoleDescription($el, description) { |
|
7983 |
+ $el.attr('aria-role-description', description); |
|
7984 |
+ return $el; |
|
7985 |
+ }, |
|
7986 |
+ addElControls: function addElControls($el, controls) { |
|
7987 |
+ $el.attr('aria-controls', controls); |
|
7988 |
+ return $el; |
|
7989 |
+ }, |
|
7990 |
+ addElLabel: function addElLabel($el, label) { |
|
7991 |
+ $el.attr('aria-label', label); |
|
7992 |
+ return $el; |
|
7993 |
+ }, |
|
7994 |
+ addElId: function addElId($el, id) { |
|
7995 |
+ $el.attr('id', id); |
|
7996 |
+ return $el; |
|
7997 |
+ }, |
|
7998 |
+ addElLive: function addElLive($el, live) { |
|
7999 |
+ $el.attr('aria-live', live); |
|
8000 |
+ return $el; |
|
8001 |
+ }, |
|
8002 |
+ disableEl: function disableEl($el) { |
|
8003 |
+ $el.attr('aria-disabled', true); |
|
8004 |
+ return $el; |
|
8005 |
+ }, |
|
8006 |
+ enableEl: function enableEl($el) { |
|
8007 |
+ $el.attr('aria-disabled', false); |
|
8008 |
+ return $el; |
|
8009 |
+ }, |
|
8010 |
+ onEnterKey: function onEnterKey(e) { |
|
8011 |
+ var swiper = this; |
|
8012 |
+ var params = swiper.params.a11y; |
|
8013 |
+ if (e.keyCode !== 13) return; |
|
8014 |
+ var $targetEl = $(e.target); |
|
8015 |
+ |
|
8016 |
+ if (swiper.navigation && swiper.navigation.$nextEl && $targetEl.is(swiper.navigation.$nextEl)) { |
|
8017 |
+ if (!(swiper.isEnd && !swiper.params.loop)) { |
|
8018 |
+ swiper.slideNext(); |
|
8019 |
+ } |
|
8020 |
+ |
|
8021 |
+ if (swiper.isEnd) { |
|
8022 |
+ swiper.a11y.notify(params.lastSlideMessage); |
|
8023 |
+ } else { |
|
8024 |
+ swiper.a11y.notify(params.nextSlideMessage); |
|
8025 |
+ } |
|
8026 |
+ } |
|
8027 |
+ |
|
8028 |
+ if (swiper.navigation && swiper.navigation.$prevEl && $targetEl.is(swiper.navigation.$prevEl)) { |
|
8029 |
+ if (!(swiper.isBeginning && !swiper.params.loop)) { |
|
8030 |
+ swiper.slidePrev(); |
|
8031 |
+ } |
|
8032 |
+ |
|
8033 |
+ if (swiper.isBeginning) { |
|
8034 |
+ swiper.a11y.notify(params.firstSlideMessage); |
|
8035 |
+ } else { |
|
8036 |
+ swiper.a11y.notify(params.prevSlideMessage); |
|
8037 |
+ } |
|
8038 |
+ } |
|
8039 |
+ |
|
8040 |
+ if (swiper.pagination && $targetEl.is("." + swiper.params.pagination.bulletClass)) { |
|
8041 |
+ $targetEl[0].click(); |
|
8042 |
+ } |
|
8043 |
+ }, |
|
8044 |
+ notify: function notify(message) { |
|
8045 |
+ var swiper = this; |
|
8046 |
+ var notification = swiper.a11y.liveRegion; |
|
8047 |
+ if (notification.length === 0) return; |
|
8048 |
+ notification.html(''); |
|
8049 |
+ notification.html(message); |
|
8050 |
+ }, |
|
8051 |
+ updateNavigation: function updateNavigation() { |
|
8052 |
+ var swiper = this; |
|
8053 |
+ if (swiper.params.loop || !swiper.navigation) return; |
|
8054 |
+ var _swiper$navigation = swiper.navigation, |
|
8055 |
+ $nextEl = _swiper$navigation.$nextEl, |
|
8056 |
+ $prevEl = _swiper$navigation.$prevEl; |
|
8057 |
+ |
|
8058 |
+ if ($prevEl && $prevEl.length > 0) { |
|
8059 |
+ if (swiper.isBeginning) { |
|
8060 |
+ swiper.a11y.disableEl($prevEl); |
|
8061 |
+ swiper.a11y.makeElNotFocusable($prevEl); |
|
8062 |
+ } else { |
|
8063 |
+ swiper.a11y.enableEl($prevEl); |
|
8064 |
+ swiper.a11y.makeElFocusable($prevEl); |
|
8065 |
+ } |
|
8066 |
+ } |
|
8067 |
+ |
|
8068 |
+ if ($nextEl && $nextEl.length > 0) { |
|
8069 |
+ if (swiper.isEnd) { |
|
8070 |
+ swiper.a11y.disableEl($nextEl); |
|
8071 |
+ swiper.a11y.makeElNotFocusable($nextEl); |
|
8072 |
+ } else { |
|
8073 |
+ swiper.a11y.enableEl($nextEl); |
|
8074 |
+ swiper.a11y.makeElFocusable($nextEl); |
|
8075 |
+ } |
|
8076 |
+ } |
|
8077 |
+ }, |
|
8078 |
+ updatePagination: function updatePagination() { |
|
8079 |
+ var swiper = this; |
|
8080 |
+ var params = swiper.params.a11y; |
|
8081 |
+ |
|
8082 |
+ if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { |
|
8083 |
+ swiper.pagination.bullets.each(function (bulletEl) { |
|
8084 |
+ var $bulletEl = $(bulletEl); |
|
8085 |
+ swiper.a11y.makeElFocusable($bulletEl); |
|
8086 |
+ |
|
8087 |
+ if (!swiper.params.pagination.renderBullet) { |
|
8088 |
+ swiper.a11y.addElRole($bulletEl, 'button'); |
|
8089 |
+ swiper.a11y.addElLabel($bulletEl, params.paginationBulletMessage.replace(/\{\{index\}\}/, $bulletEl.index() + 1)); |
|
8090 |
+ } |
|
8091 |
+ }); |
|
8092 |
+ } |
|
8093 |
+ }, |
|
8094 |
+ init: function init() { |
|
8095 |
+ var swiper = this; |
|
8096 |
+ var params = swiper.params.a11y; |
|
8097 |
+ swiper.$el.append(swiper.a11y.liveRegion); // Container |
|
8098 |
+ |
|
8099 |
+ var $containerEl = swiper.$el; |
|
8100 |
+ |
|
8101 |
+ if (params.containerRoleDescriptionMessage) { |
|
8102 |
+ swiper.a11y.addElRoleDescription($containerEl, params.containerRoleDescriptionMessage); |
|
8103 |
+ } |
|
8104 |
+ |
|
8105 |
+ if (params.containerMessage) { |
|
8106 |
+ swiper.a11y.addElLabel($containerEl, params.containerMessage); |
|
8107 |
+ } // Wrapper |
|
8108 |
+ |
|
8109 |
+ |
|
8110 |
+ var $wrapperEl = swiper.$wrapperEl; |
|
8111 |
+ var wrapperId = $wrapperEl.attr('id') || "swiper-wrapper-" + swiper.a11y.getRandomNumber(16); |
|
8112 |
+ var live; |
|
8113 |
+ swiper.a11y.addElId($wrapperEl, wrapperId); |
|
8114 |
+ |
|
8115 |
+ if (swiper.params.autoplay && swiper.params.autoplay.enabled) { |
|
8116 |
+ live = 'off'; |
|
8117 |
+ } else { |
|
8118 |
+ live = 'polite'; |
|
8119 |
+ } |
|
8120 |
+ |
|
8121 |
+ swiper.a11y.addElLive($wrapperEl, live); // Slide |
|
8122 |
+ |
|
8123 |
+ if (params.itemRoleDescriptionMessage) { |
|
8124 |
+ swiper.a11y.addElRoleDescription($(swiper.slides), params.itemRoleDescriptionMessage); |
|
8125 |
+ } |
|
8126 |
+ |
|
8127 |
+ swiper.a11y.addElRole($(swiper.slides), 'group'); |
|
8128 |
+ swiper.slides.each(function (slideEl) { |
|
8129 |
+ var $slideEl = $(slideEl); |
|
8130 |
+ swiper.a11y.addElLabel($slideEl, $slideEl.index() + 1 + " / " + swiper.slides.length); |
|
8131 |
+ }); // Navigation |
|
8132 |
+ |
|
8133 |
+ var $nextEl; |
|
8134 |
+ var $prevEl; |
|
8135 |
+ |
|
8136 |
+ if (swiper.navigation && swiper.navigation.$nextEl) { |
|
8137 |
+ $nextEl = swiper.navigation.$nextEl; |
|
8138 |
+ } |
|
8139 |
+ |
|
8140 |
+ if (swiper.navigation && swiper.navigation.$prevEl) { |
|
8141 |
+ $prevEl = swiper.navigation.$prevEl; |
|
8142 |
+ } |
|
8143 |
+ |
|
8144 |
+ if ($nextEl && $nextEl.length) { |
|
8145 |
+ swiper.a11y.makeElFocusable($nextEl); |
|
8146 |
+ |
|
8147 |
+ if ($nextEl[0].tagName !== 'BUTTON') { |
|
8148 |
+ swiper.a11y.addElRole($nextEl, 'button'); |
|
8149 |
+ $nextEl.on('keydown', swiper.a11y.onEnterKey); |
|
8150 |
+ } |
|
8151 |
+ |
|
8152 |
+ swiper.a11y.addElLabel($nextEl, params.nextSlideMessage); |
|
8153 |
+ swiper.a11y.addElControls($nextEl, wrapperId); |
|
8154 |
+ } |
|
8155 |
+ |
|
8156 |
+ if ($prevEl && $prevEl.length) { |
|
8157 |
+ swiper.a11y.makeElFocusable($prevEl); |
|
8158 |
+ |
|
8159 |
+ if ($prevEl[0].tagName !== 'BUTTON') { |
|
8160 |
+ swiper.a11y.addElRole($prevEl, 'button'); |
|
8161 |
+ $prevEl.on('keydown', swiper.a11y.onEnterKey); |
|
8162 |
+ } |
|
8163 |
+ |
|
8164 |
+ swiper.a11y.addElLabel($prevEl, params.prevSlideMessage); |
|
8165 |
+ swiper.a11y.addElControls($prevEl, wrapperId); |
|
8166 |
+ } // Pagination |
|
8167 |
+ |
|
8168 |
+ |
|
8169 |
+ if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { |
|
8170 |
+ swiper.pagination.$el.on('keydown', "." + swiper.params.pagination.bulletClass, swiper.a11y.onEnterKey); |
|
8171 |
+ } |
|
8172 |
+ }, |
|
8173 |
+ destroy: function destroy() { |
|
8174 |
+ var swiper = this; |
|
8175 |
+ if (swiper.a11y.liveRegion && swiper.a11y.liveRegion.length > 0) swiper.a11y.liveRegion.remove(); |
|
8176 |
+ var $nextEl; |
|
8177 |
+ var $prevEl; |
|
8178 |
+ |
|
8179 |
+ if (swiper.navigation && swiper.navigation.$nextEl) { |
|
8180 |
+ $nextEl = swiper.navigation.$nextEl; |
|
8181 |
+ } |
|
8182 |
+ |
|
8183 |
+ if (swiper.navigation && swiper.navigation.$prevEl) { |
|
8184 |
+ $prevEl = swiper.navigation.$prevEl; |
|
8185 |
+ } |
|
8186 |
+ |
|
8187 |
+ if ($nextEl) { |
|
8188 |
+ $nextEl.off('keydown', swiper.a11y.onEnterKey); |
|
8189 |
+ } |
|
8190 |
+ |
|
8191 |
+ if ($prevEl) { |
|
8192 |
+ $prevEl.off('keydown', swiper.a11y.onEnterKey); |
|
8193 |
+ } // Pagination |
|
8194 |
+ |
|
8195 |
+ |
|
8196 |
+ if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { |
|
8197 |
+ swiper.pagination.$el.off('keydown', "." + swiper.params.pagination.bulletClass, swiper.a11y.onEnterKey); |
|
8198 |
+ } |
|
8199 |
+ } |
|
8200 |
+}; |
|
8201 |
+var A11y$1 = { |
|
8202 |
+ name: 'a11y', |
|
8203 |
+ params: { |
|
8204 |
+ a11y: { |
|
8205 |
+ enabled: true, |
|
8206 |
+ notificationClass: 'swiper-notification', |
|
8207 |
+ prevSlideMessage: 'Previous slide', |
|
8208 |
+ nextSlideMessage: 'Next slide', |
|
8209 |
+ firstSlideMessage: 'This is the first slide', |
|
8210 |
+ lastSlideMessage: 'This is the last slide', |
|
8211 |
+ paginationBulletMessage: 'Go to slide {{index}}', |
|
8212 |
+ containerMessage: null, |
|
8213 |
+ containerRoleDescriptionMessage: null, |
|
8214 |
+ itemRoleDescriptionMessage: null |
|
8215 |
+ } |
|
8216 |
+ }, |
|
8217 |
+ create: function create() { |
|
8218 |
+ var swiper = this; |
|
8219 |
+ bindModuleMethods(swiper, { |
|
8220 |
+ a11y: _extends(_extends({}, A11y), {}, { |
|
8221 |
+ liveRegion: $("<span class=\"" + swiper.params.a11y.notificationClass + "\" aria-live=\"assertive\" aria-atomic=\"true\"></span>") |
|
8222 |
+ }) |
|
8223 |
+ }); |
|
8224 |
+ }, |
|
8225 |
+ on: { |
|
8226 |
+ afterInit: function afterInit(swiper) { |
|
8227 |
+ if (!swiper.params.a11y.enabled) return; |
|
8228 |
+ swiper.a11y.init(); |
|
8229 |
+ swiper.a11y.updateNavigation(); |
|
8230 |
+ }, |
|
8231 |
+ toEdge: function toEdge(swiper) { |
|
8232 |
+ if (!swiper.params.a11y.enabled) return; |
|
8233 |
+ swiper.a11y.updateNavigation(); |
|
8234 |
+ }, |
|
8235 |
+ fromEdge: function fromEdge(swiper) { |
|
8236 |
+ if (!swiper.params.a11y.enabled) return; |
|
8237 |
+ swiper.a11y.updateNavigation(); |
|
8238 |
+ }, |
|
8239 |
+ paginationUpdate: function paginationUpdate(swiper) { |
|
8240 |
+ if (!swiper.params.a11y.enabled) return; |
|
8241 |
+ swiper.a11y.updatePagination(); |
|
8242 |
+ }, |
|
8243 |
+ destroy: function destroy(swiper) { |
|
8244 |
+ if (!swiper.params.a11y.enabled) return; |
|
8245 |
+ swiper.a11y.destroy(); |
|
8246 |
+ } |
|
8247 |
+ } |
|
8248 |
+}; |
|
8249 |
+ |
|
8250 |
+var History = { |
|
8251 |
+ init: function init() { |
|
8252 |
+ var swiper = this; |
|
8253 |
+ var window = getWindow(); |
|
8254 |
+ if (!swiper.params.history) return; |
|
8255 |
+ |
|
8256 |
+ if (!window.history || !window.history.pushState) { |
|
8257 |
+ swiper.params.history.enabled = false; |
|
8258 |
+ swiper.params.hashNavigation.enabled = true; |
|
8259 |
+ return; |
|
8260 |
+ } |
|
8261 |
+ |
|
8262 |
+ var history = swiper.history; |
|
8263 |
+ history.initialized = true; |
|
8264 |
+ history.paths = History.getPathValues(swiper.params.url); |
|
8265 |
+ if (!history.paths.key && !history.paths.value) return; |
|
8266 |
+ history.scrollToSlide(0, history.paths.value, swiper.params.runCallbacksOnInit); |
|
8267 |
+ |
|
8268 |
+ if (!swiper.params.history.replaceState) { |
|
8269 |
+ window.addEventListener('popstate', swiper.history.setHistoryPopState); |
|
8270 |
+ } |
|
8271 |
+ }, |
|
8272 |
+ destroy: function destroy() { |
|
8273 |
+ var swiper = this; |
|
8274 |
+ var window = getWindow(); |
|
8275 |
+ |
|
8276 |
+ if (!swiper.params.history.replaceState) { |
|
8277 |
+ window.removeEventListener('popstate', swiper.history.setHistoryPopState); |
|
8278 |
+ } |
|
8279 |
+ }, |
|
8280 |
+ setHistoryPopState: function setHistoryPopState() { |
|
8281 |
+ var swiper = this; |
|
8282 |
+ swiper.history.paths = History.getPathValues(swiper.params.url); |
|
8283 |
+ swiper.history.scrollToSlide(swiper.params.speed, swiper.history.paths.value, false); |
|
8284 |
+ }, |
|
8285 |
+ getPathValues: function getPathValues(urlOverride) { |
|
8286 |
+ var window = getWindow(); |
|
8287 |
+ var location; |
|
8288 |
+ |
|
8289 |
+ if (urlOverride) { |
|
8290 |
+ location = new URL(urlOverride); |
|
8291 |
+ } else { |
|
8292 |
+ location = window.location; |
|
8293 |
+ } |
|
8294 |
+ |
|
8295 |
+ var pathArray = location.pathname.slice(1).split('/').filter(function (part) { |
|
8296 |
+ return part !== ''; |
|
8297 |
+ }); |
|
8298 |
+ var total = pathArray.length; |
|
8299 |
+ var key = pathArray[total - 2]; |
|
8300 |
+ var value = pathArray[total - 1]; |
|
8301 |
+ return { |
|
8302 |
+ key: key, |
|
8303 |
+ value: value |
|
8304 |
+ }; |
|
8305 |
+ }, |
|
8306 |
+ setHistory: function setHistory(key, index) { |
|
8307 |
+ var swiper = this; |
|
8308 |
+ var window = getWindow(); |
|
8309 |
+ if (!swiper.history.initialized || !swiper.params.history.enabled) return; |
|
8310 |
+ var location; |
|
8311 |
+ |
|
8312 |
+ if (swiper.params.url) { |
|
8313 |
+ location = new URL(swiper.params.url); |
|
8314 |
+ } else { |
|
8315 |
+ location = window.location; |
|
8316 |
+ } |
|
8317 |
+ |
|
8318 |
+ var slide = swiper.slides.eq(index); |
|
8319 |
+ var value = History.slugify(slide.attr('data-history')); |
|
8320 |
+ |
|
8321 |
+ if (!location.pathname.includes(key)) { |
|
8322 |
+ value = key + "/" + value; |
|
8323 |
+ } |
|
8324 |
+ |
|
8325 |
+ var currentState = window.history.state; |
|
8326 |
+ |
|
8327 |
+ if (currentState && currentState.value === value) { |
|
8328 |
+ return; |
|
8329 |
+ } |
|
8330 |
+ |
|
8331 |
+ if (swiper.params.history.replaceState) { |
|
8332 |
+ window.history.replaceState({ |
|
8333 |
+ value: value |
|
8334 |
+ }, null, value); |
|
8335 |
+ } else { |
|
8336 |
+ window.history.pushState({ |
|
8337 |
+ value: value |
|
8338 |
+ }, null, value); |
|
8339 |
+ } |
|
8340 |
+ }, |
|
8341 |
+ slugify: function slugify(text) { |
|
8342 |
+ return text.toString().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, ''); |
|
8343 |
+ }, |
|
8344 |
+ scrollToSlide: function scrollToSlide(speed, value, runCallbacks) { |
|
8345 |
+ var swiper = this; |
|
8346 |
+ |
|
8347 |
+ if (value) { |
|
8348 |
+ for (var i = 0, length = swiper.slides.length; i < length; i += 1) { |
|
8349 |
+ var slide = swiper.slides.eq(i); |
|
8350 |
+ var slideHistory = History.slugify(slide.attr('data-history')); |
|
8351 |
+ |
|
8352 |
+ if (slideHistory === value && !slide.hasClass(swiper.params.slideDuplicateClass)) { |
|
8353 |
+ var index = slide.index(); |
|
8354 |
+ swiper.slideTo(index, speed, runCallbacks); |
|
8355 |
+ } |
|
8356 |
+ } |
|
8357 |
+ } else { |
|
8358 |
+ swiper.slideTo(0, speed, runCallbacks); |
|
8359 |
+ } |
|
8360 |
+ } |
|
8361 |
+}; |
|
8362 |
+var History$1 = { |
|
8363 |
+ name: 'history', |
|
8364 |
+ params: { |
|
8365 |
+ history: { |
|
8366 |
+ enabled: false, |
|
8367 |
+ replaceState: false, |
|
8368 |
+ key: 'slides' |
|
8369 |
+ } |
|
8370 |
+ }, |
|
8371 |
+ create: function create() { |
|
8372 |
+ var swiper = this; |
|
8373 |
+ bindModuleMethods(swiper, { |
|
8374 |
+ history: _extends({}, History) |
|
8375 |
+ }); |
|
8376 |
+ }, |
|
8377 |
+ on: { |
|
8378 |
+ init: function init(swiper) { |
|
8379 |
+ if (swiper.params.history.enabled) { |
|
8380 |
+ swiper.history.init(); |
|
8381 |
+ } |
|
8382 |
+ }, |
|
8383 |
+ destroy: function destroy(swiper) { |
|
8384 |
+ if (swiper.params.history.enabled) { |
|
8385 |
+ swiper.history.destroy(); |
|
8386 |
+ } |
|
8387 |
+ }, |
|
8388 |
+ transitionEnd: function transitionEnd(swiper) { |
|
8389 |
+ if (swiper.history.initialized) { |
|
8390 |
+ swiper.history.setHistory(swiper.params.history.key, swiper.activeIndex); |
|
8391 |
+ } |
|
8392 |
+ }, |
|
8393 |
+ slideChange: function slideChange(swiper) { |
|
8394 |
+ if (swiper.history.initialized && swiper.params.cssMode) { |
|
8395 |
+ swiper.history.setHistory(swiper.params.history.key, swiper.activeIndex); |
|
8396 |
+ } |
|
8397 |
+ } |
|
8398 |
+ } |
|
8399 |
+}; |
|
8400 |
+ |
|
8401 |
+var HashNavigation = { |
|
8402 |
+ onHashCange: function onHashCange() { |
|
8403 |
+ var swiper = this; |
|
8404 |
+ var document = getDocument(); |
|
8405 |
+ swiper.emit('hashChange'); |
|
8406 |
+ var newHash = document.location.hash.replace('#', ''); |
|
8407 |
+ var activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash'); |
|
8408 |
+ |
|
8409 |
+ if (newHash !== activeSlideHash) { |
|
8410 |
+ var newIndex = swiper.$wrapperEl.children("." + swiper.params.slideClass + "[data-hash=\"" + newHash + "\"]").index(); |
|
8411 |
+ if (typeof newIndex === 'undefined') return; |
|
8412 |
+ swiper.slideTo(newIndex); |
|
8413 |
+ } |
|
8414 |
+ }, |
|
8415 |
+ setHash: function setHash() { |
|
8416 |
+ var swiper = this; |
|
8417 |
+ var window = getWindow(); |
|
8418 |
+ var document = getDocument(); |
|
8419 |
+ if (!swiper.hashNavigation.initialized || !swiper.params.hashNavigation.enabled) return; |
|
8420 |
+ |
|
8421 |
+ if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) { |
|
8422 |
+ window.history.replaceState(null, null, "#" + swiper.slides.eq(swiper.activeIndex).attr('data-hash') || ''); |
|
8423 |
+ swiper.emit('hashSet'); |
|
8424 |
+ } else { |
|
8425 |
+ var slide = swiper.slides.eq(swiper.activeIndex); |
|
8426 |
+ var hash = slide.attr('data-hash') || slide.attr('data-history'); |
|
8427 |
+ document.location.hash = hash || ''; |
|
8428 |
+ swiper.emit('hashSet'); |
|
8429 |
+ } |
|
8430 |
+ }, |
|
8431 |
+ init: function init() { |
|
8432 |
+ var swiper = this; |
|
8433 |
+ var document = getDocument(); |
|
8434 |
+ var window = getWindow(); |
|
8435 |
+ if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return; |
|
8436 |
+ swiper.hashNavigation.initialized = true; |
|
8437 |
+ var hash = document.location.hash.replace('#', ''); |
|
8438 |
+ |
|
8439 |
+ if (hash) { |
|
8440 |
+ var speed = 0; |
|
8441 |
+ |
|
8442 |
+ for (var i = 0, length = swiper.slides.length; i < length; i += 1) { |
|
8443 |
+ var slide = swiper.slides.eq(i); |
|
8444 |
+ var slideHash = slide.attr('data-hash') || slide.attr('data-history'); |
|
8445 |
+ |
|
8446 |
+ if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) { |
|
8447 |
+ var index = slide.index(); |
|
8448 |
+ swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true); |
|
8449 |
+ } |
|
8450 |
+ } |
|
8451 |
+ } |
|
8452 |
+ |
|
8453 |
+ if (swiper.params.hashNavigation.watchState) { |
|
8454 |
+ $(window).on('hashchange', swiper.hashNavigation.onHashCange); |
|
8455 |
+ } |
|
8456 |
+ }, |
|
8457 |
+ destroy: function destroy() { |
|
8458 |
+ var swiper = this; |
|
8459 |
+ var window = getWindow(); |
|
8460 |
+ |
|
8461 |
+ if (swiper.params.hashNavigation.watchState) { |
|
8462 |
+ $(window).off('hashchange', swiper.hashNavigation.onHashCange); |
|
8463 |
+ } |
|
8464 |
+ } |
|
8465 |
+}; |
|
8466 |
+var HashNavigation$1 = { |
|
8467 |
+ name: 'hash-navigation', |
|
8468 |
+ params: { |
|
8469 |
+ hashNavigation: { |
|
8470 |
+ enabled: false, |
|
8471 |
+ replaceState: false, |
|
8472 |
+ watchState: false |
|
8473 |
+ } |
|
8474 |
+ }, |
|
8475 |
+ create: function create() { |
|
8476 |
+ var swiper = this; |
|
8477 |
+ bindModuleMethods(swiper, { |
|
8478 |
+ hashNavigation: _extends({ |
|
8479 |
+ initialized: false |
|
8480 |
+ }, HashNavigation) |
|
8481 |
+ }); |
|
8482 |
+ }, |
|
8483 |
+ on: { |
|
8484 |
+ init: function init(swiper) { |
|
8485 |
+ if (swiper.params.hashNavigation.enabled) { |
|
8486 |
+ swiper.hashNavigation.init(); |
|
8487 |
+ } |
|
8488 |
+ }, |
|
8489 |
+ destroy: function destroy(swiper) { |
|
8490 |
+ if (swiper.params.hashNavigation.enabled) { |
|
8491 |
+ swiper.hashNavigation.destroy(); |
|
8492 |
+ } |
|
8493 |
+ }, |
|
8494 |
+ transitionEnd: function transitionEnd(swiper) { |
|
8495 |
+ if (swiper.hashNavigation.initialized) { |
|
8496 |
+ swiper.hashNavigation.setHash(); |
|
8497 |
+ } |
|
8498 |
+ }, |
|
8499 |
+ slideChange: function slideChange(swiper) { |
|
8500 |
+ if (swiper.hashNavigation.initialized && swiper.params.cssMode) { |
|
8501 |
+ swiper.hashNavigation.setHash(); |
|
8502 |
+ } |
|
8503 |
+ } |
|
8504 |
+ } |
|
8505 |
+}; |
|
8506 |
+ |
|
8507 |
+var Autoplay = { |
|
8508 |
+ run: function run() { |
|
8509 |
+ var swiper = this; |
|
8510 |
+ var $activeSlideEl = swiper.slides.eq(swiper.activeIndex); |
|
8511 |
+ var delay = swiper.params.autoplay.delay; |
|
8512 |
+ |
|
8513 |
+ if ($activeSlideEl.attr('data-swiper-autoplay')) { |
|
8514 |
+ delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay; |
|
8515 |
+ } |
|
8516 |
+ |
|
8517 |
+ clearTimeout(swiper.autoplay.timeout); |
|
8518 |
+ swiper.autoplay.timeout = nextTick(function () { |
|
8519 |
+ var autoplayResult; |
|
8520 |
+ |
|
8521 |
+ if (swiper.params.autoplay.reverseDirection) { |
|
8522 |
+ if (swiper.params.loop) { |
|
8523 |
+ swiper.loopFix(); |
|
8524 |
+ autoplayResult = swiper.slidePrev(swiper.params.speed, true, true); |
|
8525 |
+ swiper.emit('autoplay'); |
|
8526 |
+ } else if (!swiper.isBeginning) { |
|
8527 |
+ autoplayResult = swiper.slidePrev(swiper.params.speed, true, true); |
|
8528 |
+ swiper.emit('autoplay'); |
|
8529 |
+ } else if (!swiper.params.autoplay.stopOnLastSlide) { |
|
8530 |
+ autoplayResult = swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true); |
|
8531 |
+ swiper.emit('autoplay'); |
|
8532 |
+ } else { |
|
8533 |
+ swiper.autoplay.stop(); |
|
8534 |
+ } |
|
8535 |
+ } else if (swiper.params.loop) { |
|
8536 |
+ swiper.loopFix(); |
|
8537 |
+ autoplayResult = swiper.slideNext(swiper.params.speed, true, true); |
|
8538 |
+ swiper.emit('autoplay'); |
|
8539 |
+ } else if (!swiper.isEnd) { |
|
8540 |
+ autoplayResult = swiper.slideNext(swiper.params.speed, true, true); |
|
8541 |
+ swiper.emit('autoplay'); |
|
8542 |
+ } else if (!swiper.params.autoplay.stopOnLastSlide) { |
|
8543 |
+ autoplayResult = swiper.slideTo(0, swiper.params.speed, true, true); |
|
8544 |
+ swiper.emit('autoplay'); |
|
8545 |
+ } else { |
|
8546 |
+ swiper.autoplay.stop(); |
|
8547 |
+ } |
|
8548 |
+ |
|
8549 |
+ if (swiper.params.cssMode && swiper.autoplay.running) swiper.autoplay.run();else if (autoplayResult === false) { |
|
8550 |
+ swiper.autoplay.run(); |
|
8551 |
+ } |
|
8552 |
+ }, delay); |
|
8553 |
+ }, |
|
8554 |
+ start: function start() { |
|
8555 |
+ var swiper = this; |
|
8556 |
+ if (typeof swiper.autoplay.timeout !== 'undefined') return false; |
|
8557 |
+ if (swiper.autoplay.running) return false; |
|
8558 |
+ swiper.autoplay.running = true; |
|
8559 |
+ swiper.emit('autoplayStart'); |
|
8560 |
+ swiper.autoplay.run(); |
|
8561 |
+ return true; |
|
8562 |
+ }, |
|
8563 |
+ stop: function stop() { |
|
8564 |
+ var swiper = this; |
|
8565 |
+ if (!swiper.autoplay.running) return false; |
|
8566 |
+ if (typeof swiper.autoplay.timeout === 'undefined') return false; |
|
8567 |
+ |
|
8568 |
+ if (swiper.autoplay.timeout) { |
|
8569 |
+ clearTimeout(swiper.autoplay.timeout); |
|
8570 |
+ swiper.autoplay.timeout = undefined; |
|
8571 |
+ } |
|
8572 |
+ |
|
8573 |
+ swiper.autoplay.running = false; |
|
8574 |
+ swiper.emit('autoplayStop'); |
|
8575 |
+ return true; |
|
8576 |
+ }, |
|
8577 |
+ pause: function pause(speed) { |
|
8578 |
+ var swiper = this; |
|
8579 |
+ if (!swiper.autoplay.running) return; |
|
8580 |
+ if (swiper.autoplay.paused) return; |
|
8581 |
+ if (swiper.autoplay.timeout) clearTimeout(swiper.autoplay.timeout); |
|
8582 |
+ swiper.autoplay.paused = true; |
|
8583 |
+ |
|
8584 |
+ if (speed === 0 || !swiper.params.autoplay.waitForTransition) { |
|
8585 |
+ swiper.autoplay.paused = false; |
|
8586 |
+ swiper.autoplay.run(); |
|
8587 |
+ } else { |
|
8588 |
+ swiper.$wrapperEl[0].addEventListener('transitionend', swiper.autoplay.onTransitionEnd); |
|
8589 |
+ swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd); |
|
8590 |
+ } |
|
8591 |
+ }, |
|
8592 |
+ onVisibilityChange: function onVisibilityChange() { |
|
8593 |
+ var swiper = this; |
|
8594 |
+ var document = getDocument(); |
|
8595 |
+ |
|
8596 |
+ if (document.visibilityState === 'hidden' && swiper.autoplay.running) { |
|
8597 |
+ swiper.autoplay.pause(); |
|
8598 |
+ } |
|
8599 |
+ |
|
8600 |
+ if (document.visibilityState === 'visible' && swiper.autoplay.paused) { |
|
8601 |
+ swiper.autoplay.run(); |
|
8602 |
+ swiper.autoplay.paused = false; |
|
8603 |
+ } |
|
8604 |
+ }, |
|
8605 |
+ onTransitionEnd: function onTransitionEnd(e) { |
|
8606 |
+ var swiper = this; |
|
8607 |
+ if (!swiper || swiper.destroyed || !swiper.$wrapperEl) return; |
|
8608 |
+ if (e.target !== swiper.$wrapperEl[0]) return; |
|
8609 |
+ swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.autoplay.onTransitionEnd); |
|
8610 |
+ swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd); |
|
8611 |
+ swiper.autoplay.paused = false; |
|
8612 |
+ |
|
8613 |
+ if (!swiper.autoplay.running) { |
|
8614 |
+ swiper.autoplay.stop(); |
|
8615 |
+ } else { |
|
8616 |
+ swiper.autoplay.run(); |
|
8617 |
+ } |
|
8618 |
+ } |
|
8619 |
+}; |
|
8620 |
+var Autoplay$1 = { |
|
8621 |
+ name: 'autoplay', |
|
8622 |
+ params: { |
|
8623 |
+ autoplay: { |
|
8624 |
+ enabled: false, |
|
8625 |
+ delay: 3000, |
|
8626 |
+ waitForTransition: true, |
|
8627 |
+ disableOnInteraction: true, |
|
8628 |
+ stopOnLastSlide: false, |
|
8629 |
+ reverseDirection: false |
|
8630 |
+ } |
|
8631 |
+ }, |
|
8632 |
+ create: function create() { |
|
8633 |
+ var swiper = this; |
|
8634 |
+ bindModuleMethods(swiper, { |
|
8635 |
+ autoplay: _extends(_extends({}, Autoplay), {}, { |
|
8636 |
+ running: false, |
|
8637 |
+ paused: false |
|
8638 |
+ }) |
|
8639 |
+ }); |
|
8640 |
+ }, |
|
8641 |
+ on: { |
|
8642 |
+ init: function init(swiper) { |
|
8643 |
+ if (swiper.params.autoplay.enabled) { |
|
8644 |
+ swiper.autoplay.start(); |
|
8645 |
+ var document = getDocument(); |
|
8646 |
+ document.addEventListener('visibilitychange', swiper.autoplay.onVisibilityChange); |
|
8647 |
+ } |
|
8648 |
+ }, |
|
8649 |
+ beforeTransitionStart: function beforeTransitionStart(swiper, speed, internal) { |
|
8650 |
+ if (swiper.autoplay.running) { |
|
8651 |
+ if (internal || !swiper.params.autoplay.disableOnInteraction) { |
|
8652 |
+ swiper.autoplay.pause(speed); |
|
8653 |
+ } else { |
|
8654 |
+ swiper.autoplay.stop(); |
|
8655 |
+ } |
|
8656 |
+ } |
|
8657 |
+ }, |
|
8658 |
+ sliderFirstMove: function sliderFirstMove(swiper) { |
|
8659 |
+ if (swiper.autoplay.running) { |
|
8660 |
+ if (swiper.params.autoplay.disableOnInteraction) { |
|
8661 |
+ swiper.autoplay.stop(); |
|
8662 |
+ } else { |
|
8663 |
+ swiper.autoplay.pause(); |
|
8664 |
+ } |
|
8665 |
+ } |
|
8666 |
+ }, |
|
8667 |
+ touchEnd: function touchEnd(swiper) { |
|
8668 |
+ if (swiper.params.cssMode && swiper.autoplay.paused && !swiper.params.autoplay.disableOnInteraction) { |
|
8669 |
+ swiper.autoplay.run(); |
|
8670 |
+ } |
|
8671 |
+ }, |
|
8672 |
+ destroy: function destroy(swiper) { |
|
8673 |
+ if (swiper.autoplay.running) { |
|
8674 |
+ swiper.autoplay.stop(); |
|
8675 |
+ } |
|
8676 |
+ |
|
8677 |
+ var document = getDocument(); |
|
8678 |
+ document.removeEventListener('visibilitychange', swiper.autoplay.onVisibilityChange); |
|
8679 |
+ } |
|
8680 |
+ } |
|
8681 |
+}; |
|
8682 |
+ |
|
8683 |
+var Fade = { |
|
8684 |
+ setTranslate: function setTranslate() { |
|
8685 |
+ var swiper = this; |
|
8686 |
+ var slides = swiper.slides; |
|
8687 |
+ |
|
8688 |
+ for (var i = 0; i < slides.length; i += 1) { |
|
8689 |
+ var $slideEl = swiper.slides.eq(i); |
|
8690 |
+ var offset = $slideEl[0].swiperSlideOffset; |
|
8691 |
+ var tx = -offset; |
|
8692 |
+ if (!swiper.params.virtualTranslate) tx -= swiper.translate; |
|
8693 |
+ var ty = 0; |
|
8694 |
+ |
|
8695 |
+ if (!swiper.isHorizontal()) { |
|
8696 |
+ ty = tx; |
|
8697 |
+ tx = 0; |
|
8698 |
+ } |
|
8699 |
+ |
|
8700 |
+ var slideOpacity = swiper.params.fadeEffect.crossFade ? Math.max(1 - Math.abs($slideEl[0].progress), 0) : 1 + Math.min(Math.max($slideEl[0].progress, -1), 0); |
|
8701 |
+ $slideEl.css({ |
|
8702 |
+ opacity: slideOpacity |
|
8703 |
+ }).transform("translate3d(" + tx + "px, " + ty + "px, 0px)"); |
|
8704 |
+ } |
|
8705 |
+ }, |
|
8706 |
+ setTransition: function setTransition(duration) { |
|
8707 |
+ var swiper = this; |
|
8708 |
+ var slides = swiper.slides, |
|
8709 |
+ $wrapperEl = swiper.$wrapperEl; |
|
8710 |
+ slides.transition(duration); |
|
8711 |
+ |
|
8712 |
+ if (swiper.params.virtualTranslate && duration !== 0) { |
|
8713 |
+ var eventTriggered = false; |
|
8714 |
+ slides.transitionEnd(function () { |
|
8715 |
+ if (eventTriggered) return; |
|
8716 |
+ if (!swiper || swiper.destroyed) return; |
|
8717 |
+ eventTriggered = true; |
|
8718 |
+ swiper.animating = false; |
|
8719 |
+ var triggerEvents = ['webkitTransitionEnd', 'transitionend']; |
|
8720 |
+ |
|
8721 |
+ for (var i = 0; i < triggerEvents.length; i += 1) { |
|
8722 |
+ $wrapperEl.trigger(triggerEvents[i]); |
|
8723 |
+ } |
|
8724 |
+ }); |
|
8725 |
+ } |
|
8726 |
+ } |
|
8727 |
+}; |
|
8728 |
+var EffectFade = { |
|
8729 |
+ name: 'effect-fade', |
|
8730 |
+ params: { |
|
8731 |
+ fadeEffect: { |
|
8732 |
+ crossFade: false |
|
8733 |
+ } |
|
8734 |
+ }, |
|
8735 |
+ create: function create() { |
|
8736 |
+ var swiper = this; |
|
8737 |
+ bindModuleMethods(swiper, { |
|
8738 |
+ fadeEffect: _extends({}, Fade) |
|
8739 |
+ }); |
|
8740 |
+ }, |
|
8741 |
+ on: { |
|
8742 |
+ beforeInit: function beforeInit(swiper) { |
|
8743 |
+ if (swiper.params.effect !== 'fade') return; |
|
8744 |
+ swiper.classNames.push(swiper.params.containerModifierClass + "fade"); |
|
8745 |
+ var overwriteParams = { |
|
8746 |
+ slidesPerView: 1, |
|
8747 |
+ slidesPerColumn: 1, |
|
8748 |
+ slidesPerGroup: 1, |
|
8749 |
+ watchSlidesProgress: true, |
|
8750 |
+ spaceBetween: 0, |
|
8751 |
+ virtualTranslate: true |
|
8752 |
+ }; |
|
8753 |
+ extend$1(swiper.params, overwriteParams); |
|
8754 |
+ extend$1(swiper.originalParams, overwriteParams); |
|
8755 |
+ }, |
|
8756 |
+ setTranslate: function setTranslate(swiper) { |
|
8757 |
+ if (swiper.params.effect !== 'fade') return; |
|
8758 |
+ swiper.fadeEffect.setTranslate(); |
|
8759 |
+ }, |
|
8760 |
+ setTransition: function setTransition(swiper, duration) { |
|
8761 |
+ if (swiper.params.effect !== 'fade') return; |
|
8762 |
+ swiper.fadeEffect.setTransition(duration); |
|
8763 |
+ } |
|
8764 |
+ } |
|
8765 |
+}; |
|
8766 |
+ |
|
8767 |
+var Cube = { |
|
8768 |
+ setTranslate: function setTranslate() { |
|
8769 |
+ var swiper = this; |
|
8770 |
+ var $el = swiper.$el, |
|
8771 |
+ $wrapperEl = swiper.$wrapperEl, |
|
8772 |
+ slides = swiper.slides, |
|
8773 |
+ swiperWidth = swiper.width, |
|
8774 |
+ swiperHeight = swiper.height, |
|
8775 |
+ rtl = swiper.rtlTranslate, |
|
8776 |
+ swiperSize = swiper.size, |
|
8777 |
+ browser = swiper.browser; |
|
8778 |
+ var params = swiper.params.cubeEffect; |
|
8779 |
+ var isHorizontal = swiper.isHorizontal(); |
|
8780 |
+ var isVirtual = swiper.virtual && swiper.params.virtual.enabled; |
|
8781 |
+ var wrapperRotate = 0; |
|
8782 |
+ var $cubeShadowEl; |
|
8783 |
+ |
|
8784 |
+ if (params.shadow) { |
|
8785 |
+ if (isHorizontal) { |
|
8786 |
+ $cubeShadowEl = $wrapperEl.find('.swiper-cube-shadow'); |
|
8787 |
+ |
|
8788 |
+ if ($cubeShadowEl.length === 0) { |
|
8789 |
+ $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>'); |
|
8790 |
+ $wrapperEl.append($cubeShadowEl); |
|
8791 |
+ } |
|
8792 |
+ |
|
8793 |
+ $cubeShadowEl.css({ |
|
8794 |
+ height: swiperWidth + "px" |
|
8795 |
+ }); |
|
8796 |
+ } else { |
|
8797 |
+ $cubeShadowEl = $el.find('.swiper-cube-shadow'); |
|
8798 |
+ |
|
8799 |
+ if ($cubeShadowEl.length === 0) { |
|
8800 |
+ $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>'); |
|
8801 |
+ $el.append($cubeShadowEl); |
|
8802 |
+ } |
|
8803 |
+ } |
|
8804 |
+ } |
|
8805 |
+ |
|
8806 |
+ for (var i = 0; i < slides.length; i += 1) { |
|
8807 |
+ var $slideEl = slides.eq(i); |
|
8808 |
+ var slideIndex = i; |
|
8809 |
+ |
|
8810 |
+ if (isVirtual) { |
|
8811 |
+ slideIndex = parseInt($slideEl.attr('data-swiper-slide-index'), 10); |
|
8812 |
+ } |
|
8813 |
+ |
|
8814 |
+ var slideAngle = slideIndex * 90; |
|
8815 |
+ var round = Math.floor(slideAngle / 360); |
|
8816 |
+ |
|
8817 |
+ if (rtl) { |
|
8818 |
+ slideAngle = -slideAngle; |
|
8819 |
+ round = Math.floor(-slideAngle / 360); |
|
8820 |
+ } |
|
8821 |
+ |
|
8822 |
+ var progress = Math.max(Math.min($slideEl[0].progress, 1), -1); |
|
8823 |
+ var tx = 0; |
|
8824 |
+ var ty = 0; |
|
8825 |
+ var tz = 0; |
|
8826 |
+ |
|
8827 |
+ if (slideIndex % 4 === 0) { |
|
8828 |
+ tx = -round * 4 * swiperSize; |
|
8829 |
+ tz = 0; |
|
8830 |
+ } else if ((slideIndex - 1) % 4 === 0) { |
|
8831 |
+ tx = 0; |
|
8832 |
+ tz = -round * 4 * swiperSize; |
|
8833 |
+ } else if ((slideIndex - 2) % 4 === 0) { |
|
8834 |
+ tx = swiperSize + round * 4 * swiperSize; |
|
8835 |
+ tz = swiperSize; |
|
8836 |
+ } else if ((slideIndex - 3) % 4 === 0) { |
|
8837 |
+ tx = -swiperSize; |
|
8838 |
+ tz = 3 * swiperSize + swiperSize * 4 * round; |
|
8839 |
+ } |
|
8840 |
+ |
|
8841 |
+ if (rtl) { |
|
8842 |
+ tx = -tx; |
|
8843 |
+ } |
|
8844 |
+ |
|
8845 |
+ if (!isHorizontal) { |
|
8846 |
+ ty = tx; |
|
8847 |
+ tx = 0; |
|
8848 |
+ } |
|
8849 |
+ |
|
8850 |
+ var transform = "rotateX(" + (isHorizontal ? 0 : -slideAngle) + "deg) rotateY(" + (isHorizontal ? slideAngle : 0) + "deg) translate3d(" + tx + "px, " + ty + "px, " + tz + "px)"; |
|
8851 |
+ |
|
8852 |
+ if (progress <= 1 && progress > -1) { |
|
8853 |
+ wrapperRotate = slideIndex * 90 + progress * 90; |
|
8854 |
+ if (rtl) wrapperRotate = -slideIndex * 90 - progress * 90; |
|
8855 |
+ } |
|
8856 |
+ |
|
8857 |
+ $slideEl.transform(transform); |
|
8858 |
+ |
|
8859 |
+ if (params.slideShadows) { |
|
8860 |
+ // Set shadows |
|
8861 |
+ var shadowBefore = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); |
|
8862 |
+ var shadowAfter = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); |
|
8863 |
+ |
|
8864 |
+ if (shadowBefore.length === 0) { |
|
8865 |
+ shadowBefore = $("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>"); |
|
8866 |
+ $slideEl.append(shadowBefore); |
|
8867 |
+ } |
|
8868 |
+ |
|
8869 |
+ if (shadowAfter.length === 0) { |
|
8870 |
+ shadowAfter = $("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>"); |
|
8871 |
+ $slideEl.append(shadowAfter); |
|
8872 |
+ } |
|
8873 |
+ |
|
8874 |
+ if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0); |
|
8875 |
+ if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0); |
|
8876 |
+ } |
|
8877 |
+ } |
|
8878 |
+ |
|
8879 |
+ $wrapperEl.css({ |
|
8880 |
+ '-webkit-transform-origin': "50% 50% -" + swiperSize / 2 + "px", |
|
8881 |
+ '-moz-transform-origin': "50% 50% -" + swiperSize / 2 + "px", |
|
8882 |
+ '-ms-transform-origin': "50% 50% -" + swiperSize / 2 + "px", |
|
8883 |
+ 'transform-origin': "50% 50% -" + swiperSize / 2 + "px" |
|
8884 |
+ }); |
|
8885 |
+ |
|
8886 |
+ if (params.shadow) { |
|
8887 |
+ if (isHorizontal) { |
|
8888 |
+ $cubeShadowEl.transform("translate3d(0px, " + (swiperWidth / 2 + params.shadowOffset) + "px, " + -swiperWidth / 2 + "px) rotateX(90deg) rotateZ(0deg) scale(" + params.shadowScale + ")"); |
|
8889 |
+ } else { |
|
8890 |
+ var shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90; |
|
8891 |
+ var multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2); |
|
8892 |
+ var scale1 = params.shadowScale; |
|
8893 |
+ var scale2 = params.shadowScale / multiplier; |
|
8894 |
+ var offset = params.shadowOffset; |
|
8895 |
+ $cubeShadowEl.transform("scale3d(" + scale1 + ", 1, " + scale2 + ") translate3d(0px, " + (swiperHeight / 2 + offset) + "px, " + -swiperHeight / 2 / scale2 + "px) rotateX(-90deg)"); |
|
8896 |
+ } |
|
8897 |
+ } |
|
8898 |
+ |
|
8899 |
+ var zFactor = browser.isSafari || browser.isWebView ? -swiperSize / 2 : 0; |
|
8900 |
+ $wrapperEl.transform("translate3d(0px,0," + zFactor + "px) rotateX(" + (swiper.isHorizontal() ? 0 : wrapperRotate) + "deg) rotateY(" + (swiper.isHorizontal() ? -wrapperRotate : 0) + "deg)"); |
|
8901 |
+ }, |
|
8902 |
+ setTransition: function setTransition(duration) { |
|
8903 |
+ var swiper = this; |
|
8904 |
+ var $el = swiper.$el, |
|
8905 |
+ slides = swiper.slides; |
|
8906 |
+ slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); |
|
8907 |
+ |
|
8908 |
+ if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) { |
|
8909 |
+ $el.find('.swiper-cube-shadow').transition(duration); |
|
8910 |
+ } |
|
8911 |
+ } |
|
8912 |
+}; |
|
8913 |
+var EffectCube = { |
|
8914 |
+ name: 'effect-cube', |
|
8915 |
+ params: { |
|
8916 |
+ cubeEffect: { |
|
8917 |
+ slideShadows: true, |
|
8918 |
+ shadow: true, |
|
8919 |
+ shadowOffset: 20, |
|
8920 |
+ shadowScale: 0.94 |
|
8921 |
+ } |
|
8922 |
+ }, |
|
8923 |
+ create: function create() { |
|
8924 |
+ var swiper = this; |
|
8925 |
+ bindModuleMethods(swiper, { |
|
8926 |
+ cubeEffect: _extends({}, Cube) |
|
8927 |
+ }); |
|
8928 |
+ }, |
|
8929 |
+ on: { |
|
8930 |
+ beforeInit: function beforeInit(swiper) { |
|
8931 |
+ if (swiper.params.effect !== 'cube') return; |
|
8932 |
+ swiper.classNames.push(swiper.params.containerModifierClass + "cube"); |
|
8933 |
+ swiper.classNames.push(swiper.params.containerModifierClass + "3d"); |
|
8934 |
+ var overwriteParams = { |
|
8935 |
+ slidesPerView: 1, |
|
8936 |
+ slidesPerColumn: 1, |
|
8937 |
+ slidesPerGroup: 1, |
|
8938 |
+ watchSlidesProgress: true, |
|
8939 |
+ resistanceRatio: 0, |
|
8940 |
+ spaceBetween: 0, |
|
8941 |
+ centeredSlides: false, |
|
8942 |
+ virtualTranslate: true |
|
8943 |
+ }; |
|
8944 |
+ extend$1(swiper.params, overwriteParams); |
|
8945 |
+ extend$1(swiper.originalParams, overwriteParams); |
|
8946 |
+ }, |
|
8947 |
+ setTranslate: function setTranslate(swiper) { |
|
8948 |
+ if (swiper.params.effect !== 'cube') return; |
|
8949 |
+ swiper.cubeEffect.setTranslate(); |
|
8950 |
+ }, |
|
8951 |
+ setTransition: function setTransition(swiper, duration) { |
|
8952 |
+ if (swiper.params.effect !== 'cube') return; |
|
8953 |
+ swiper.cubeEffect.setTransition(duration); |
|
8954 |
+ } |
|
8955 |
+ } |
|
8956 |
+}; |
|
8957 |
+ |
|
8958 |
+var Flip = { |
|
8959 |
+ setTranslate: function setTranslate() { |
|
8960 |
+ var swiper = this; |
|
8961 |
+ var slides = swiper.slides, |
|
8962 |
+ rtl = swiper.rtlTranslate; |
|
8963 |
+ |
|
8964 |
+ for (var i = 0; i < slides.length; i += 1) { |
|
8965 |
+ var $slideEl = slides.eq(i); |
|
8966 |
+ var progress = $slideEl[0].progress; |
|
8967 |
+ |
|
8968 |
+ if (swiper.params.flipEffect.limitRotation) { |
|
8969 |
+ progress = Math.max(Math.min($slideEl[0].progress, 1), -1); |
|
8970 |
+ } |
|
8971 |
+ |
|
8972 |
+ var offset = $slideEl[0].swiperSlideOffset; |
|
8973 |
+ var rotate = -180 * progress; |
|
8974 |
+ var rotateY = rotate; |
|
8975 |
+ var rotateX = 0; |
|
8976 |
+ var tx = -offset; |
|
8977 |
+ var ty = 0; |
|
8978 |
+ |
|
8979 |
+ if (!swiper.isHorizontal()) { |
|
8980 |
+ ty = tx; |
|
8981 |
+ tx = 0; |
|
8982 |
+ rotateX = -rotateY; |
|
8983 |
+ rotateY = 0; |
|
8984 |
+ } else if (rtl) { |
|
8985 |
+ rotateY = -rotateY; |
|
8986 |
+ } |
|
8987 |
+ |
|
8988 |
+ $slideEl[0].style.zIndex = -Math.abs(Math.round(progress)) + slides.length; |
|
8989 |
+ |
|
8990 |
+ if (swiper.params.flipEffect.slideShadows) { |
|
8991 |
+ // Set shadows |
|
8992 |
+ var shadowBefore = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); |
|
8993 |
+ var shadowAfter = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); |
|
8994 |
+ |
|
8995 |
+ if (shadowBefore.length === 0) { |
|
8996 |
+ shadowBefore = $("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'left' : 'top') + "\"></div>"); |
|
8997 |
+ $slideEl.append(shadowBefore); |
|
8998 |
+ } |
|
8999 |
+ |
|
9000 |
+ if (shadowAfter.length === 0) { |
|
9001 |
+ shadowAfter = $("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'right' : 'bottom') + "\"></div>"); |
|
9002 |
+ $slideEl.append(shadowAfter); |
|
9003 |
+ } |
|
9004 |
+ |
|
9005 |
+ if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0); |
|
9006 |
+ if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0); |
|
9007 |
+ } |
|
9008 |
+ |
|
9009 |
+ $slideEl.transform("translate3d(" + tx + "px, " + ty + "px, 0px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg)"); |
|
9010 |
+ } |
|
9011 |
+ }, |
|
9012 |
+ setTransition: function setTransition(duration) { |
|
9013 |
+ var swiper = this; |
|
9014 |
+ var slides = swiper.slides, |
|
9015 |
+ activeIndex = swiper.activeIndex, |
|
9016 |
+ $wrapperEl = swiper.$wrapperEl; |
|
9017 |
+ slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); |
|
9018 |
+ |
|
9019 |
+ if (swiper.params.virtualTranslate && duration !== 0) { |
|
9020 |
+ var eventTriggered = false; // eslint-disable-next-line |
|
9021 |
+ |
|
9022 |
+ slides.eq(activeIndex).transitionEnd(function onTransitionEnd() { |
|
9023 |
+ if (eventTriggered) return; |
|
9024 |
+ if (!swiper || swiper.destroyed) return; // if (!$(this).hasClass(swiper.params.slideActiveClass)) return; |
|
9025 |
+ |
|
9026 |
+ eventTriggered = true; |
|
9027 |
+ swiper.animating = false; |
|
9028 |
+ var triggerEvents = ['webkitTransitionEnd', 'transitionend']; |
|
9029 |
+ |
|
9030 |
+ for (var i = 0; i < triggerEvents.length; i += 1) { |
|
9031 |
+ $wrapperEl.trigger(triggerEvents[i]); |
|
9032 |
+ } |
|
9033 |
+ }); |
|
9034 |
+ } |
|
9035 |
+ } |
|
9036 |
+}; |
|
9037 |
+var EffectFlip = { |
|
9038 |
+ name: 'effect-flip', |
|
9039 |
+ params: { |
|
9040 |
+ flipEffect: { |
|
9041 |
+ slideShadows: true, |
|
9042 |
+ limitRotation: true |
|
9043 |
+ } |
|
9044 |
+ }, |
|
9045 |
+ create: function create() { |
|
9046 |
+ var swiper = this; |
|
9047 |
+ bindModuleMethods(swiper, { |
|
9048 |
+ flipEffect: _extends({}, Flip) |
|
9049 |
+ }); |
|
9050 |
+ }, |
|
9051 |
+ on: { |
|
9052 |
+ beforeInit: function beforeInit(swiper) { |
|
9053 |
+ if (swiper.params.effect !== 'flip') return; |
|
9054 |
+ swiper.classNames.push(swiper.params.containerModifierClass + "flip"); |
|
9055 |
+ swiper.classNames.push(swiper.params.containerModifierClass + "3d"); |
|
9056 |
+ var overwriteParams = { |
|
9057 |
+ slidesPerView: 1, |
|
9058 |
+ slidesPerColumn: 1, |
|
9059 |
+ slidesPerGroup: 1, |
|
9060 |
+ watchSlidesProgress: true, |
|
9061 |
+ spaceBetween: 0, |
|
9062 |
+ virtualTranslate: true |
|
9063 |
+ }; |
|
9064 |
+ extend$1(swiper.params, overwriteParams); |
|
9065 |
+ extend$1(swiper.originalParams, overwriteParams); |
|
9066 |
+ }, |
|
9067 |
+ setTranslate: function setTranslate(swiper) { |
|
9068 |
+ if (swiper.params.effect !== 'flip') return; |
|
9069 |
+ swiper.flipEffect.setTranslate(); |
|
9070 |
+ }, |
|
9071 |
+ setTransition: function setTransition(swiper, duration) { |
|
9072 |
+ if (swiper.params.effect !== 'flip') return; |
|
9073 |
+ swiper.flipEffect.setTransition(duration); |
|
9074 |
+ } |
|
9075 |
+ } |
|
9076 |
+}; |
|
9077 |
+ |
|
9078 |
+var Coverflow = { |
|
9079 |
+ setTranslate: function setTranslate() { |
|
9080 |
+ var swiper = this; |
|
9081 |
+ var swiperWidth = swiper.width, |
|
9082 |
+ swiperHeight = swiper.height, |
|
9083 |
+ slides = swiper.slides, |
|
9084 |
+ slidesSizesGrid = swiper.slidesSizesGrid; |
|
9085 |
+ var params = swiper.params.coverflowEffect; |
|
9086 |
+ var isHorizontal = swiper.isHorizontal(); |
|
9087 |
+ var transform = swiper.translate; |
|
9088 |
+ var center = isHorizontal ? -transform + swiperWidth / 2 : -transform + swiperHeight / 2; |
|
9089 |
+ var rotate = isHorizontal ? params.rotate : -params.rotate; |
|
9090 |
+ var translate = params.depth; // Each slide offset from center |
|
9091 |
+ |
|
9092 |
+ for (var i = 0, length = slides.length; i < length; i += 1) { |
|
9093 |
+ var $slideEl = slides.eq(i); |
|
9094 |
+ var slideSize = slidesSizesGrid[i]; |
|
9095 |
+ var slideOffset = $slideEl[0].swiperSlideOffset; |
|
9096 |
+ var offsetMultiplier = (center - slideOffset - slideSize / 2) / slideSize * params.modifier; |
|
9097 |
+ var rotateY = isHorizontal ? rotate * offsetMultiplier : 0; |
|
9098 |
+ var rotateX = isHorizontal ? 0 : rotate * offsetMultiplier; // var rotateZ = 0 |
|
9099 |
+ |
|
9100 |
+ var translateZ = -translate * Math.abs(offsetMultiplier); |
|
9101 |
+ var stretch = params.stretch; // Allow percentage to make a relative stretch for responsive sliders |
|
9102 |
+ |
|
9103 |
+ if (typeof stretch === 'string' && stretch.indexOf('%') !== -1) { |
|
9104 |
+ stretch = parseFloat(params.stretch) / 100 * slideSize; |
|
9105 |
+ } |
|
9106 |
+ |
|
9107 |
+ var translateY = isHorizontal ? 0 : stretch * offsetMultiplier; |
|
9108 |
+ var translateX = isHorizontal ? stretch * offsetMultiplier : 0; |
|
9109 |
+ var scale = 1 - (1 - params.scale) * Math.abs(offsetMultiplier); // Fix for ultra small values |
|
9110 |
+ |
|
9111 |
+ if (Math.abs(translateX) < 0.001) translateX = 0; |
|
9112 |
+ if (Math.abs(translateY) < 0.001) translateY = 0; |
|
9113 |
+ if (Math.abs(translateZ) < 0.001) translateZ = 0; |
|
9114 |
+ if (Math.abs(rotateY) < 0.001) rotateY = 0; |
|
9115 |
+ if (Math.abs(rotateX) < 0.001) rotateX = 0; |
|
9116 |
+ if (Math.abs(scale) < 0.001) scale = 0; |
|
9117 |
+ var slideTransform = "translate3d(" + translateX + "px," + translateY + "px," + translateZ + "px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg) scale(" + scale + ")"; |
|
9118 |
+ $slideEl.transform(slideTransform); |
|
9119 |
+ $slideEl[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1; |
|
9120 |
+ |
|
9121 |
+ if (params.slideShadows) { |
|
9122 |
+ // Set shadows |
|
9123 |
+ var $shadowBeforeEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); |
|
9124 |
+ var $shadowAfterEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); |
|
9125 |
+ |
|
9126 |
+ if ($shadowBeforeEl.length === 0) { |
|
9127 |
+ $shadowBeforeEl = $("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>"); |
|
9128 |
+ $slideEl.append($shadowBeforeEl); |
|
9129 |
+ } |
|
9130 |
+ |
|
9131 |
+ if ($shadowAfterEl.length === 0) { |
|
9132 |
+ $shadowAfterEl = $("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>"); |
|
9133 |
+ $slideEl.append($shadowAfterEl); |
|
9134 |
+ } |
|
9135 |
+ |
|
9136 |
+ if ($shadowBeforeEl.length) $shadowBeforeEl[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0; |
|
9137 |
+ if ($shadowAfterEl.length) $shadowAfterEl[0].style.opacity = -offsetMultiplier > 0 ? -offsetMultiplier : 0; |
|
9138 |
+ } |
|
9139 |
+ } |
|
9140 |
+ }, |
|
9141 |
+ setTransition: function setTransition(duration) { |
|
9142 |
+ var swiper = this; |
|
9143 |
+ swiper.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); |
|
9144 |
+ } |
|
9145 |
+}; |
|
9146 |
+var EffectCoverflow = { |
|
9147 |
+ name: 'effect-coverflow', |
|
9148 |
+ params: { |
|
9149 |
+ coverflowEffect: { |
|
9150 |
+ rotate: 50, |
|
9151 |
+ stretch: 0, |
|
9152 |
+ depth: 100, |
|
9153 |
+ scale: 1, |
|
9154 |
+ modifier: 1, |
|
9155 |
+ slideShadows: true |
|
9156 |
+ } |
|
9157 |
+ }, |
|
9158 |
+ create: function create() { |
|
9159 |
+ var swiper = this; |
|
9160 |
+ bindModuleMethods(swiper, { |
|
9161 |
+ coverflowEffect: _extends({}, Coverflow) |
|
9162 |
+ }); |
|
9163 |
+ }, |
|
9164 |
+ on: { |
|
9165 |
+ beforeInit: function beforeInit(swiper) { |
|
9166 |
+ if (swiper.params.effect !== 'coverflow') return; |
|
9167 |
+ swiper.classNames.push(swiper.params.containerModifierClass + "coverflow"); |
|
9168 |
+ swiper.classNames.push(swiper.params.containerModifierClass + "3d"); |
|
9169 |
+ swiper.params.watchSlidesProgress = true; |
|
9170 |
+ swiper.originalParams.watchSlidesProgress = true; |
|
9171 |
+ }, |
|
9172 |
+ setTranslate: function setTranslate(swiper) { |
|
9173 |
+ if (swiper.params.effect !== 'coverflow') return; |
|
9174 |
+ swiper.coverflowEffect.setTranslate(); |
|
9175 |
+ }, |
|
9176 |
+ setTransition: function setTransition(swiper, duration) { |
|
9177 |
+ if (swiper.params.effect !== 'coverflow') return; |
|
9178 |
+ swiper.coverflowEffect.setTransition(duration); |
|
9179 |
+ } |
|
9180 |
+ } |
|
9181 |
+}; |
|
9182 |
+ |
|
9183 |
+var Thumbs = { |
|
9184 |
+ init: function init() { |
|
9185 |
+ var swiper = this; |
|
9186 |
+ var thumbsParams = swiper.params.thumbs; |
|
9187 |
+ if (swiper.thumbs.initialized) return false; |
|
9188 |
+ swiper.thumbs.initialized = true; |
|
9189 |
+ var SwiperClass = swiper.constructor; |
|
9190 |
+ |
|
9191 |
+ if (thumbsParams.swiper instanceof SwiperClass) { |
|
9192 |
+ swiper.thumbs.swiper = thumbsParams.swiper; |
|
9193 |
+ extend$1(swiper.thumbs.swiper.originalParams, { |
|
9194 |
+ watchSlidesProgress: true, |
|
9195 |
+ slideToClickedSlide: false |
|
9196 |
+ }); |
|
9197 |
+ extend$1(swiper.thumbs.swiper.params, { |
|
9198 |
+ watchSlidesProgress: true, |
|
9199 |
+ slideToClickedSlide: false |
|
9200 |
+ }); |
|
9201 |
+ } else if (isObject$1(thumbsParams.swiper)) { |
|
9202 |
+ swiper.thumbs.swiper = new SwiperClass(extend$1({}, thumbsParams.swiper, { |
|
9203 |
+ watchSlidesVisibility: true, |
|
9204 |
+ watchSlidesProgress: true, |
|
9205 |
+ slideToClickedSlide: false |
|
9206 |
+ })); |
|
9207 |
+ swiper.thumbs.swiperCreated = true; |
|
9208 |
+ } |
|
9209 |
+ |
|
9210 |
+ swiper.thumbs.swiper.$el.addClass(swiper.params.thumbs.thumbsContainerClass); |
|
9211 |
+ swiper.thumbs.swiper.on('tap', swiper.thumbs.onThumbClick); |
|
9212 |
+ return true; |
|
9213 |
+ }, |
|
9214 |
+ onThumbClick: function onThumbClick() { |
|
9215 |
+ var swiper = this; |
|
9216 |
+ var thumbsSwiper = swiper.thumbs.swiper; |
|
9217 |
+ if (!thumbsSwiper) return; |
|
9218 |
+ var clickedIndex = thumbsSwiper.clickedIndex; |
|
9219 |
+ var clickedSlide = thumbsSwiper.clickedSlide; |
|
9220 |
+ if (clickedSlide && $(clickedSlide).hasClass(swiper.params.thumbs.slideThumbActiveClass)) return; |
|
9221 |
+ if (typeof clickedIndex === 'undefined' || clickedIndex === null) return; |
|
9222 |
+ var slideToIndex; |
|
9223 |
+ |
|
9224 |
+ if (thumbsSwiper.params.loop) { |
|
9225 |
+ slideToIndex = parseInt($(thumbsSwiper.clickedSlide).attr('data-swiper-slide-index'), 10); |
|
9226 |
+ } else { |
|
9227 |
+ slideToIndex = clickedIndex; |
|
9228 |
+ } |
|
9229 |
+ |
|
9230 |
+ if (swiper.params.loop) { |
|
9231 |
+ var currentIndex = swiper.activeIndex; |
|
9232 |
+ |
|
9233 |
+ if (swiper.slides.eq(currentIndex).hasClass(swiper.params.slideDuplicateClass)) { |
|
9234 |
+ swiper.loopFix(); // eslint-disable-next-line |
|
9235 |
+ |
|
9236 |
+ swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; |
|
9237 |
+ currentIndex = swiper.activeIndex; |
|
9238 |
+ } |
|
9239 |
+ |
|
9240 |
+ var prevIndex = swiper.slides.eq(currentIndex).prevAll("[data-swiper-slide-index=\"" + slideToIndex + "\"]").eq(0).index(); |
|
9241 |
+ var nextIndex = swiper.slides.eq(currentIndex).nextAll("[data-swiper-slide-index=\"" + slideToIndex + "\"]").eq(0).index(); |
|
9242 |
+ if (typeof prevIndex === 'undefined') slideToIndex = nextIndex;else if (typeof nextIndex === 'undefined') slideToIndex = prevIndex;else if (nextIndex - currentIndex < currentIndex - prevIndex) slideToIndex = nextIndex;else slideToIndex = prevIndex; |
|
9243 |
+ } |
|
9244 |
+ |
|
9245 |
+ swiper.slideTo(slideToIndex); |
|
9246 |
+ }, |
|
9247 |
+ update: function update(initial) { |
|
9248 |
+ var swiper = this; |
|
9249 |
+ var thumbsSwiper = swiper.thumbs.swiper; |
|
9250 |
+ if (!thumbsSwiper) return; |
|
9251 |
+ var slidesPerView = thumbsSwiper.params.slidesPerView === 'auto' ? thumbsSwiper.slidesPerViewDynamic() : thumbsSwiper.params.slidesPerView; |
|
9252 |
+ var autoScrollOffset = swiper.params.thumbs.autoScrollOffset; |
|
9253 |
+ var useOffset = autoScrollOffset && !thumbsSwiper.params.loop; |
|
9254 |
+ |
|
9255 |
+ if (swiper.realIndex !== thumbsSwiper.realIndex || useOffset) { |
|
9256 |
+ var currentThumbsIndex = thumbsSwiper.activeIndex; |
|
9257 |
+ var newThumbsIndex; |
|
9258 |
+ var direction; |
|
9259 |
+ |
|
9260 |
+ if (thumbsSwiper.params.loop) { |
|
9261 |
+ if (thumbsSwiper.slides.eq(currentThumbsIndex).hasClass(thumbsSwiper.params.slideDuplicateClass)) { |
|
9262 |
+ thumbsSwiper.loopFix(); // eslint-disable-next-line |
|
9263 |
+ |
|
9264 |
+ thumbsSwiper._clientLeft = thumbsSwiper.$wrapperEl[0].clientLeft; |
|
9265 |
+ currentThumbsIndex = thumbsSwiper.activeIndex; |
|
9266 |
+ } // Find actual thumbs index to slide to |
|
9267 |
+ |
|
9268 |
+ |
|
9269 |
+ var prevThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).prevAll("[data-swiper-slide-index=\"" + swiper.realIndex + "\"]").eq(0).index(); |
|
9270 |
+ var nextThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).nextAll("[data-swiper-slide-index=\"" + swiper.realIndex + "\"]").eq(0).index(); |
|
9271 |
+ if (typeof prevThumbsIndex === 'undefined') newThumbsIndex = nextThumbsIndex;else if (typeof nextThumbsIndex === 'undefined') newThumbsIndex = prevThumbsIndex;else if (nextThumbsIndex - currentThumbsIndex === currentThumbsIndex - prevThumbsIndex) newThumbsIndex = currentThumbsIndex;else if (nextThumbsIndex - currentThumbsIndex < currentThumbsIndex - prevThumbsIndex) newThumbsIndex = nextThumbsIndex;else newThumbsIndex = prevThumbsIndex; |
|
9272 |
+ direction = swiper.activeIndex > swiper.previousIndex ? 'next' : 'prev'; |
|
9273 |
+ } else { |
|
9274 |
+ newThumbsIndex = swiper.realIndex; |
|
9275 |
+ direction = newThumbsIndex > swiper.previousIndex ? 'next' : 'prev'; |
|
9276 |
+ } |
|
9277 |
+ |
|
9278 |
+ if (useOffset) { |
|
9279 |
+ newThumbsIndex += direction === 'next' ? autoScrollOffset : -1 * autoScrollOffset; |
|
9280 |
+ } |
|
9281 |
+ |
|
9282 |
+ if (thumbsSwiper.visibleSlidesIndexes && thumbsSwiper.visibleSlidesIndexes.indexOf(newThumbsIndex) < 0) { |
|
9283 |
+ if (thumbsSwiper.params.centeredSlides) { |
|
9284 |
+ if (newThumbsIndex > currentThumbsIndex) { |
|
9285 |
+ newThumbsIndex = newThumbsIndex - Math.floor(slidesPerView / 2) + 1; |
|
9286 |
+ } else { |
|
9287 |
+ newThumbsIndex = newThumbsIndex + Math.floor(slidesPerView / 2) - 1; |
|
9288 |
+ } |
|
9289 |
+ } else if (newThumbsIndex > currentThumbsIndex) { |
|
9290 |
+ newThumbsIndex = newThumbsIndex - slidesPerView + 1; |
|
9291 |
+ } |
|
9292 |
+ |
|
9293 |
+ thumbsSwiper.slideTo(newThumbsIndex, initial ? 0 : undefined); |
|
9294 |
+ } |
|
9295 |
+ } // Activate thumbs |
|
9296 |
+ |
|
9297 |
+ |
|
9298 |
+ var thumbsToActivate = 1; |
|
9299 |
+ var thumbActiveClass = swiper.params.thumbs.slideThumbActiveClass; |
|
9300 |
+ |
|
9301 |
+ if (swiper.params.slidesPerView > 1 && !swiper.params.centeredSlides) { |
|
9302 |
+ thumbsToActivate = swiper.params.slidesPerView; |
|
9303 |
+ } |
|
9304 |
+ |
|
9305 |
+ if (!swiper.params.thumbs.multipleActiveThumbs) { |
|
9306 |
+ thumbsToActivate = 1; |
|
9307 |
+ } |
|
9308 |
+ |
|
9309 |
+ thumbsToActivate = Math.floor(thumbsToActivate); |
|
9310 |
+ thumbsSwiper.slides.removeClass(thumbActiveClass); |
|
9311 |
+ |
|
9312 |
+ if (thumbsSwiper.params.loop || thumbsSwiper.params.virtual && thumbsSwiper.params.virtual.enabled) { |
|
9313 |
+ for (var i = 0; i < thumbsToActivate; i += 1) { |
|
9314 |
+ thumbsSwiper.$wrapperEl.children("[data-swiper-slide-index=\"" + (swiper.realIndex + i) + "\"]").addClass(thumbActiveClass); |
|
9315 |
+ } |
|
9316 |
+ } else { |
|
9317 |
+ for (var _i = 0; _i < thumbsToActivate; _i += 1) { |
|
9318 |
+ thumbsSwiper.slides.eq(swiper.realIndex + _i).addClass(thumbActiveClass); |
|
9319 |
+ } |
|
9320 |
+ } |
|
9321 |
+ } |
|
9322 |
+}; |
|
9323 |
+var Thumbs$1 = { |
|
9324 |
+ name: 'thumbs', |
|
9325 |
+ params: { |
|
9326 |
+ thumbs: { |
|
9327 |
+ swiper: null, |
|
9328 |
+ multipleActiveThumbs: true, |
|
9329 |
+ autoScrollOffset: 0, |
|
9330 |
+ slideThumbActiveClass: 'swiper-slide-thumb-active', |
|
9331 |
+ thumbsContainerClass: 'swiper-container-thumbs' |
|
9332 |
+ } |
|
9333 |
+ }, |
|
9334 |
+ create: function create() { |
|
9335 |
+ var swiper = this; |
|
9336 |
+ bindModuleMethods(swiper, { |
|
9337 |
+ thumbs: _extends({ |
|
9338 |
+ swiper: null, |
|
9339 |
+ initialized: false |
|
9340 |
+ }, Thumbs) |
|
9341 |
+ }); |
|
9342 |
+ }, |
|
9343 |
+ on: { |
|
9344 |
+ beforeInit: function beforeInit(swiper) { |
|
9345 |
+ var thumbs = swiper.params.thumbs; |
|
9346 |
+ if (!thumbs || !thumbs.swiper) return; |
|
9347 |
+ swiper.thumbs.init(); |
|
9348 |
+ swiper.thumbs.update(true); |
|
9349 |
+ }, |
|
9350 |
+ slideChange: function slideChange(swiper) { |
|
9351 |
+ if (!swiper.thumbs.swiper) return; |
|
9352 |
+ swiper.thumbs.update(); |
|
9353 |
+ }, |
|
9354 |
+ update: function update(swiper) { |
|
9355 |
+ if (!swiper.thumbs.swiper) return; |
|
9356 |
+ swiper.thumbs.update(); |
|
9357 |
+ }, |
|
9358 |
+ resize: function resize(swiper) { |
|
9359 |
+ if (!swiper.thumbs.swiper) return; |
|
9360 |
+ swiper.thumbs.update(); |
|
9361 |
+ }, |
|
9362 |
+ observerUpdate: function observerUpdate(swiper) { |
|
9363 |
+ if (!swiper.thumbs.swiper) return; |
|
9364 |
+ swiper.thumbs.update(); |
|
9365 |
+ }, |
|
9366 |
+ setTransition: function setTransition(swiper, duration) { |
|
9367 |
+ var thumbsSwiper = swiper.thumbs.swiper; |
|
9368 |
+ if (!thumbsSwiper) return; |
|
9369 |
+ thumbsSwiper.setTransition(duration); |
|
9370 |
+ }, |
|
9371 |
+ beforeDestroy: function beforeDestroy(swiper) { |
|
9372 |
+ var thumbsSwiper = swiper.thumbs.swiper; |
|
9373 |
+ if (!thumbsSwiper) return; |
|
9374 |
+ |
|
9375 |
+ if (swiper.thumbs.swiperCreated && thumbsSwiper) { |
|
9376 |
+ thumbsSwiper.destroy(); |
|
9377 |
+ } |
|
9378 |
+ } |
|
9379 |
+ } |
|
9380 |
+}; |
|
9381 |
+ |
|
9382 |
+// Swiper Class |
|
9383 |
+var components = [Virtual$1, Keyboard$1, Mousewheel$1, Navigation$1, Pagination$1, Scrollbar$1, Parallax$1, Zoom$1, Lazy$1, Controller$1, A11y$1, History$1, HashNavigation$1, Autoplay$1, EffectFade, EffectCube, EffectFlip, EffectCoverflow, Thumbs$1]; |
|
9384 |
+Swiper.use(components); |
|
9385 |
+ |
|
9386 |
+export default Swiper; |
|
9387 |
+export { Swiper }; |