| 1 |
/** |
| 2 |
* Swiper 6.5.7 |
| 3 |
* Most modern mobile touch slider and framework with hardware accelerated transitions |
| 4 |
* https://swiperjs.com |
| 5 |
* |
| 6 |
* Copyright 2014-2021 Vladimir Kharlampidi |
| 7 |
* |
| 8 |
* Released under the MIT License |
| 9 |
* |
| 10 |
* Released on: April 16, 2021 |
| 11 |
*/ |
| 12 |
|
| 13 |
(function (global, factory) { |
| 14 |
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : |
| 15 |
typeof define === 'function' && define.amd ? define(factory) : |
| 16 |
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Swiper = factory()); |
| 17 |
}(this, (function () { 'use strict'; |
| 18 |
|
| 19 |
function _defineProperties(target, props) { |
| 20 |
for (var i = 0; i < props.length; i++) { |
| 21 |
var descriptor = props[i]; |
| 22 |
descriptor.enumerable = descriptor.enumerable || false; |
| 23 |
descriptor.configurable = true; |
| 24 |
if ("value" in descriptor) descriptor.writable = true; |
| 25 |
Object.defineProperty(target, descriptor.key, descriptor); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
function _createClass(Constructor, protoProps, staticProps) { |
| 30 |
if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
| 31 |
if (staticProps) _defineProperties(Constructor, staticProps); |
| 32 |
return Constructor; |
| 33 |
} |
| 34 |
|
| 35 |
function _extends() { |
| 36 |
_extends = Object.assign || function (target) { |
| 37 |
for (var i = 1; i < arguments.length; i++) { |
| 38 |
var source = arguments[i]; |
| 39 |
|
| 40 |
for (var key in source) { |
| 41 |
if (Object.prototype.hasOwnProperty.call(source, key)) { |
| 42 |
target[key] = source[key]; |
| 43 |
} |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
return target; |
| 48 |
}; |
| 49 |
|
| 50 |
return _extends.apply(this, arguments); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* SSR Window 3.0.0 |
| 55 |
* Better handling for window object in SSR environment |
| 56 |
* https://github.com/nolimits4web/ssr-window |
| 57 |
* |
| 58 |
* Copyright 2020, Vladimir Kharlampidi |
| 59 |
* |
| 60 |
* Licensed under MIT |
| 61 |
* |
| 62 |
* Released on: November 9, 2020 |
| 63 |
*/ |
| 64 |
|
| 65 |
/* eslint-disable no-param-reassign */ |
| 66 |
function isObject$1(obj) { |
| 67 |
return obj !== null && typeof obj === 'object' && 'constructor' in obj && obj.constructor === Object; |
| 68 |
} |
| 69 |
|
| 70 |
function extend$1(target, src) { |
| 71 |
if (target === void 0) { |
| 72 |
target = {}; |
| 73 |
} |
| 74 |
|
| 75 |
if (src === void 0) { |
| 76 |
src = {}; |
| 77 |
} |
| 78 |
|
| 79 |
Object.keys(src).forEach(function (key) { |
| 80 |
if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject$1(src[key]) && isObject$1(target[key]) && Object.keys(src[key]).length > 0) { |
| 81 |
extend$1(target[key], src[key]); |
| 82 |
} |
| 83 |
}); |
| 84 |
} |
| 85 |
|
| 86 |
var ssrDocument = { |
| 87 |
body: {}, |
| 88 |
addEventListener: function addEventListener() {}, |
| 89 |
removeEventListener: function removeEventListener() {}, |
| 90 |
activeElement: { |
| 91 |
blur: function blur() {}, |
| 92 |
nodeName: '' |
| 93 |
}, |
| 94 |
querySelector: function querySelector() { |
| 95 |
return null; |
| 96 |
}, |
| 97 |
querySelectorAll: function querySelectorAll() { |
| 98 |
return []; |
| 99 |
}, |
| 100 |
getElementById: function getElementById() { |
| 101 |
return null; |
| 102 |
}, |
| 103 |
createEvent: function createEvent() { |
| 104 |
return { |
| 105 |
initEvent: function initEvent() {} |
| 106 |
}; |
| 107 |
}, |
| 108 |
createElement: function createElement() { |
| 109 |
return { |
| 110 |
children: [], |
| 111 |
childNodes: [], |
| 112 |
style: {}, |
| 113 |
setAttribute: function setAttribute() {}, |
| 114 |
getElementsByTagName: function getElementsByTagName() { |
| 115 |
return []; |
| 116 |
} |
| 117 |
}; |
| 118 |
}, |
| 119 |
createElementNS: function createElementNS() { |
| 120 |
return {}; |
| 121 |
}, |
| 122 |
importNode: function importNode() { |
| 123 |
return null; |
| 124 |
}, |
| 125 |
location: { |
| 126 |
hash: '', |
| 127 |
host: '', |
| 128 |
hostname: '', |
| 129 |
href: '', |
| 130 |
origin: '', |
| 131 |
pathname: '', |
| 132 |
protocol: '', |
| 133 |
search: '' |
| 134 |
} |
| 135 |
}; |
| 136 |
|
| 137 |
function getDocument() { |
| 138 |
var doc = typeof document !== 'undefined' ? document : {}; |
| 139 |
extend$1(doc, ssrDocument); |
| 140 |
return doc; |
| 141 |
} |
| 142 |
|
| 143 |
var ssrWindow = { |
| 144 |
document: ssrDocument, |
| 145 |
navigator: { |
| 146 |
userAgent: '' |
| 147 |
}, |
| 148 |
location: { |
| 149 |
hash: '', |
| 150 |
host: '', |
| 151 |
hostname: '', |
| 152 |
href: '', |
| 153 |
origin: '', |
| 154 |
pathname: '', |
| 155 |
protocol: '', |
| 156 |
search: '' |
| 157 |
}, |
| 158 |
history: { |
| 159 |
replaceState: function replaceState() {}, |
| 160 |
pushState: function pushState() {}, |
| 161 |
go: function go() {}, |
| 162 |
back: function back() {} |
| 163 |
}, |
| 164 |
CustomEvent: function CustomEvent() { |
| 165 |
return this; |
| 166 |
}, |
| 167 |
addEventListener: function addEventListener() {}, |
| 168 |
removeEventListener: function removeEventListener() {}, |
| 169 |
getComputedStyle: function getComputedStyle() { |
| 170 |
return { |
| 171 |
getPropertyValue: function getPropertyValue() { |
| 172 |
return ''; |
| 173 |
} |
| 174 |
}; |
| 175 |
}, |
| 176 |
Image: function Image() {}, |
| 177 |
Date: function Date() {}, |
| 178 |
screen: {}, |
| 179 |
setTimeout: function setTimeout() {}, |
| 180 |
clearTimeout: function clearTimeout() {}, |
| 181 |
matchMedia: function matchMedia() { |
| 182 |
return {}; |
| 183 |
}, |
| 184 |
requestAnimationFrame: function requestAnimationFrame(callback) { |
| 185 |
if (typeof setTimeout === 'undefined') { |
| 186 |
callback(); |
| 187 |
return null; |
| 188 |
} |
| 189 |
|
| 190 |
return setTimeout(callback, 0); |
| 191 |
}, |
| 192 |
cancelAnimationFrame: function cancelAnimationFrame(id) { |
| 193 |
if (typeof setTimeout === 'undefined') { |
| 194 |
return; |
| 195 |
} |
| 196 |
|
| 197 |
clearTimeout(id); |
| 198 |
} |
| 199 |
}; |
| 200 |
|
| 201 |
function getWindow() { |
| 202 |
var win = typeof window !== 'undefined' ? window : {}; |
| 203 |
extend$1(win, ssrWindow); |
| 204 |
return win; |
| 205 |
} |
| 206 |
|
| 207 |
/** |
| 208 |
* Dom7 3.0.0 |
| 209 |
* Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API |
| 210 |
* https://framework7.io/docs/dom7.html |
| 211 |
* |
| 212 |
* Copyright 2020, Vladimir Kharlampidi |
| 213 |
* |
| 214 |
* Licensed under MIT |
| 215 |
* |
| 216 |
* Released on: November 9, 2020 |
| 217 |
*/ |
| 218 |
|
| 219 |
function _inheritsLoose(subClass, superClass) { |
| 220 |
subClass.prototype = Object.create(superClass.prototype); |
| 221 |
subClass.prototype.constructor = subClass; |
| 222 |
subClass.__proto__ = superClass; |
| 223 |
} |
| 224 |
|
| 225 |
function _getPrototypeOf(o) { |
| 226 |
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { |
| 227 |
return o.__proto__ || Object.getPrototypeOf(o); |
| 228 |
}; |
| 229 |
return _getPrototypeOf(o); |
| 230 |
} |
| 231 |
|
| 232 |
function _setPrototypeOf(o, p) { |
| 233 |
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { |
| 234 |
o.__proto__ = p; |
| 235 |
return o; |
| 236 |
}; |
| 237 |
|
| 238 |
return _setPrototypeOf(o, p); |
| 239 |
} |
| 240 |
|
| 241 |
function _isNativeReflectConstruct() { |
| 242 |
if (typeof Reflect === "undefined" || !Reflect.construct) return false; |
| 243 |
if (Reflect.construct.sham) return false; |
| 244 |
if (typeof Proxy === "function") return true; |
| 245 |
|
| 246 |
try { |
| 247 |
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); |
| 248 |
return true; |
| 249 |
} catch (e) { |
| 250 |
return false; |
| 251 |
} |
| 252 |
} |
| 253 |
|
| 254 |
function _construct(Parent, args, Class) { |
| 255 |
if (_isNativeReflectConstruct()) { |
| 256 |
_construct = Reflect.construct; |
| 257 |
} else { |
| 258 |
_construct = function _construct(Parent, args, Class) { |
| 259 |
var a = [null]; |
| 260 |
a.push.apply(a, args); |
| 261 |
var Constructor = Function.bind.apply(Parent, a); |
| 262 |
var instance = new Constructor(); |
| 263 |
if (Class) _setPrototypeOf(instance, Class.prototype); |
| 264 |
return instance; |
| 265 |
}; |
| 266 |
} |
| 267 |
|
| 268 |
return _construct.apply(null, arguments); |
| 269 |
} |
| 270 |
|
| 271 |
function _isNativeFunction(fn) { |
| 272 |
return Function.toString.call(fn).indexOf("[native code]") !== -1; |
| 273 |
} |
| 274 |
|
| 275 |
function _wrapNativeSuper(Class) { |
| 276 |
var _cache = typeof Map === "function" ? new Map() : undefined; |
| 277 |
|
| 278 |
_wrapNativeSuper = function _wrapNativeSuper(Class) { |
| 279 |
if (Class === null || !_isNativeFunction(Class)) return Class; |
| 280 |
|
| 281 |
if (typeof Class !== "function") { |
| 282 |
throw new TypeError("Super expression must either be null or a function"); |
| 283 |
} |
| 284 |
|
| 285 |
if (typeof _cache !== "undefined") { |
| 286 |
if (_cache.has(Class)) return _cache.get(Class); |
| 287 |
|
| 288 |
_cache.set(Class, Wrapper); |
| 289 |
} |
| 290 |
|
| 291 |
function Wrapper() { |
| 292 |
return _construct(Class, arguments, _getPrototypeOf(this).constructor); |
| 293 |
} |
| 294 |
|
| 295 |
Wrapper.prototype = Object.create(Class.prototype, { |
| 296 |
constructor: { |
| 297 |
value: Wrapper, |
| 298 |
enumerable: false, |
| 299 |
writable: true, |
| 300 |
configurable: true |
| 301 |
} |
| 302 |
}); |
| 303 |
return _setPrototypeOf(Wrapper, Class); |
| 304 |
}; |
| 305 |
|
| 306 |
return _wrapNativeSuper(Class); |
| 307 |
} |
| 308 |
|
| 309 |
function _assertThisInitialized(self) { |
| 310 |
if (self === void 0) { |
| 311 |
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); |
| 312 |
} |
| 313 |
|
| 314 |
return self; |
| 315 |
} |
| 316 |
/* eslint-disable no-proto */ |
| 317 |
|
| 318 |
|
| 319 |
function makeReactive(obj) { |
| 320 |
var proto = obj.__proto__; |
| 321 |
Object.defineProperty(obj, '__proto__', { |
| 322 |
get: function get() { |
| 323 |
return proto; |
| 324 |
}, |
| 325 |
set: function set(value) { |
| 326 |
proto.__proto__ = value; |
| 327 |
} |
| 328 |
}); |
| 329 |
} |
| 330 |
|
| 331 |
var Dom7 = /*#__PURE__*/function (_Array) { |
| 332 |
_inheritsLoose(Dom7, _Array); |
| 333 |
|
| 334 |
function Dom7(items) { |
| 335 |
var _this; |
| 336 |
|
| 337 |
_this = _Array.call.apply(_Array, [this].concat(items)) || this; |
| 338 |
makeReactive(_assertThisInitialized(_this)); |
| 339 |
return _this; |
| 340 |
} |
| 341 |
|
| 342 |
return Dom7; |
| 343 |
}( /*#__PURE__*/_wrapNativeSuper(Array)); |
| 344 |
|
| 345 |
function arrayFlat(arr) { |
| 346 |
if (arr === void 0) { |
| 347 |
arr = []; |
| 348 |
} |
| 349 |
|
| 350 |
var res = []; |
| 351 |
arr.forEach(function (el) { |
| 352 |
if (Array.isArray(el)) { |
| 353 |
res.push.apply(res, arrayFlat(el)); |
| 354 |
} else { |
| 355 |
res.push(el); |
| 356 |
} |
| 357 |
}); |
| 358 |
return res; |
| 359 |
} |
| 360 |
|
| 361 |
function arrayFilter(arr, callback) { |
| 362 |
return Array.prototype.filter.call(arr, callback); |
| 363 |
} |
| 364 |
|
| 365 |
function arrayUnique(arr) { |
| 366 |
var uniqueArray = []; |
| 367 |
|
| 368 |
for (var i = 0; i < arr.length; i += 1) { |
| 369 |
if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]); |
| 370 |
} |
| 371 |
|
| 372 |
return uniqueArray; |
| 373 |
} |
| 374 |
|
| 375 |
function qsa(selector, context) { |
| 376 |
if (typeof selector !== 'string') { |
| 377 |
return [selector]; |
| 378 |
} |
| 379 |
|
| 380 |
var a = []; |
| 381 |
var res = context.querySelectorAll(selector); |
| 382 |
|
| 383 |
for (var i = 0; i < res.length; i += 1) { |
| 384 |
a.push(res[i]); |
| 385 |
} |
| 386 |
|
| 387 |
return a; |
| 388 |
} |
| 389 |
|
| 390 |
function $(selector, context) { |
| 391 |
var window = getWindow(); |
| 392 |
var document = getDocument(); |
| 393 |
var arr = []; |
| 394 |
|
| 395 |
if (!context && selector instanceof Dom7) { |
| 396 |
return selector; |
| 397 |
} |
| 398 |
|
| 399 |
if (!selector) { |
| 400 |
return new Dom7(arr); |
| 401 |
} |
| 402 |
|
| 403 |
if (typeof selector === 'string') { |
| 404 |
var html = selector.trim(); |
| 405 |
|
| 406 |
if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) { |
| 407 |
var toCreate = 'div'; |
| 408 |
if (html.indexOf('<li') === 0) toCreate = 'ul'; |
| 409 |
if (html.indexOf('<tr') === 0) toCreate = 'tbody'; |
| 410 |
if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr'; |
| 411 |
if (html.indexOf('<tbody') === 0) toCreate = 'table'; |
| 412 |
if (html.indexOf('<option') === 0) toCreate = 'select'; |
| 413 |
var tempParent = document.createElement(toCreate); |
| 414 |
tempParent.innerHTML = html; |
| 415 |
|
| 416 |
for (var i = 0; i < tempParent.childNodes.length; i += 1) { |
| 417 |
arr.push(tempParent.childNodes[i]); |
| 418 |
} |
| 419 |
} else { |
| 420 |
arr = qsa(selector.trim(), context || document); |
| 421 |
} // arr = qsa(selector, document); |
| 422 |
|
| 423 |
} else if (selector.nodeType || selector === window || selector === document) { |
| 424 |
arr.push(selector); |
| 425 |
} else if (Array.isArray(selector)) { |
| 426 |
if (selector instanceof Dom7) return selector; |
| 427 |
arr = selector; |
| 428 |
} |
| 429 |
|
| 430 |
return new Dom7(arrayUnique(arr)); |
| 431 |
} |
| 432 |
|
| 433 |
$.fn = Dom7.prototype; |
| 434 |
|
| 435 |
function addClass() { |
| 436 |
for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) { |
| 437 |
classes[_key] = arguments[_key]; |
| 438 |
} |
| 439 |
|
| 440 |
var classNames = arrayFlat(classes.map(function (c) { |
| 441 |
return c.split(' '); |
| 442 |
})); |
| 443 |
this.forEach(function (el) { |
| 444 |
var _el$classList; |
| 445 |
|
| 446 |
(_el$classList = el.classList).add.apply(_el$classList, classNames); |
| 447 |
}); |
| 448 |
return this; |
| 449 |
} |
| 450 |
|
| 451 |
function removeClass() { |
| 452 |
for (var _len2 = arguments.length, classes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { |
| 453 |
classes[_key2] = arguments[_key2]; |
| 454 |
} |
| 455 |
|
| 456 |
var classNames = arrayFlat(classes.map(function (c) { |
| 457 |
return c.split(' '); |
| 458 |
})); |
| 459 |
this.forEach(function (el) { |
| 460 |
var _el$classList2; |
| 461 |
|
| 462 |
(_el$classList2 = el.classList).remove.apply(_el$classList2, classNames); |
| 463 |
}); |
| 464 |
return this; |
| 465 |
} |
| 466 |
|
| 467 |
function toggleClass() { |
| 468 |
for (var _len3 = arguments.length, classes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { |
| 469 |
classes[_key3] = arguments[_key3]; |
| 470 |
} |
| 471 |
|
| 472 |
var classNames = arrayFlat(classes.map(function (c) { |
| 473 |
return c.split(' '); |
| 474 |
})); |
| 475 |
this.forEach(function (el) { |
| 476 |
classNames.forEach(function (className) { |
| 477 |
el.classList.toggle(className); |
| 478 |
}); |
| 479 |
}); |
| 480 |
} |
| 481 |
|
| 482 |
function hasClass() { |
| 483 |
for (var _len4 = arguments.length, classes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { |
| 484 |
classes[_key4] = arguments[_key4]; |
| 485 |
} |
| 486 |
|
| 487 |
var classNames = arrayFlat(classes.map(function (c) { |
| 488 |
return c.split(' '); |
| 489 |
})); |
| 490 |
return arrayFilter(this, function (el) { |
| 491 |
return classNames.filter(function (className) { |
| 492 |
return el.classList.contains(className); |
| 493 |
}).length > 0; |
| 494 |
}).length > 0; |
| 495 |
} |
| 496 |
|
| 497 |
function attr(attrs, value) { |
| 498 |
if (arguments.length === 1 && typeof attrs === 'string') { |
| 499 |
// Get attr |
| 500 |
if (this[0]) return this[0].getAttribute(attrs); |
| 501 |
return undefined; |
| 502 |
} // Set attrs |
| 503 |
|
| 504 |
|
| 505 |
for (var i = 0; i < this.length; i += 1) { |
| 506 |
if (arguments.length === 2) { |
| 507 |
// String |
| 508 |
this[i].setAttribute(attrs, value); |
| 509 |
} else { |
| 510 |
// Object |
| 511 |
for (var attrName in attrs) { |
| 512 |
this[i][attrName] = attrs[attrName]; |
| 513 |
this[i].setAttribute(attrName, attrs[attrName]); |
| 514 |
} |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
return this; |
| 519 |
} |
| 520 |
|
| 521 |
function removeAttr(attr) { |
| 522 |
for (var i = 0; i < this.length; i += 1) { |
| 523 |
this[i].removeAttribute(attr); |
| 524 |
} |
| 525 |
|
| 526 |
return this; |
| 527 |
} |
| 528 |
|
| 529 |
function transform(transform) { |
| 530 |
for (var i = 0; i < this.length; i += 1) { |
| 531 |
this[i].style.transform = transform; |
| 532 |
} |
| 533 |
|
| 534 |
return this; |
| 535 |
} |
| 536 |
|
| 537 |
function transition$1(duration) { |
| 538 |
for (var i = 0; i < this.length; i += 1) { |
| 539 |
this[i].style.transitionDuration = typeof duration !== 'string' ? duration + "ms" : duration; |
| 540 |
} |
| 541 |
|
| 542 |
return this; |
| 543 |
} |
| 544 |
|
| 545 |
function on() { |
| 546 |
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { |
| 547 |
args[_key5] = arguments[_key5]; |
| 548 |
} |
| 549 |
|
| 550 |
var eventType = args[0], |
| 551 |
targetSelector = args[1], |
| 552 |
listener = args[2], |
| 553 |
capture = args[3]; |
| 554 |
|
| 555 |
if (typeof args[1] === 'function') { |
| 556 |
eventType = args[0]; |
| 557 |
listener = args[1]; |
| 558 |
capture = args[2]; |
| 559 |
targetSelector = undefined; |
| 560 |
} |
| 561 |
|
| 562 |
if (!capture) capture = false; |
| 563 |
|
| 564 |
function handleLiveEvent(e) { |
| 565 |
var target = e.target; |
| 566 |
if (!target) return; |
| 567 |
var eventData = e.target.dom7EventData || []; |
| 568 |
|
| 569 |
if (eventData.indexOf(e) < 0) { |
| 570 |
eventData.unshift(e); |
| 571 |
} |
| 572 |
|
| 573 |
if ($(target).is(targetSelector)) listener.apply(target, eventData);else { |
| 574 |
var _parents = $(target).parents(); // eslint-disable-line |
| 575 |
|
| 576 |
|
| 577 |
for (var k = 0; k < _parents.length; k += 1) { |
| 578 |
if ($(_parents[k]).is(targetSelector)) listener.apply(_parents[k], eventData); |
| 579 |
} |
| 580 |
} |
| 581 |
} |
| 582 |
|
| 583 |
function handleEvent(e) { |
| 584 |
var eventData = e && e.target ? e.target.dom7EventData || [] : []; |
| 585 |
|
| 586 |
if (eventData.indexOf(e) < 0) { |
| 587 |
eventData.unshift(e); |
| 588 |
} |
| 589 |
|
| 590 |
listener.apply(this, eventData); |
| 591 |
} |
| 592 |
|
| 593 |
var events = eventType.split(' '); |
| 594 |
var j; |
| 595 |
|
| 596 |
for (var i = 0; i < this.length; i += 1) { |
| 597 |
var el = this[i]; |
| 598 |
|
| 599 |
if (!targetSelector) { |
| 600 |
for (j = 0; j < events.length; j += 1) { |
| 601 |
var event = events[j]; |
| 602 |
if (!el.dom7Listeners) el.dom7Listeners = {}; |
| 603 |
if (!el.dom7Listeners[event]) el.dom7Listeners[event] = []; |
| 604 |
el.dom7Listeners[event].push({ |
| 605 |
listener: listener, |
| 606 |
proxyListener: handleEvent |
| 607 |
}); |
| 608 |
el.addEventListener(event, handleEvent, capture); |
| 609 |
} |
| 610 |
} else { |
| 611 |
// Live events |
| 612 |
for (j = 0; j < events.length; j += 1) { |
| 613 |
var _event = events[j]; |
| 614 |
if (!el.dom7LiveListeners) el.dom7LiveListeners = {}; |
| 615 |
if (!el.dom7LiveListeners[_event]) el.dom7LiveListeners[_event] = []; |
| 616 |
|
| 617 |
el.dom7LiveListeners[_event].push({ |
| 618 |
listener: listener, |
| 619 |
proxyListener: handleLiveEvent |
| 620 |
}); |
| 621 |
|
| 622 |
el.addEventListener(_event, handleLiveEvent, capture); |
| 623 |
} |
| 624 |
} |
| 625 |
} |
| 626 |
|
| 627 |
return this; |
| 628 |
} |
| 629 |
|
| 630 |
function off() { |
| 631 |
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { |
| 632 |
args[_key6] = arguments[_key6]; |
| 633 |
} |
| 634 |
|
| 635 |
var eventType = args[0], |
| 636 |
targetSelector = args[1], |
| 637 |
listener = args[2], |
| 638 |
capture = args[3]; |
| 639 |
|
| 640 |
if (typeof args[1] === 'function') { |
| 641 |
eventType = args[0]; |
| 642 |
listener = args[1]; |
| 643 |
capture = args[2]; |
| 644 |
targetSelector = undefined; |
| 645 |
} |
| 646 |
|
| 647 |
if (!capture) capture = false; |
| 648 |
var events = eventType.split(' '); |
| 649 |
|
| 650 |
for (var i = 0; i < events.length; i += 1) { |
| 651 |
var event = events[i]; |
| 652 |
|
| 653 |
for (var j = 0; j < this.length; j += 1) { |
| 654 |
var el = this[j]; |
| 655 |
var handlers = void 0; |
| 656 |
|
| 657 |
if (!targetSelector && el.dom7Listeners) { |
| 658 |
handlers = el.dom7Listeners[event]; |
| 659 |
} else if (targetSelector && el.dom7LiveListeners) { |
| 660 |
handlers = el.dom7LiveListeners[event]; |
| 661 |
} |
| 662 |
|
| 663 |
if (handlers && handlers.length) { |
| 664 |
for (var k = handlers.length - 1; k >= 0; k -= 1) { |
| 665 |
var handler = handlers[k]; |
| 666 |
|
| 667 |
if (listener && handler.listener === listener) { |
| 668 |
el.removeEventListener(event, handler.proxyListener, capture); |
| 669 |
handlers.splice(k, 1); |
| 670 |
} else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) { |
| 671 |
el.removeEventListener(event, handler.proxyListener, capture); |
| 672 |
handlers.splice(k, 1); |
| 673 |
} else if (!listener) { |
| 674 |
el.removeEventListener(event, handler.proxyListener, capture); |
| 675 |
handlers.splice(k, 1); |
| 676 |
} |
| 677 |
} |
| 678 |
} |
| 679 |
} |
| 680 |
} |
| 681 |
|
| 682 |
return this; |
| 683 |
} |
| 684 |
|
| 685 |
function trigger() { |
| 686 |
var window = getWindow(); |
| 687 |
|
| 688 |
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { |
| 689 |
args[_key9] = arguments[_key9]; |
| 690 |
} |
| 691 |
|
| 692 |
var events = args[0].split(' '); |
| 693 |
var eventData = args[1]; |
| 694 |
|
| 695 |
for (var i = 0; i < events.length; i += 1) { |
| 696 |
var event = events[i]; |
| 697 |
|
| 698 |
for (var j = 0; j < this.length; j += 1) { |
| 699 |
var el = this[j]; |
| 700 |
|
| 701 |
if (window.CustomEvent) { |
| 702 |
var evt = new window.CustomEvent(event, { |
| 703 |
detail: eventData, |
| 704 |
bubbles: true, |
| 705 |
cancelable: true |
| 706 |
}); |
| 707 |
el.dom7EventData = args.filter(function (data, dataIndex) { |
| 708 |
return dataIndex > 0; |
| 709 |
}); |
| 710 |
el.dispatchEvent(evt); |
| 711 |
el.dom7EventData = []; |
| 712 |
delete el.dom7EventData; |
| 713 |
} |
| 714 |
} |
| 715 |
} |
| 716 |
|
| 717 |
return this; |
| 718 |
} |
| 719 |
|
| 720 |
function transitionEnd$1(callback) { |
| 721 |
var dom = this; |
| 722 |
|
| 723 |
function fireCallBack(e) { |
| 724 |
if (e.target !== this) return; |
| 725 |
callback.call(this, e); |
| 726 |
dom.off('transitionend', fireCallBack); |
| 727 |
} |
| 728 |
|
| 729 |
if (callback) { |
| 730 |
dom.on('transitionend', fireCallBack); |
| 731 |
} |
| 732 |
|
| 733 |
return this; |
| 734 |
} |
| 735 |
|
| 736 |
function outerWidth(includeMargins) { |
| 737 |
if (this.length > 0) { |
| 738 |
if (includeMargins) { |
| 739 |
var _styles = this.styles(); |
| 740 |
|
| 741 |
return this[0].offsetWidth + parseFloat(_styles.getPropertyValue('margin-right')) + parseFloat(_styles.getPropertyValue('margin-left')); |
| 742 |
} |
| 743 |
|
| 744 |
return this[0].offsetWidth; |
| 745 |
} |
| 746 |
|
| 747 |
return null; |
| 748 |
} |
| 749 |
|
| 750 |
function outerHeight(includeMargins) { |
| 751 |
if (this.length > 0) { |
| 752 |
if (includeMargins) { |
| 753 |
var _styles2 = this.styles(); |
| 754 |
|
| 755 |
return this[0].offsetHeight + parseFloat(_styles2.getPropertyValue('margin-top')) + parseFloat(_styles2.getPropertyValue('margin-bottom')); |
| 756 |
} |
| 757 |
|
| 758 |
return this[0].offsetHeight; |
| 759 |
} |
| 760 |
|
| 761 |
return null; |
| 762 |
} |
| 763 |
|
| 764 |
function offset() { |
| 765 |
if (this.length > 0) { |
| 766 |
var window = getWindow(); |
| 767 |
var document = getDocument(); |
| 768 |
var el = this[0]; |
| 769 |
var box = el.getBoundingClientRect(); |
| 770 |
var body = document.body; |
| 771 |
var clientTop = el.clientTop || body.clientTop || 0; |
| 772 |
var clientLeft = el.clientLeft || body.clientLeft || 0; |
| 773 |
var scrollTop = el === window ? window.scrollY : el.scrollTop; |
| 774 |
var scrollLeft = el === window ? window.scrollX : el.scrollLeft; |
| 775 |
return { |
| 776 |
top: box.top + scrollTop - clientTop, |
| 777 |
left: box.left + scrollLeft - clientLeft |
| 778 |
}; |
| 779 |
} |
| 780 |
|
| 781 |
return null; |
| 782 |
} |
| 783 |
|
| 784 |
function styles() { |
| 785 |
var window = getWindow(); |
| 786 |
if (this[0]) return window.getComputedStyle(this[0], null); |
| 787 |
return {}; |
| 788 |
} |
| 789 |
|
| 790 |
function css(props, value) { |
| 791 |
var window = getWindow(); |
| 792 |
var i; |
| 793 |
|
| 794 |
if (arguments.length === 1) { |
| 795 |
if (typeof props === 'string') { |
| 796 |
// .css('width') |
| 797 |
if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props); |
| 798 |
} else { |
| 799 |
// .css({ width: '100px' }) |
| 800 |
for (i = 0; i < this.length; i += 1) { |
| 801 |
for (var _prop in props) { |
| 802 |
this[i].style[_prop] = props[_prop]; |
| 803 |
} |
| 804 |
} |
| 805 |
|
| 806 |
return this; |
| 807 |
} |
| 808 |
} |
| 809 |
|
| 810 |
if (arguments.length === 2 && typeof props === 'string') { |
| 811 |
// .css('width', '100px') |
| 812 |
for (i = 0; i < this.length; i += 1) { |
| 813 |
this[i].style[props] = value; |
| 814 |
} |
| 815 |
|
| 816 |
return this; |
| 817 |
} |
| 818 |
|
| 819 |
return this; |
| 820 |
} |
| 821 |
|
| 822 |
function each(callback) { |
| 823 |
if (!callback) return this; |
| 824 |
this.forEach(function (el, index) { |
| 825 |
callback.apply(el, [el, index]); |
| 826 |
}); |
| 827 |
return this; |
| 828 |
} |
| 829 |
|
| 830 |
function filter(callback) { |
| 831 |
var result = arrayFilter(this, callback); |
| 832 |
return $(result); |
| 833 |
} |
| 834 |
|
| 835 |
function html(html) { |
| 836 |
if (typeof html === 'undefined') { |
| 837 |
return this[0] ? this[0].innerHTML : null; |
| 838 |
} |
| 839 |
|
| 840 |
for (var i = 0; i < this.length; i += 1) { |
| 841 |
this[i].innerHTML = html; |
| 842 |
} |
| 843 |
|
| 844 |
return this; |
| 845 |
} |
| 846 |
|
| 847 |
function text(text) { |
| 848 |
if (typeof text === 'undefined') { |
| 849 |
return this[0] ? this[0].textContent.trim() : null; |
| 850 |
} |
| 851 |
|
| 852 |
for (var i = 0; i < this.length; i += 1) { |
| 853 |
this[i].textContent = text; |
| 854 |
} |
| 855 |
|
| 856 |
return this; |
| 857 |
} |
| 858 |
|
| 859 |
function is(selector) { |
| 860 |
var window = getWindow(); |
| 861 |
var document = getDocument(); |
| 862 |
var el = this[0]; |
| 863 |
var compareWith; |
| 864 |
var i; |
| 865 |
if (!el || typeof selector === 'undefined') return false; |
| 866 |
|
| 867 |
if (typeof selector === 'string') { |
| 868 |
if (el.matches) return el.matches(selector); |
| 869 |
if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector); |
| 870 |
if (el.msMatchesSelector) return el.msMatchesSelector(selector); |
| 871 |
compareWith = $(selector); |
| 872 |
|
| 873 |
for (i = 0; i < compareWith.length; i += 1) { |
| 874 |
if (compareWith[i] === el) return true; |
| 875 |
} |
| 876 |
|
| 877 |
return false; |
| 878 |
} |
| 879 |
|
| 880 |
if (selector === document) { |
| 881 |
return el === document; |
| 882 |
} |
| 883 |
|
| 884 |
if (selector === window) { |
| 885 |
return el === window; |
| 886 |
} |
| 887 |
|
| 888 |
if (selector.nodeType || selector instanceof Dom7) { |
| 889 |
compareWith = selector.nodeType ? [selector] : selector; |
| 890 |
|
| 891 |
for (i = 0; i < compareWith.length; i += 1) { |
| 892 |
if (compareWith[i] === el) return true; |
| 893 |
} |
| 894 |
|
| 895 |
return false; |
| 896 |
} |
| 897 |
|
| 898 |
return false; |
| 899 |
} |
| 900 |
|
| 901 |
function index() { |
| 902 |
var child = this[0]; |
| 903 |
var i; |
| 904 |
|
| 905 |
if (child) { |
| 906 |
i = 0; // eslint-disable-next-line |
| 907 |
|
| 908 |
while ((child = child.previousSibling) !== null) { |
| 909 |
if (child.nodeType === 1) i += 1; |
| 910 |
} |
| 911 |
|
| 912 |
return i; |
| 913 |
} |
| 914 |
|
| 915 |
return undefined; |
| 916 |
} |
| 917 |
|
| 918 |
function eq(index) { |
| 919 |
if (typeof index === 'undefined') return this; |
| 920 |
var length = this.length; |
| 921 |
|
| 922 |
if (index > length - 1) { |
| 923 |
return $([]); |
| 924 |
} |
| 925 |
|
| 926 |
if (index < 0) { |
| 927 |
var returnIndex = length + index; |
| 928 |
if (returnIndex < 0) return $([]); |
| 929 |
return $([this[returnIndex]]); |
| 930 |
} |
| 931 |
|
| 932 |
return $([this[index]]); |
| 933 |
} |
| 934 |
|
| 935 |
function append() { |
| 936 |
var newChild; |
| 937 |
var document = getDocument(); |
| 938 |
|
| 939 |
for (var k = 0; k < arguments.length; k += 1) { |
| 940 |
newChild = k < 0 || arguments.length <= k ? undefined : arguments[k]; |
| 941 |
|
| 942 |
for (var i = 0; i < this.length; i += 1) { |
| 943 |
if (typeof newChild === 'string') { |
| 944 |
var tempDiv = document.createElement('div'); |
| 945 |
tempDiv.innerHTML = newChild; |
| 946 |
|
| 947 |
while (tempDiv.firstChild) { |
| 948 |
this[i].appendChild(tempDiv.firstChild); |
| 949 |
} |
| 950 |
} else if (newChild instanceof Dom7) { |
| 951 |
for (var j = 0; j < newChild.length; j += 1) { |
| 952 |
this[i].appendChild(newChild[j]); |
| 953 |
} |
| 954 |
} else { |
| 955 |
this[i].appendChild(newChild); |
| 956 |
} |
| 957 |
} |
| 958 |
} |
| 959 |
|
| 960 |
return this; |
| 961 |
} |
| 962 |
|
| 963 |
function prepend(newChild) { |
| 964 |
var document = getDocument(); |
| 965 |
var i; |
| 966 |
var j; |
| 967 |
|
| 968 |
for (i = 0; i < this.length; i += 1) { |
| 969 |
if (typeof newChild === 'string') { |
| 970 |
var tempDiv = document.createElement('div'); |
| 971 |
tempDiv.innerHTML = newChild; |
| 972 |
|
| 973 |
for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) { |
| 974 |
this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]); |
| 975 |
} |
| 976 |
} else if (newChild instanceof Dom7) { |
| 977 |
for (j = 0; j < newChild.length; j += 1) { |
| 978 |
this[i].insertBefore(newChild[j], this[i].childNodes[0]); |
| 979 |
} |
| 980 |
} else { |
| 981 |
this[i].insertBefore(newChild, this[i].childNodes[0]); |
| 982 |
} |
| 983 |
} |
| 984 |
|
| 985 |
return this; |
| 986 |
} |
| 987 |
|
| 988 |
function next(selector) { |
| 989 |
if (this.length > 0) { |
| 990 |
if (selector) { |
| 991 |
if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) { |
| 992 |
return $([this[0].nextElementSibling]); |
| 993 |
} |
| 994 |
|
| 995 |
return $([]); |
| 996 |
} |
| 997 |
|
| 998 |
if (this[0].nextElementSibling) return $([this[0].nextElementSibling]); |
| 999 |
return $([]); |
| 1000 |
} |
| 1001 |
|
| 1002 |
return $([]); |
| 1003 |
} |
| 1004 |
|
| 1005 |
function nextAll(selector) { |
| 1006 |
var nextEls = []; |
| 1007 |
var el = this[0]; |
| 1008 |
if (!el) return $([]); |
| 1009 |
|
| 1010 |
while (el.nextElementSibling) { |
| 1011 |
var _next = el.nextElementSibling; // eslint-disable-line |
| 1012 |
|
| 1013 |
if (selector) { |
| 1014 |
if ($(_next).is(selector)) nextEls.push(_next); |
| 1015 |
} else nextEls.push(_next); |
| 1016 |
|
| 1017 |
el = _next; |
| 1018 |
} |
| 1019 |
|
| 1020 |
return $(nextEls); |
| 1021 |
} |
| 1022 |
|
| 1023 |
function prev(selector) { |
| 1024 |
if (this.length > 0) { |
| 1025 |
var el = this[0]; |
| 1026 |
|
| 1027 |
if (selector) { |
| 1028 |
if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) { |
| 1029 |
return $([el.previousElementSibling]); |
| 1030 |
} |
| 1031 |
|
| 1032 |
return $([]); |
| 1033 |
} |
| 1034 |
|
| 1035 |
if (el.previousElementSibling) return $([el.previousElementSibling]); |
| 1036 |
return $([]); |
| 1037 |
} |
| 1038 |
|
| 1039 |
return $([]); |
| 1040 |
} |
| 1041 |
|
| 1042 |
function prevAll(selector) { |
| 1043 |
var prevEls = []; |
| 1044 |
var el = this[0]; |
| 1045 |
if (!el) return $([]); |
| 1046 |
|
| 1047 |
while (el.previousElementSibling) { |
| 1048 |
var _prev = el.previousElementSibling; // eslint-disable-line |
| 1049 |
|
| 1050 |
if (selector) { |
| 1051 |
if ($(_prev).is(selector)) prevEls.push(_prev); |
| 1052 |
} else prevEls.push(_prev); |
| 1053 |
|
| 1054 |
el = _prev; |
| 1055 |
} |
| 1056 |
|
| 1057 |
return $(prevEls); |
| 1058 |
} |
| 1059 |
|
| 1060 |
function parent(selector) { |
| 1061 |
var parents = []; // eslint-disable-line |
| 1062 |
|
| 1063 |
for (var i = 0; i < this.length; i += 1) { |
| 1064 |
if (this[i].parentNode !== null) { |
| 1065 |
if (selector) { |
| 1066 |
if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode); |
| 1067 |
} else { |
| 1068 |
parents.push(this[i].parentNode); |
| 1069 |
} |
| 1070 |
} |
| 1071 |
} |
| 1072 |
|
| 1073 |
return $(parents); |
| 1074 |
} |
| 1075 |
|
| 1076 |
function parents(selector) { |
| 1077 |
var parents = []; // eslint-disable-line |
| 1078 |
|
| 1079 |
for (var i = 0; i < this.length; i += 1) { |
| 1080 |
var _parent = this[i].parentNode; // eslint-disable-line |
| 1081 |
|
| 1082 |
while (_parent) { |
| 1083 |
if (selector) { |
| 1084 |
if ($(_parent).is(selector)) parents.push(_parent); |
| 1085 |
} else { |
| 1086 |
parents.push(_parent); |
| 1087 |
} |
| 1088 |
|
| 1089 |
_parent = _parent.parentNode; |
| 1090 |
} |
| 1091 |
} |
| 1092 |
|
| 1093 |
return $(parents); |
| 1094 |
} |
| 1095 |
|
| 1096 |
function closest(selector) { |
| 1097 |
var closest = this; // eslint-disable-line |
| 1098 |
|
| 1099 |
if (typeof selector === 'undefined') { |
| 1100 |
return $([]); |
| 1101 |
} |
| 1102 |
|
| 1103 |
if (!closest.is(selector)) { |
| 1104 |
closest = closest.parents(selector).eq(0); |
| 1105 |
} |
| 1106 |
|
| 1107 |
return closest; |
| 1108 |
} |
| 1109 |
|
| 1110 |
function find(selector) { |
| 1111 |
var foundElements = []; |
| 1112 |
|
| 1113 |
for (var i = 0; i < this.length; i += 1) { |
| 1114 |
try { |
| 1115 |
var found = this[i].querySelectorAll(selector); |
| 1116 |
} catch (err) { |
| 1117 |
console.log(selector); |
| 1118 |
} |
| 1119 |
|
| 1120 |
for (var j = 0; j < found.length; j += 1) { |
| 1121 |
foundElements.push(found[j]); |
| 1122 |
} |
| 1123 |
} |
| 1124 |
|
| 1125 |
return $(foundElements); |
| 1126 |
} |
| 1127 |
|
| 1128 |
function children(selector) { |
| 1129 |
var children = []; // eslint-disable-line |
| 1130 |
|
| 1131 |
for (var i = 0; i < this.length; i += 1) { |
| 1132 |
var childNodes = this[i].children; |
| 1133 |
|
| 1134 |
for (var j = 0; j < childNodes.length; j += 1) { |
| 1135 |
if (!selector || $(childNodes[j]).is(selector)) { |
| 1136 |
children.push(childNodes[j]); |
| 1137 |
} |
| 1138 |
} |
| 1139 |
} |
| 1140 |
|
| 1141 |
return $(children); |
| 1142 |
} |
| 1143 |
|
| 1144 |
function remove() { |
| 1145 |
for (var i = 0; i < this.length; i += 1) { |
| 1146 |
if (this[i].parentNode) this[i].parentNode.removeChild(this[i]); |
| 1147 |
} |
| 1148 |
|
| 1149 |
return this; |
| 1150 |
} |
| 1151 |
|
| 1152 |
var Methods = { |
| 1153 |
addClass: addClass, |
| 1154 |
removeClass: removeClass, |
| 1155 |
hasClass: hasClass, |
| 1156 |
toggleClass: toggleClass, |
| 1157 |
attr: attr, |
| 1158 |
removeAttr: removeAttr, |
| 1159 |
transform: transform, |
| 1160 |
transition: transition$1, |
| 1161 |
on: on, |
| 1162 |
off: off, |
| 1163 |
trigger: trigger, |
| 1164 |
transitionEnd: transitionEnd$1, |
| 1165 |
outerWidth: outerWidth, |
| 1166 |
outerHeight: outerHeight, |
| 1167 |
styles: styles, |
| 1168 |
offset: offset, |
| 1169 |
css: css, |
| 1170 |
each: each, |
| 1171 |
html: html, |
| 1172 |
text: text, |
| 1173 |
is: is, |
| 1174 |
index: index, |
| 1175 |
eq: eq, |
| 1176 |
append: append, |
| 1177 |
prepend: prepend, |
| 1178 |
next: next, |
| 1179 |
nextAll: nextAll, |
| 1180 |
prev: prev, |
| 1181 |
prevAll: prevAll, |
| 1182 |
parent: parent, |
| 1183 |
parents: parents, |
| 1184 |
closest: closest, |
| 1185 |
find: find, |
| 1186 |
children: children, |
| 1187 |
filter: filter, |
| 1188 |
remove: remove |
| 1189 |
}; |
| 1190 |
Object.keys(Methods).forEach(function (methodName) { |
| 1191 |
Object.defineProperty($.fn, methodName, { |
| 1192 |
value: Methods[methodName], |
| 1193 |
writable: true |
| 1194 |
}); |
| 1195 |
}); |
| 1196 |
|
| 1197 |
function deleteProps(obj) { |
| 1198 |
var object = obj; |
| 1199 |
Object.keys(object).forEach(function (key) { |
| 1200 |
try { |
| 1201 |
object[key] = null; |
| 1202 |
} catch (e) {// no getter for object |
| 1203 |
} |
| 1204 |
|
| 1205 |
try { |
| 1206 |
delete object[key]; |
| 1207 |
} catch (e) {// something got wrong |
| 1208 |
} |
| 1209 |
}); |
| 1210 |
} |
| 1211 |
|
| 1212 |
function nextTick(callback, delay) { |
| 1213 |
if (delay === void 0) { |
| 1214 |
delay = 0; |
| 1215 |
} |
| 1216 |
|
| 1217 |
return setTimeout(callback, delay); |
| 1218 |
} |
| 1219 |
|
| 1220 |
function now() { |
| 1221 |
return Date.now(); |
| 1222 |
} |
| 1223 |
|
| 1224 |
function getComputedStyle$1(el) { |
| 1225 |
var window = getWindow(); |
| 1226 |
var style; |
| 1227 |
|
| 1228 |
if (window.getComputedStyle) { |
| 1229 |
style = window.getComputedStyle(el, null); |
| 1230 |
} |
| 1231 |
|
| 1232 |
if (!style && el.currentStyle) { |
| 1233 |
style = el.currentStyle; |
| 1234 |
} |
| 1235 |
|
| 1236 |
if (!style) { |
| 1237 |
style = el.style; |
| 1238 |
} |
| 1239 |
|
| 1240 |
return style; |
| 1241 |
} |
| 1242 |
|
| 1243 |
function getTranslate(el, axis) { |
| 1244 |
if (axis === void 0) { |
| 1245 |
axis = 'x'; |
| 1246 |
} |
| 1247 |
|
| 1248 |
var window = getWindow(); |
| 1249 |
var matrix; |
| 1250 |
var curTransform; |
| 1251 |
var transformMatrix; |
| 1252 |
var curStyle = getComputedStyle$1(el); |
| 1253 |
|
| 1254 |
if (window.WebKitCSSMatrix) { |
| 1255 |
curTransform = curStyle.transform || curStyle.webkitTransform; |
| 1256 |
|
| 1257 |
if (curTransform.split(',').length > 6) { |
| 1258 |
curTransform = curTransform.split(', ').map(function (a) { |
| 1259 |
return a.replace(',', '.'); |
| 1260 |
}).join(', '); |
| 1261 |
} // Some old versions of Webkit choke when 'none' is passed; pass |
| 1262 |
// empty string instead in this case |
| 1263 |
|
| 1264 |
|
| 1265 |
transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform); |
| 1266 |
} else { |
| 1267 |
transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,'); |
| 1268 |
matrix = transformMatrix.toString().split(','); |
| 1269 |
} |
| 1270 |
|
| 1271 |
if (axis === 'x') { |
| 1272 |
// Latest Chrome and webkits Fix |
| 1273 |
if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41; // Crazy IE10 Matrix |
| 1274 |
else if (matrix.length === 16) curTransform = parseFloat(matrix[12]); // Normal Browsers |
| 1275 |
else curTransform = parseFloat(matrix[4]); |
| 1276 |
} |
| 1277 |
|
| 1278 |
if (axis === 'y') { |
| 1279 |
// Latest Chrome and webkits Fix |
| 1280 |
if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42; // Crazy IE10 Matrix |
| 1281 |
else if (matrix.length === 16) curTransform = parseFloat(matrix[13]); // Normal Browsers |
| 1282 |
else curTransform = parseFloat(matrix[5]); |
| 1283 |
} |
| 1284 |
|
| 1285 |
return curTransform || 0; |
| 1286 |
} |
| 1287 |
|
| 1288 |
function isObject(o) { |
| 1289 |
return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object'; |
| 1290 |
} |
| 1291 |
|
| 1292 |
function extend() { |
| 1293 |
var to = Object(arguments.length <= 0 ? undefined : arguments[0]); |
| 1294 |
var noExtend = ['__proto__', 'constructor', 'prototype']; |
| 1295 |
|
| 1296 |
for (var i = 1; i < arguments.length; i += 1) { |
| 1297 |
var nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i]; |
| 1298 |
|
| 1299 |
if (nextSource !== undefined && nextSource !== null) { |
| 1300 |
var keysArray = Object.keys(Object(nextSource)).filter(function (key) { |
| 1301 |
return noExtend.indexOf(key) < 0; |
| 1302 |
}); |
| 1303 |
|
| 1304 |
for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) { |
| 1305 |
var nextKey = keysArray[nextIndex]; |
| 1306 |
var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); |
| 1307 |
|
| 1308 |
if (desc !== undefined && desc.enumerable) { |
| 1309 |
if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) { |
| 1310 |
if (nextSource[nextKey].__swiper__) { |
| 1311 |
to[nextKey] = nextSource[nextKey]; |
| 1312 |
} else { |
| 1313 |
extend(to[nextKey], nextSource[nextKey]); |
| 1314 |
} |
| 1315 |
} else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) { |
| 1316 |
to[nextKey] = {}; |
| 1317 |
|
| 1318 |
if (nextSource[nextKey].__swiper__) { |
| 1319 |
to[nextKey] = nextSource[nextKey]; |
| 1320 |
} else { |
| 1321 |
extend(to[nextKey], nextSource[nextKey]); |
| 1322 |
} |
| 1323 |
} else { |
| 1324 |
to[nextKey] = nextSource[nextKey]; |
| 1325 |
} |
| 1326 |
} |
| 1327 |
} |
| 1328 |
} |
| 1329 |
} |
| 1330 |
|
| 1331 |
return to; |
| 1332 |
} |
| 1333 |
|
| 1334 |
function bindModuleMethods(instance, obj) { |
| 1335 |
Object.keys(obj).forEach(function (key) { |
| 1336 |
if (isObject(obj[key])) { |
| 1337 |
Object.keys(obj[key]).forEach(function (subKey) { |
| 1338 |
if (typeof obj[key][subKey] === 'function') { |
| 1339 |
obj[key][subKey] = obj[key][subKey].bind(instance); |
| 1340 |
} |
| 1341 |
}); |
| 1342 |
} |
| 1343 |
|
| 1344 |
instance[key] = obj[key]; |
| 1345 |
}); |
| 1346 |
} |
| 1347 |
|
| 1348 |
function classesToSelector(classes) { |
| 1349 |
if (classes === void 0) { |
| 1350 |
classes = ''; |
| 1351 |
} |
| 1352 |
|
| 1353 |
return "." + classes.trim().replace(/([\.:\/])/g, '\\$1') // eslint-disable-line |
| 1354 |
.replace(/ /g, '.'); |
| 1355 |
} |
| 1356 |
|
| 1357 |
var support; |
| 1358 |
|
| 1359 |
function calcSupport() { |
| 1360 |
var window = getWindow(); |
| 1361 |
var document = getDocument(); |
| 1362 |
return { |
| 1363 |
touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch), |
| 1364 |
pointerEvents: !!window.PointerEvent && 'maxTouchPoints' in window.navigator && window.navigator.maxTouchPoints >= 0, |
| 1365 |
observer: function checkObserver() { |
| 1366 |
return 'MutationObserver' in window || 'WebkitMutationObserver' in window; |
| 1367 |
}(), |
| 1368 |
passiveListener: function checkPassiveListener() { |
| 1369 |
var supportsPassive = false; |
| 1370 |
|
| 1371 |
try { |
| 1372 |
var opts = Object.defineProperty({}, 'passive', { |
| 1373 |
// eslint-disable-next-line |
| 1374 |
get: function get() { |
| 1375 |
supportsPassive = true; |
| 1376 |
} |
| 1377 |
}); |
| 1378 |
window.addEventListener('testPassiveListener', null, opts); |
| 1379 |
} catch (e) {// No support |
| 1380 |
} |
| 1381 |
|
| 1382 |
return supportsPassive; |
| 1383 |
}(), |
| 1384 |
gestures: function checkGestures() { |
| 1385 |
return 'ongesturestart' in window; |
| 1386 |
}() |
| 1387 |
}; |
| 1388 |
} |
| 1389 |
|
| 1390 |
function getSupport() { |
| 1391 |
if (!support) { |
| 1392 |
support = calcSupport(); |
| 1393 |
} |
| 1394 |
|
| 1395 |
return support; |
| 1396 |
} |
| 1397 |
|
| 1398 |
var device; |
| 1399 |
|
| 1400 |
function calcDevice(_temp) { |
| 1401 |
var _ref = _temp === void 0 ? {} : _temp, |
| 1402 |
userAgent = _ref.userAgent; |
| 1403 |
|
| 1404 |
var support = getSupport(); |
| 1405 |
var window = getWindow(); |
| 1406 |
var platform = window.navigator.platform; |
| 1407 |
var ua = userAgent || window.navigator.userAgent; |
| 1408 |
var device = { |
| 1409 |
ios: false, |
| 1410 |
android: false |
| 1411 |
}; |
| 1412 |
var screenWidth = window.screen.width; |
| 1413 |
var screenHeight = window.screen.height; |
| 1414 |
var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line |
| 1415 |
|
| 1416 |
var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); |
| 1417 |
var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); |
| 1418 |
var iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/); |
| 1419 |
var windows = platform === 'Win32'; |
| 1420 |
var macos = platform === 'MacIntel'; // iPadOs 13 fix |
| 1421 |
|
| 1422 |
var iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810']; |
| 1423 |
|
| 1424 |
if (!ipad && macos && support.touch && iPadScreens.indexOf(screenWidth + "x" + screenHeight) >= 0) { |
| 1425 |
ipad = ua.match(/(Version)\/([\d.]+)/); |
| 1426 |
if (!ipad) ipad = [0, 1, '13_0_0']; |
| 1427 |
macos = false; |
| 1428 |
} // Android |
| 1429 |
|
| 1430 |
|
| 1431 |
if (android && !windows) { |
| 1432 |
device.os = 'android'; |
| 1433 |
device.android = true; |
| 1434 |
} |
| 1435 |
|
| 1436 |
if (ipad || iphone || ipod) { |
| 1437 |
device.os = 'ios'; |
| 1438 |
device.ios = true; |
| 1439 |
} // Export object |
| 1440 |
|
| 1441 |
|
| 1442 |
return device; |
| 1443 |
} |
| 1444 |
|
| 1445 |
function getDevice(overrides) { |
| 1446 |
if (overrides === void 0) { |
| 1447 |
overrides = {}; |
| 1448 |
} |
| 1449 |
|
| 1450 |
if (!device) { |
| 1451 |
device = calcDevice(overrides); |
| 1452 |
} |
| 1453 |
|
| 1454 |
return device; |
| 1455 |
} |
| 1456 |
|
| 1457 |
var browser; |
| 1458 |
|
| 1459 |
function calcBrowser() { |
| 1460 |
var window = getWindow(); |
| 1461 |
|
| 1462 |
function isSafari() { |
| 1463 |
var ua = window.navigator.userAgent.toLowerCase(); |
| 1464 |
return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0; |
| 1465 |
} |
| 1466 |
|
| 1467 |
return { |
| 1468 |
isEdge: !!window.navigator.userAgent.match(/Edge/g), |
| 1469 |
isSafari: isSafari(), |
| 1470 |
isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent) |
| 1471 |
}; |
| 1472 |
} |
| 1473 |
|
| 1474 |
function getBrowser() { |
| 1475 |
if (!browser) { |
| 1476 |
browser = calcBrowser(); |
| 1477 |
} |
| 1478 |
|
| 1479 |
return browser; |
| 1480 |
} |
| 1481 |
|
| 1482 |
var supportsResizeObserver = function supportsResizeObserver() { |
| 1483 |
var window = getWindow(); |
| 1484 |
return typeof window.ResizeObserver !== 'undefined'; |
| 1485 |
}; |
| 1486 |
|
| 1487 |
var Resize = { |
| 1488 |
name: 'resize', |
| 1489 |
create: function create() { |
| 1490 |
var swiper = this; |
| 1491 |
extend(swiper, { |
| 1492 |
resize: { |
| 1493 |
observer: null, |
| 1494 |
createObserver: function createObserver() { |
| 1495 |
if (!swiper || swiper.destroyed || !swiper.initialized) return; |
| 1496 |
swiper.resize.observer = new ResizeObserver(function (entries) { |
| 1497 |
var width = swiper.width, |
| 1498 |
height = swiper.height; |
| 1499 |
var newWidth = width; |
| 1500 |
var newHeight = height; |
| 1501 |
entries.forEach(function (_ref) { |
| 1502 |
var contentBoxSize = _ref.contentBoxSize, |
| 1503 |
contentRect = _ref.contentRect, |
| 1504 |
target = _ref.target; |
| 1505 |
if (target && target !== swiper.el) return; |
| 1506 |
newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize; |
| 1507 |
newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize; |
| 1508 |
}); |
| 1509 |
|
| 1510 |
if (newWidth !== width || newHeight !== height) { |
| 1511 |
swiper.resize.resizeHandler(); |
| 1512 |
} |
| 1513 |
}); |
| 1514 |
swiper.resize.observer.observe(swiper.el); |
| 1515 |
}, |
| 1516 |
removeObserver: function removeObserver() { |
| 1517 |
if (swiper.resize.observer && swiper.resize.observer.unobserve && swiper.el) { |
| 1518 |
swiper.resize.observer.unobserve(swiper.el); |
| 1519 |
swiper.resize.observer = null; |
| 1520 |
} |
| 1521 |
}, |
| 1522 |
resizeHandler: function resizeHandler() { |
| 1523 |
if (!swiper || swiper.destroyed || !swiper.initialized) return; |
| 1524 |
swiper.emit('beforeResize'); |
| 1525 |
swiper.emit('resize'); |
| 1526 |
}, |
| 1527 |
orientationChangeHandler: function orientationChangeHandler() { |
| 1528 |
if (!swiper || swiper.destroyed || !swiper.initialized) return; |
| 1529 |
swiper.emit('orientationchange'); |
| 1530 |
} |
| 1531 |
} |
| 1532 |
}); |
| 1533 |
}, |
| 1534 |
on: { |
| 1535 |
init: function init(swiper) { |
| 1536 |
var window = getWindow(); |
| 1537 |
|
| 1538 |
if (swiper.params.resizeObserver && supportsResizeObserver()) { |
| 1539 |
swiper.resize.createObserver(); |
| 1540 |
return; |
| 1541 |
} // Emit resize |
| 1542 |
|
| 1543 |
|
| 1544 |
window.addEventListener('resize', swiper.resize.resizeHandler); // Emit orientationchange |
| 1545 |
|
| 1546 |
window.addEventListener('orientationchange', swiper.resize.orientationChangeHandler); |
| 1547 |
}, |
| 1548 |
destroy: function destroy(swiper) { |
| 1549 |
var window = getWindow(); |
| 1550 |
swiper.resize.removeObserver(); |
| 1551 |
window.removeEventListener('resize', swiper.resize.resizeHandler); |
| 1552 |
window.removeEventListener('orientationchange', swiper.resize.orientationChangeHandler); |
| 1553 |
} |
| 1554 |
} |
| 1555 |
}; |
| 1556 |
|
| 1557 |
var Observer = { |
| 1558 |
attach: function attach(target, options) { |
| 1559 |
if (options === void 0) { |
| 1560 |
options = {}; |
| 1561 |
} |
| 1562 |
|
| 1563 |
var window = getWindow(); |
| 1564 |
var swiper = this; |
| 1565 |
var ObserverFunc = window.MutationObserver || window.WebkitMutationObserver; |
| 1566 |
var observer = new ObserverFunc(function (mutations) { |
| 1567 |
// The observerUpdate event should only be triggered |
| 1568 |
// once despite the number of mutations. Additional |
| 1569 |
// triggers are redundant and are very costly |
| 1570 |
if (mutations.length === 1) { |
| 1571 |
swiper.emit('observerUpdate', mutations[0]); |
| 1572 |
return; |
| 1573 |
} |
| 1574 |
|
| 1575 |
var observerUpdate = function observerUpdate() { |
| 1576 |
swiper.emit('observerUpdate', mutations[0]); |
| 1577 |
}; |
| 1578 |
|
| 1579 |
if (window.requestAnimationFrame) { |
| 1580 |
window.requestAnimationFrame(observerUpdate); |
| 1581 |
} else { |
| 1582 |
window.setTimeout(observerUpdate, 0); |
| 1583 |
} |
| 1584 |
}); |
| 1585 |
observer.observe(target, { |
| 1586 |
attributes: typeof options.attributes === 'undefined' ? true : options.attributes, |
| 1587 |
childList: typeof options.childList === 'undefined' ? true : options.childList, |
| 1588 |
characterData: typeof options.characterData === 'undefined' ? true : options.characterData |
| 1589 |
}); |
| 1590 |
swiper.observer.observers.push(observer); |
| 1591 |
}, |
| 1592 |
init: function init() { |
| 1593 |
var swiper = this; |
| 1594 |
if (!swiper.support.observer || !swiper.params.observer) return; |
| 1595 |
|
| 1596 |
if (swiper.params.observeParents) { |
| 1597 |
var containerParents = swiper.$el.parents(); |
| 1598 |
|
| 1599 |
for (var i = 0; i < containerParents.length; i += 1) { |
| 1600 |
swiper.observer.attach(containerParents[i]); |
| 1601 |
} |
| 1602 |
} // Observe container |
| 1603 |
|
| 1604 |
|
| 1605 |
swiper.observer.attach(swiper.$el[0], { |
| 1606 |
childList: swiper.params.observeSlideChildren |
| 1607 |
}); // Observe wrapper |
| 1608 |
|
| 1609 |
swiper.observer.attach(swiper.$wrapperEl[0], { |
| 1610 |
attributes: false |
| 1611 |
}); |
| 1612 |
}, |
| 1613 |
destroy: function destroy() { |
| 1614 |
var swiper = this; |
| 1615 |
swiper.observer.observers.forEach(function (observer) { |
| 1616 |
observer.disconnect(); |
| 1617 |
}); |
| 1618 |
swiper.observer.observers = []; |
| 1619 |
} |
| 1620 |
}; |
| 1621 |
var Observer$1 = { |
| 1622 |
name: 'observer', |
| 1623 |
params: { |
| 1624 |
observer: false, |
| 1625 |
observeParents: false, |
| 1626 |
observeSlideChildren: false |
| 1627 |
}, |
| 1628 |
create: function create() { |
| 1629 |
var swiper = this; |
| 1630 |
bindModuleMethods(swiper, { |
| 1631 |
observer: _extends({}, Observer, { |
| 1632 |
observers: [] |
| 1633 |
}) |
| 1634 |
}); |
| 1635 |
}, |
| 1636 |
on: { |
| 1637 |
init: function init(swiper) { |
| 1638 |
swiper.observer.init(); |
| 1639 |
}, |
| 1640 |
destroy: function destroy(swiper) { |
| 1641 |
swiper.observer.destroy(); |
| 1642 |
} |
| 1643 |
} |
| 1644 |
}; |
| 1645 |
|
| 1646 |
var modular = { |
| 1647 |
useParams: function useParams(instanceParams) { |
| 1648 |
var instance = this; |
| 1649 |
if (!instance.modules) return; |
| 1650 |
Object.keys(instance.modules).forEach(function (moduleName) { |
| 1651 |
var module = instance.modules[moduleName]; // Extend params |
| 1652 |
|
| 1653 |
if (module.params) { |
| 1654 |
extend(instanceParams, module.params); |
| 1655 |
} |
| 1656 |
}); |
| 1657 |
}, |
| 1658 |
useModules: function useModules(modulesParams) { |
| 1659 |
if (modulesParams === void 0) { |
| 1660 |
modulesParams = {}; |
| 1661 |
} |
| 1662 |
|
| 1663 |
var instance = this; |
| 1664 |
if (!instance.modules) return; |
| 1665 |
Object.keys(instance.modules).forEach(function (moduleName) { |
| 1666 |
var module = instance.modules[moduleName]; |
| 1667 |
var moduleParams = modulesParams[moduleName] || {}; // Add event listeners |
| 1668 |
|
| 1669 |
if (module.on && instance.on) { |
| 1670 |
Object.keys(module.on).forEach(function (moduleEventName) { |
| 1671 |
instance.on(moduleEventName, module.on[moduleEventName]); |
| 1672 |
}); |
| 1673 |
} // Module create callback |
| 1674 |
|
| 1675 |
|
| 1676 |
if (module.create) { |
| 1677 |
module.create.bind(instance)(moduleParams); |
| 1678 |
} |
| 1679 |
}); |
| 1680 |
} |
| 1681 |
}; |
| 1682 |
|
| 1683 |
/* eslint-disable no-underscore-dangle */ |
| 1684 |
var eventsEmitter = { |
| 1685 |
on: function on(events, handler, priority) { |
| 1686 |
var self = this; |
| 1687 |
if (typeof handler !== 'function') return self; |
| 1688 |
var method = priority ? 'unshift' : 'push'; |
| 1689 |
events.split(' ').forEach(function (event) { |
| 1690 |
if (!self.eventsListeners[event]) self.eventsListeners[event] = []; |
| 1691 |
self.eventsListeners[event][method](handler); |
| 1692 |
}); |
| 1693 |
return self; |
| 1694 |
}, |
| 1695 |
once: function once(events, handler, priority) { |
| 1696 |
var self = this; |
| 1697 |
if (typeof handler !== 'function') return self; |
| 1698 |
|
| 1699 |
function onceHandler() { |
| 1700 |
self.off(events, onceHandler); |
| 1701 |
|
| 1702 |
if (onceHandler.__emitterProxy) { |
| 1703 |
delete onceHandler.__emitterProxy; |
| 1704 |
} |
| 1705 |
|
| 1706 |
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
| 1707 |
args[_key] = arguments[_key]; |
| 1708 |
} |
| 1709 |
|
| 1710 |
handler.apply(self, args); |
| 1711 |
} |
| 1712 |
|
| 1713 |
onceHandler.__emitterProxy = handler; |
| 1714 |
return self.on(events, onceHandler, priority); |
| 1715 |
}, |
| 1716 |
onAny: function onAny(handler, priority) { |
| 1717 |
var self = this; |
| 1718 |
if (typeof handler !== 'function') return self; |
| 1719 |
var method = priority ? 'unshift' : 'push'; |
| 1720 |
|
| 1721 |
if (self.eventsAnyListeners.indexOf(handler) < 0) { |
| 1722 |
self.eventsAnyListeners[method](handler); |
| 1723 |
} |
| 1724 |
|
| 1725 |
return self; |
| 1726 |
}, |
| 1727 |
offAny: function offAny(handler) { |
| 1728 |
var self = this; |
| 1729 |
if (!self.eventsAnyListeners) return self; |
| 1730 |
var index = self.eventsAnyListeners.indexOf(handler); |
| 1731 |
|
| 1732 |
if (index >= 0) { |
| 1733 |
self.eventsAnyListeners.splice(index, 1); |
| 1734 |
} |
| 1735 |
|
| 1736 |
return self; |
| 1737 |
}, |
| 1738 |
off: function off(events, handler) { |
| 1739 |
var self = this; |
| 1740 |
if (!self.eventsListeners) return self; |
| 1741 |
events.split(' ').forEach(function (event) { |
| 1742 |
if (typeof handler === 'undefined') { |
| 1743 |
self.eventsListeners[event] = []; |
| 1744 |
} else if (self.eventsListeners[event]) { |
| 1745 |
self.eventsListeners[event].forEach(function (eventHandler, index) { |
| 1746 |
if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) { |
| 1747 |
self.eventsListeners[event].splice(index, 1); |
| 1748 |
} |
| 1749 |
}); |
| 1750 |
} |
| 1751 |
}); |
| 1752 |
return self; |
| 1753 |
}, |
| 1754 |
emit: function emit() { |
| 1755 |
var self = this; |
| 1756 |
if (!self.eventsListeners) return self; |
| 1757 |
var events; |
| 1758 |
var data; |
| 1759 |
var context; |
| 1760 |
|
| 1761 |
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { |
| 1762 |
args[_key2] = arguments[_key2]; |
| 1763 |
} |
| 1764 |
|
| 1765 |
if (typeof args[0] === 'string' || Array.isArray(args[0])) { |
| 1766 |
events = args[0]; |
| 1767 |
data = args.slice(1, args.length); |
| 1768 |
context = self; |
| 1769 |
} else { |
| 1770 |
events = args[0].events; |
| 1771 |
data = args[0].data; |
| 1772 |
context = args[0].context || self; |
| 1773 |
} |
| 1774 |
|
| 1775 |
data.unshift(context); |
| 1776 |
var eventsArray = Array.isArray(events) ? events : events.split(' '); |
| 1777 |
eventsArray.forEach(function (event) { |
| 1778 |
if (self.eventsAnyListeners && self.eventsAnyListeners.length) { |
| 1779 |
self.eventsAnyListeners.forEach(function (eventHandler) { |
| 1780 |
eventHandler.apply(context, [event].concat(data)); |
| 1781 |
}); |
| 1782 |
} |
| 1783 |
|
| 1784 |
if (self.eventsListeners && self.eventsListeners[event]) { |
| 1785 |
self.eventsListeners[event].forEach(function (eventHandler) { |
| 1786 |
eventHandler.apply(context, data); |
| 1787 |
}); |
| 1788 |
} |
| 1789 |
}); |
| 1790 |
return self; |
| 1791 |
} |
| 1792 |
}; |
| 1793 |
|
| 1794 |
function updateSize() { |
| 1795 |
var swiper = this; |
| 1796 |
var width; |
| 1797 |
var height; |
| 1798 |
var $el = swiper.$el; |
| 1799 |
|
| 1800 |
if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) { |
| 1801 |
width = swiper.params.width; |
| 1802 |
} else { |
| 1803 |
width = $el[0].clientWidth; |
| 1804 |
} |
| 1805 |
|
| 1806 |
if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) { |
| 1807 |
height = swiper.params.height; |
| 1808 |
} else { |
| 1809 |
height = $el[0].clientHeight; |
| 1810 |
} |
| 1811 |
|
| 1812 |
if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) { |
| 1813 |
return; |
| 1814 |
} // Subtract paddings |
| 1815 |
|
| 1816 |
|
| 1817 |
width = width - parseInt($el.css('padding-left') || 0, 10) - parseInt($el.css('padding-right') || 0, 10); |
| 1818 |
height = height - parseInt($el.css('padding-top') || 0, 10) - parseInt($el.css('padding-bottom') || 0, 10); |
| 1819 |
if (Number.isNaN(width)) width = 0; |
| 1820 |
if (Number.isNaN(height)) height = 0; |
| 1821 |
extend(swiper, { |
| 1822 |
width: width, |
| 1823 |
height: height, |
| 1824 |
size: swiper.isHorizontal() ? width : height |
| 1825 |
}); |
| 1826 |
} |
| 1827 |
|
| 1828 |
function updateSlides() { |
| 1829 |
var swiper = this; |
| 1830 |
|
| 1831 |
var getDirectionLabel = function getDirectionLabel(property) { |
| 1832 |
if (swiper.isHorizontal()) { |
| 1833 |
return property; |
| 1834 |
} // prettier-ignore |
| 1835 |
|
| 1836 |
|
| 1837 |
return { |
| 1838 |
'width': 'height', |
| 1839 |
'margin-top': 'margin-left', |
| 1840 |
'margin-bottom ': 'margin-right', |
| 1841 |
'margin-left': 'margin-top', |
| 1842 |
'margin-right': 'margin-bottom', |
| 1843 |
'padding-left': 'padding-top', |
| 1844 |
'padding-right': 'padding-bottom', |
| 1845 |
'marginRight': 'marginBottom' |
| 1846 |
}[property]; |
| 1847 |
}; |
| 1848 |
|
| 1849 |
var getDirectionPropertyValue = function getDirectionPropertyValue(node, label) { |
| 1850 |
return parseFloat(node.getPropertyValue(getDirectionLabel(label)) || 0); |
| 1851 |
}; |
| 1852 |
|
| 1853 |
var params = swiper.params; |
| 1854 |
var $wrapperEl = swiper.$wrapperEl, |
| 1855 |
swiperSize = swiper.size, |
| 1856 |
rtl = swiper.rtlTranslate, |
| 1857 |
wrongRTL = swiper.wrongRTL; |
| 1858 |
var isVirtual = swiper.virtual && params.virtual.enabled; |
| 1859 |
var previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length; |
| 1860 |
var slides = $wrapperEl.children("." + swiper.params.slideClass); |
| 1861 |
var slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length; |
| 1862 |
var snapGrid = []; |
| 1863 |
var slidesGrid = []; |
| 1864 |
var slidesSizesGrid = []; |
| 1865 |
|
| 1866 |
function slidesForMargin(slideEl, slideIndex) { |
| 1867 |
if (!params.cssMode) return true; |
| 1868 |
|
| 1869 |
if (slideIndex === slides.length - 1) { |
| 1870 |
return false; |
| 1871 |
} |
| 1872 |
|
| 1873 |
return true; |
| 1874 |
} |
| 1875 |
|
| 1876 |
var offsetBefore = params.slidesOffsetBefore; |
| 1877 |
|
| 1878 |
if (typeof offsetBefore === 'function') { |
| 1879 |
offsetBefore = params.slidesOffsetBefore.call(swiper); |
| 1880 |
} |
| 1881 |
|
| 1882 |
var offsetAfter = params.slidesOffsetAfter; |
| 1883 |
|
| 1884 |
if (typeof offsetAfter === 'function') { |
| 1885 |
offsetAfter = params.slidesOffsetAfter.call(swiper); |
| 1886 |
} |
| 1887 |
|
| 1888 |
var previousSnapGridLength = swiper.snapGrid.length; |
| 1889 |
var previousSlidesGridLength = swiper.slidesGrid.length; |
| 1890 |
var spaceBetween = params.spaceBetween; |
| 1891 |
var slidePosition = -offsetBefore; |
| 1892 |
var prevSlideSize = 0; |
| 1893 |
var index = 0; |
| 1894 |
|
| 1895 |
if (typeof swiperSize === 'undefined') { |
| 1896 |
return; |
| 1897 |
} |
| 1898 |
|
| 1899 |
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) { |
| 1900 |
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize; |
| 1901 |
} |
| 1902 |
|
| 1903 |
swiper.virtualSize = -spaceBetween; // reset margins |
| 1904 |
|
| 1905 |
if (rtl) slides.css({ |
| 1906 |
marginLeft: '', |
| 1907 |
marginTop: '' |
| 1908 |
});else slides.css({ |
| 1909 |
marginRight: '', |
| 1910 |
marginBottom: '' |
| 1911 |
}); |
| 1912 |
var slidesNumberEvenToRows; |
| 1913 |
|
| 1914 |
if (params.slidesPerColumn > 1) { |
| 1915 |
if (Math.floor(slidesLength / params.slidesPerColumn) === slidesLength / swiper.params.slidesPerColumn) { |
| 1916 |
slidesNumberEvenToRows = slidesLength; |
| 1917 |
} else { |
| 1918 |
slidesNumberEvenToRows = Math.ceil(slidesLength / params.slidesPerColumn) * params.slidesPerColumn; |
| 1919 |
} |
| 1920 |
|
| 1921 |
if (params.slidesPerView !== 'auto' && params.slidesPerColumnFill === 'row') { |
| 1922 |
slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, params.slidesPerView * params.slidesPerColumn); |
| 1923 |
} |
| 1924 |
} // Calc slides |
| 1925 |
|
| 1926 |
|
| 1927 |
var slideSize; |
| 1928 |
var slidesPerColumn = params.slidesPerColumn; |
| 1929 |
var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn; |
| 1930 |
var numFullColumns = Math.floor(slidesLength / params.slidesPerColumn); |
| 1931 |
|
| 1932 |
for (var i = 0; i < slidesLength; i += 1) { |
| 1933 |
slideSize = 0; |
| 1934 |
var slide = slides.eq(i); |
| 1935 |
|
| 1936 |
if (params.slidesPerColumn > 1) { |
| 1937 |
// Set slides order |
| 1938 |
var newSlideOrderIndex = void 0; |
| 1939 |
var column = void 0; |
| 1940 |
var row = void 0; |
| 1941 |
|
| 1942 |
if (params.slidesPerColumnFill === 'row' && params.slidesPerGroup > 1) { |
| 1943 |
var groupIndex = Math.floor(i / (params.slidesPerGroup * params.slidesPerColumn)); |
| 1944 |
var slideIndexInGroup = i - params.slidesPerColumn * params.slidesPerGroup * groupIndex; |
| 1945 |
var columnsInGroup = groupIndex === 0 ? params.slidesPerGroup : Math.min(Math.ceil((slidesLength - groupIndex * slidesPerColumn * params.slidesPerGroup) / slidesPerColumn), params.slidesPerGroup); |
| 1946 |
row = Math.floor(slideIndexInGroup / columnsInGroup); |
| 1947 |
column = slideIndexInGroup - row * columnsInGroup + groupIndex * params.slidesPerGroup; |
| 1948 |
newSlideOrderIndex = column + row * slidesNumberEvenToRows / slidesPerColumn; |
| 1949 |
slide.css({ |
| 1950 |
'-webkit-box-ordinal-group': newSlideOrderIndex, |
| 1951 |
'-moz-box-ordinal-group': newSlideOrderIndex, |
| 1952 |
'-ms-flex-order': newSlideOrderIndex, |
| 1953 |
'-webkit-order': newSlideOrderIndex, |
| 1954 |
order: newSlideOrderIndex |
| 1955 |
}); |
| 1956 |
} else if (params.slidesPerColumnFill === 'column') { |
| 1957 |
column = Math.floor(i / slidesPerColumn); |
| 1958 |
row = i - column * slidesPerColumn; |
| 1959 |
|
| 1960 |
if (column > numFullColumns || column === numFullColumns && row === slidesPerColumn - 1) { |
| 1961 |
row += 1; |
| 1962 |
|
| 1963 |
if (row >= slidesPerColumn) { |
| 1964 |
row = 0; |
| 1965 |
column += 1; |
| 1966 |
} |
| 1967 |
} |
| 1968 |
} else { |
| 1969 |
row = Math.floor(i / slidesPerRow); |
| 1970 |
column = i - row * slidesPerRow; |
| 1971 |
} |
| 1972 |
|
| 1973 |
slide.css(getDirectionLabel('margin-top'), row !== 0 && params.spaceBetween && params.spaceBetween + "px"); |
| 1974 |
} |
| 1975 |
|
| 1976 |
if (slide.css('display') === 'none') continue; // eslint-disable-line |
| 1977 |
|
| 1978 |
if (params.slidesPerView === 'auto') { |
| 1979 |
var slideStyles = getComputedStyle(slide[0]); |
| 1980 |
var currentTransform = slide[0].style.transform; |
| 1981 |
var currentWebKitTransform = slide[0].style.webkitTransform; |
| 1982 |
|
| 1983 |
if (currentTransform) { |
| 1984 |
slide[0].style.transform = 'none'; |
| 1985 |
} |
| 1986 |
|
| 1987 |
if (currentWebKitTransform) { |
| 1988 |
slide[0].style.webkitTransform = 'none'; |
| 1989 |
} |
| 1990 |
|
| 1991 |
if (params.roundLengths) { |
| 1992 |
slideSize = swiper.isHorizontal() ? slide.outerWidth(true) : slide.outerHeight(true); |
| 1993 |
} else { |
| 1994 |
// eslint-disable-next-line |
| 1995 |
var width = getDirectionPropertyValue(slideStyles, 'width'); |
| 1996 |
var paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left'); |
| 1997 |
var paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right'); |
| 1998 |
var marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left'); |
| 1999 |
var marginRight = getDirectionPropertyValue(slideStyles, 'margin-right'); |
| 2000 |
var boxSizing = slideStyles.getPropertyValue('box-sizing'); |
| 2001 |
|
| 2002 |
if (boxSizing && boxSizing === 'border-box') { |
| 2003 |
slideSize = width + marginLeft + marginRight; |
| 2004 |
} else { |
| 2005 |
var _slide$ = slide[0], |
| 2006 |
clientWidth = _slide$.clientWidth, |
| 2007 |
offsetWidth = _slide$.offsetWidth; |
| 2008 |
slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth); |
| 2009 |
} |
| 2010 |
} |
| 2011 |
|
| 2012 |
if (currentTransform) { |
| 2013 |
slide[0].style.transform = currentTransform; |
| 2014 |
} |
| 2015 |
|
| 2016 |
if (currentWebKitTransform) { |
| 2017 |
slide[0].style.webkitTransform = currentWebKitTransform; |
| 2018 |
} |
| 2019 |
|
| 2020 |
if (params.roundLengths) slideSize = Math.floor(slideSize); |
| 2021 |
} else { |
| 2022 |
slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView; |
| 2023 |
if (params.roundLengths) slideSize = Math.floor(slideSize); |
| 2024 |
|
| 2025 |
if (slides[i]) { |
| 2026 |
slides[i].style[getDirectionLabel('width')] = slideSize + "px"; |
| 2027 |
} |
| 2028 |
} |
| 2029 |
|
| 2030 |
if (slides[i]) { |
| 2031 |
slides[i].swiperSlideSize = slideSize; |
| 2032 |
} |
| 2033 |
|
| 2034 |
slidesSizesGrid.push(slideSize); |
| 2035 |
|
| 2036 |
if (params.centeredSlides) { |
| 2037 |
slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween; |
| 2038 |
if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween; |
| 2039 |
if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween; |
| 2040 |
if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0; |
| 2041 |
if (params.roundLengths) slidePosition = Math.floor(slidePosition); |
| 2042 |
if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition); |
| 2043 |
slidesGrid.push(slidePosition); |
| 2044 |
} else { |
| 2045 |
if (params.roundLengths) slidePosition = Math.floor(slidePosition); |
| 2046 |
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition); |
| 2047 |
slidesGrid.push(slidePosition); |
| 2048 |
slidePosition = slidePosition + slideSize + spaceBetween; |
| 2049 |
} |
| 2050 |
|
| 2051 |
swiper.virtualSize += slideSize + spaceBetween; |
| 2052 |
prevSlideSize = slideSize; |
| 2053 |
index += 1; |
| 2054 |
} |
| 2055 |
|
| 2056 |
swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter; |
| 2057 |
var newSlidesGrid; |
| 2058 |
|
| 2059 |
if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) { |
| 2060 |
$wrapperEl.css({ |
| 2061 |
width: swiper.virtualSize + params.spaceBetween + "px" |
| 2062 |
}); |
| 2063 |
} |
| 2064 |
|
| 2065 |
if (params.setWrapperSize) { |
| 2066 |
var _$wrapperEl$css; |
| 2067 |
|
| 2068 |
$wrapperEl.css((_$wrapperEl$css = {}, _$wrapperEl$css[getDirectionLabel('width')] = swiper.virtualSize + params.spaceBetween + "px", _$wrapperEl$css)); |
| 2069 |
} |
| 2070 |
|
| 2071 |
if (params.slidesPerColumn > 1) { |
| 2072 |
var _$wrapperEl$css2; |
| 2073 |
|
| 2074 |
swiper.virtualSize = (slideSize + params.spaceBetween) * slidesNumberEvenToRows; |
| 2075 |
swiper.virtualSize = Math.ceil(swiper.virtualSize / params.slidesPerColumn) - params.spaceBetween; |
| 2076 |
$wrapperEl.css((_$wrapperEl$css2 = {}, _$wrapperEl$css2[getDirectionLabel('width')] = swiper.virtualSize + params.spaceBetween + "px", _$wrapperEl$css2)); |
| 2077 |
|
| 2078 |
if (params.centeredSlides) { |
| 2079 |
newSlidesGrid = []; |
| 2080 |
|
| 2081 |
for (var _i = 0; _i < snapGrid.length; _i += 1) { |
| 2082 |
var slidesGridItem = snapGrid[_i]; |
| 2083 |
if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem); |
| 2084 |
if (snapGrid[_i] < swiper.virtualSize + snapGrid[0]) newSlidesGrid.push(slidesGridItem); |
| 2085 |
} |
| 2086 |
|
| 2087 |
snapGrid = newSlidesGrid; |
| 2088 |
} |
| 2089 |
} // Remove last grid elements depending on width |
| 2090 |
|
| 2091 |
|
| 2092 |
if (!params.centeredSlides) { |
| 2093 |
newSlidesGrid = []; |
| 2094 |
|
| 2095 |
for (var _i2 = 0; _i2 < snapGrid.length; _i2 += 1) { |
| 2096 |
var _slidesGridItem = snapGrid[_i2]; |
| 2097 |
if (params.roundLengths) _slidesGridItem = Math.floor(_slidesGridItem); |
| 2098 |
|
| 2099 |
if (snapGrid[_i2] <= swiper.virtualSize - swiperSize) { |
| 2100 |
newSlidesGrid.push(_slidesGridItem); |
| 2101 |
} |
| 2102 |
} |
| 2103 |
|
| 2104 |
snapGrid = newSlidesGrid; |
| 2105 |
|
| 2106 |
if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) { |
| 2107 |
snapGrid.push(swiper.virtualSize - swiperSize); |
| 2108 |
} |
| 2109 |
} |
| 2110 |
|
| 2111 |
if (snapGrid.length === 0) snapGrid = [0]; |
| 2112 |
|
| 2113 |
if (params.spaceBetween !== 0) { |
| 2114 |
var _slides$filter$css; |
| 2115 |
|
| 2116 |
var key = swiper.isHorizontal() && rtl ? 'marginLeft' : getDirectionLabel('marginRight'); |
| 2117 |
slides.filter(slidesForMargin).css((_slides$filter$css = {}, _slides$filter$css[key] = spaceBetween + "px", _slides$filter$css)); |
| 2118 |
} |
| 2119 |
|
| 2120 |
if (params.centeredSlides && params.centeredSlidesBounds) { |
| 2121 |
var allSlidesSize = 0; |
| 2122 |
slidesSizesGrid.forEach(function (slideSizeValue) { |
| 2123 |
allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0); |
| 2124 |
}); |
| 2125 |
allSlidesSize -= params.spaceBetween; |
| 2126 |
var maxSnap = allSlidesSize - swiperSize; |
| 2127 |
snapGrid = snapGrid.map(function (snap) { |
| 2128 |
if (snap < 0) return -offsetBefore; |
| 2129 |
if (snap > maxSnap) return maxSnap + offsetAfter; |
| 2130 |
return snap; |
| 2131 |
}); |
| 2132 |
} |
| 2133 |
|
| 2134 |
if (params.centerInsufficientSlides) { |
| 2135 |
var _allSlidesSize = 0; |
| 2136 |
slidesSizesGrid.forEach(function (slideSizeValue) { |
| 2137 |
_allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0); |
| 2138 |
}); |
| 2139 |
_allSlidesSize -= params.spaceBetween; |
| 2140 |
|
| 2141 |
if (_allSlidesSize < swiperSize) { |
| 2142 |
var allSlidesOffset = (swiperSize - _allSlidesSize) / 2; |
| 2143 |
snapGrid.forEach(function (snap, snapIndex) { |
| 2144 |
snapGrid[snapIndex] = snap - allSlidesOffset; |
| 2145 |
}); |
| 2146 |
slidesGrid.forEach(function (snap, snapIndex) { |
| 2147 |
slidesGrid[snapIndex] = snap + allSlidesOffset; |
| 2148 |
}); |
| 2149 |
} |
| 2150 |
} |
| 2151 |
|
| 2152 |
extend(swiper, { |
| 2153 |
slides: slides, |
| 2154 |
snapGrid: snapGrid, |
| 2155 |
slidesGrid: slidesGrid, |
| 2156 |
slidesSizesGrid: slidesSizesGrid |
| 2157 |
}); |
| 2158 |
|
| 2159 |
if (slidesLength !== previousSlidesLength) { |
| 2160 |
swiper.emit('slidesLengthChange'); |
| 2161 |
} |
| 2162 |
|
| 2163 |
if (snapGrid.length !== previousSnapGridLength) { |
| 2164 |
if (swiper.params.watchOverflow) swiper.checkOverflow(); |
| 2165 |
swiper.emit('snapGridLengthChange'); |
| 2166 |
} |
| 2167 |
|
| 2168 |
if (slidesGrid.length !== previousSlidesGridLength) { |
| 2169 |
swiper.emit('slidesGridLengthChange'); |
| 2170 |
} |
| 2171 |
|
| 2172 |
if (params.watchSlidesProgress || params.watchSlidesVisibility) { |
| 2173 |
swiper.updateSlidesOffset(); |
| 2174 |
} |
| 2175 |
} |
| 2176 |
|
| 2177 |
function updateAutoHeight(speed) { |
| 2178 |
var swiper = this; |
| 2179 |
var activeSlides = []; |
| 2180 |
var newHeight = 0; |
| 2181 |
var i; |
| 2182 |
|
| 2183 |
if (typeof speed === 'number') { |
| 2184 |
swiper.setTransition(speed); |
| 2185 |
} else if (speed === true) { |
| 2186 |
swiper.setTransition(swiper.params.speed); |
| 2187 |
} // Find slides currently in view |
| 2188 |
|
| 2189 |
|
| 2190 |
if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) { |
| 2191 |
if (swiper.params.centeredSlides) { |
| 2192 |
swiper.visibleSlides.each(function (slide) { |
| 2193 |
activeSlides.push(slide); |
| 2194 |
}); |
| 2195 |
} else { |
| 2196 |
for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) { |
| 2197 |
var index = swiper.activeIndex + i; |
| 2198 |
if (index > swiper.slides.length) break; |
| 2199 |
activeSlides.push(swiper.slides.eq(index)[0]); |
| 2200 |
} |
| 2201 |
} |
| 2202 |
} else { |
| 2203 |
activeSlides.push(swiper.slides.eq(swiper.activeIndex)[0]); |
| 2204 |
} // Find new height from highest slide in view |
| 2205 |
|
| 2206 |
|
| 2207 |
for (i = 0; i < activeSlides.length; i += 1) { |
| 2208 |
if (typeof activeSlides[i] !== 'undefined') { |
| 2209 |
var height = activeSlides[i].offsetHeight; |
| 2210 |
newHeight = height > newHeight ? height : newHeight; |
| 2211 |
} |
| 2212 |
} // Update Height |
| 2213 |
|
| 2214 |
|
| 2215 |
if (newHeight) swiper.$wrapperEl.css('height', newHeight + "px"); |
| 2216 |
} |
| 2217 |
|
| 2218 |
function updateSlidesOffset() { |
| 2219 |
var swiper = this; |
| 2220 |
var slides = swiper.slides; |
| 2221 |
|
| 2222 |
for (var i = 0; i < slides.length; i += 1) { |
| 2223 |
slides[i].swiperSlideOffset = swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop; |
| 2224 |
} |
| 2225 |
} |
| 2226 |
|
| 2227 |
function updateSlidesProgress(translate) { |
| 2228 |
if (translate === void 0) { |
| 2229 |
translate = this && this.translate || 0; |
| 2230 |
} |
| 2231 |
|
| 2232 |
var swiper = this; |
| 2233 |
var params = swiper.params; |
| 2234 |
var slides = swiper.slides, |
| 2235 |
rtl = swiper.rtlTranslate; |
| 2236 |
if (slides.length === 0) return; |
| 2237 |
if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset(); |
| 2238 |
var offsetCenter = -translate; |
| 2239 |
if (rtl) offsetCenter = translate; // Visible Slides |
| 2240 |
|
| 2241 |
slides.removeClass(params.slideVisibleClass); |
| 2242 |
swiper.visibleSlidesIndexes = []; |
| 2243 |
swiper.visibleSlides = []; |
| 2244 |
|
| 2245 |
for (var i = 0; i < slides.length; i += 1) { |
| 2246 |
var slide = slides[i]; |
| 2247 |
var slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slide.swiperSlideOffset) / (slide.swiperSlideSize + params.spaceBetween); |
| 2248 |
|
| 2249 |
if (params.watchSlidesVisibility || params.centeredSlides && params.autoHeight) { |
| 2250 |
var slideBefore = -(offsetCenter - slide.swiperSlideOffset); |
| 2251 |
var slideAfter = slideBefore + swiper.slidesSizesGrid[i]; |
| 2252 |
var isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size; |
| 2253 |
|
| 2254 |
if (isVisible) { |
| 2255 |
swiper.visibleSlides.push(slide); |
| 2256 |
swiper.visibleSlidesIndexes.push(i); |
| 2257 |
slides.eq(i).addClass(params.slideVisibleClass); |
| 2258 |
} |
| 2259 |
} |
| 2260 |
|
| 2261 |
slide.progress = rtl ? -slideProgress : slideProgress; |
| 2262 |
} |
| 2263 |
|
| 2264 |
swiper.visibleSlides = $(swiper.visibleSlides); |
| 2265 |
} |
| 2266 |
|
| 2267 |
function updateProgress(translate) { |
| 2268 |
var swiper = this; |
| 2269 |
|
| 2270 |
if (typeof translate === 'undefined') { |
| 2271 |
var multiplier = swiper.rtlTranslate ? -1 : 1; // eslint-disable-next-line |
| 2272 |
|
| 2273 |
translate = swiper && swiper.translate && swiper.translate * multiplier || 0; |
| 2274 |
} |
| 2275 |
|
| 2276 |
var params = swiper.params; |
| 2277 |
var translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); |
| 2278 |
var progress = swiper.progress, |
| 2279 |
isBeginning = swiper.isBeginning, |
| 2280 |
isEnd = swiper.isEnd; |
| 2281 |
var wasBeginning = isBeginning; |
| 2282 |
var wasEnd = isEnd; |
| 2283 |
|
| 2284 |
if (translatesDiff === 0) { |
| 2285 |
progress = 0; |
| 2286 |
isBeginning = true; |
| 2287 |
isEnd = true; |
| 2288 |
} else { |
| 2289 |
progress = (translate - swiper.minTranslate()) / translatesDiff; |
| 2290 |
isBeginning = progress <= 0; |
| 2291 |
isEnd = progress >= 1; |
| 2292 |
} |
| 2293 |
|
| 2294 |
extend(swiper, { |
| 2295 |
progress: progress, |
| 2296 |
isBeginning: isBeginning, |
| 2297 |
isEnd: isEnd |
| 2298 |
}); |
| 2299 |
if (params.watchSlidesProgress || params.watchSlidesVisibility || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate); |
| 2300 |
|
| 2301 |
if (isBeginning && !wasBeginning) { |
| 2302 |
swiper.emit('reachBeginning toEdge'); |
| 2303 |
} |
| 2304 |
|
| 2305 |
if (isEnd && !wasEnd) { |
| 2306 |
swiper.emit('reachEnd toEdge'); |
| 2307 |
} |
| 2308 |
|
| 2309 |
if (wasBeginning && !isBeginning || wasEnd && !isEnd) { |
| 2310 |
swiper.emit('fromEdge'); |
| 2311 |
} |
| 2312 |
|
| 2313 |
swiper.emit('progress', progress); |
| 2314 |
} |
| 2315 |
|
| 2316 |
function updateSlidesClasses() { |
| 2317 |
var swiper = this; |
| 2318 |
var slides = swiper.slides, |
| 2319 |
params = swiper.params, |
| 2320 |
$wrapperEl = swiper.$wrapperEl, |
| 2321 |
activeIndex = swiper.activeIndex, |
| 2322 |
realIndex = swiper.realIndex; |
| 2323 |
var isVirtual = swiper.virtual && params.virtual.enabled; |
| 2324 |
slides.removeClass(params.slideActiveClass + " " + params.slideNextClass + " " + params.slidePrevClass + " " + params.slideDuplicateActiveClass + " " + params.slideDuplicateNextClass + " " + params.slideDuplicatePrevClass); |
| 2325 |
var activeSlide; |
| 2326 |
|
| 2327 |
if (isVirtual) { |
| 2328 |
activeSlide = swiper.$wrapperEl.find("." + params.slideClass + "[data-swiper-slide-index=\"" + activeIndex + "\"]"); |
| 2329 |
} else { |
| 2330 |
activeSlide = slides.eq(activeIndex); |
| 2331 |
} // Active classes |
| 2332 |
|
| 2333 |
|
| 2334 |
activeSlide.addClass(params.slideActiveClass); |
| 2335 |
|
| 2336 |
if (params.loop) { |
| 2337 |
// Duplicate to all looped slides |
| 2338 |
if (activeSlide.hasClass(params.slideDuplicateClass)) { |
| 2339 |
$wrapperEl.children("." + params.slideClass + ":not(." + params.slideDuplicateClass + ")[data-swiper-slide-index=\"" + realIndex + "\"]").addClass(params.slideDuplicateActiveClass); |
| 2340 |
} else { |
| 2341 |
$wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass + "[data-swiper-slide-index=\"" + realIndex + "\"]").addClass(params.slideDuplicateActiveClass); |
| 2342 |
} |
| 2343 |
} // Next Slide |
| 2344 |
|
| 2345 |
|
| 2346 |
var nextSlide = activeSlide.nextAll("." + params.slideClass).eq(0).addClass(params.slideNextClass); |
| 2347 |
|
| 2348 |
if (params.loop && nextSlide.length === 0) { |
| 2349 |
nextSlide = slides.eq(0); |
| 2350 |
nextSlide.addClass(params.slideNextClass); |
| 2351 |
} // Prev Slide |
| 2352 |
|
| 2353 |
|
| 2354 |
var prevSlide = activeSlide.prevAll("." + params.slideClass).eq(0).addClass(params.slidePrevClass); |
| 2355 |
|
| 2356 |
if (params.loop && prevSlide.length === 0) { |
| 2357 |
prevSlide = slides.eq(-1); |
| 2358 |
prevSlide.addClass(params.slidePrevClass); |
| 2359 |
} |
| 2360 |
|
| 2361 |
if (params.loop) { |
| 2362 |
// Duplicate to all looped slides |
| 2363 |
if (nextSlide.hasClass(params.slideDuplicateClass)) { |
| 2364 |
$wrapperEl.children("." + params.slideClass + ":not(." + params.slideDuplicateClass + ")[data-swiper-slide-index=\"" + nextSlide.attr('data-swiper-slide-index') + "\"]").addClass(params.slideDuplicateNextClass); |
| 2365 |
} else { |
| 2366 |
$wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass + "[data-swiper-slide-index=\"" + nextSlide.attr('data-swiper-slide-index') + "\"]").addClass(params.slideDuplicateNextClass); |
| 2367 |
} |
| 2368 |
|
| 2369 |
if (prevSlide.hasClass(params.slideDuplicateClass)) { |
| 2370 |
$wrapperEl.children("." + params.slideClass + ":not(." + params.slideDuplicateClass + ")[data-swiper-slide-index=\"" + prevSlide.attr('data-swiper-slide-index') + "\"]").addClass(params.slideDuplicatePrevClass); |
| 2371 |
} else { |
| 2372 |
$wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass + "[data-swiper-slide-index=\"" + prevSlide.attr('data-swiper-slide-index') + "\"]").addClass(params.slideDuplicatePrevClass); |
| 2373 |
} |
| 2374 |
} |
| 2375 |
|
| 2376 |
swiper.emitSlidesClasses(); |
| 2377 |
} |
| 2378 |
|
| 2379 |
function updateActiveIndex(newActiveIndex) { |
| 2380 |
var swiper = this; |
| 2381 |
var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate; |
| 2382 |
var slidesGrid = swiper.slidesGrid, |
| 2383 |
snapGrid = swiper.snapGrid, |
| 2384 |
params = swiper.params, |
| 2385 |
previousIndex = swiper.activeIndex, |
| 2386 |
previousRealIndex = swiper.realIndex, |
| 2387 |
previousSnapIndex = swiper.snapIndex; |
| 2388 |
var activeIndex = newActiveIndex; |
| 2389 |
var snapIndex; |
| 2390 |
|
| 2391 |
if (typeof activeIndex === 'undefined') { |
| 2392 |
for (var i = 0; i < slidesGrid.length; i += 1) { |
| 2393 |
if (typeof slidesGrid[i + 1] !== 'undefined') { |
| 2394 |
if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) { |
| 2395 |
activeIndex = i; |
| 2396 |
} else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) { |
| 2397 |
activeIndex = i + 1; |
| 2398 |
} |
| 2399 |
} else if (translate >= slidesGrid[i]) { |
| 2400 |
activeIndex = i; |
| 2401 |
} |
| 2402 |
} // Normalize slideIndex |
| 2403 |
|
| 2404 |
|
| 2405 |
if (params.normalizeSlideIndex) { |
| 2406 |
if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0; |
| 2407 |
} |
| 2408 |
} |
| 2409 |
|
| 2410 |
if (snapGrid.indexOf(translate) >= 0) { |
| 2411 |
snapIndex = snapGrid.indexOf(translate); |
| 2412 |
} else { |
| 2413 |
var skip = Math.min(params.slidesPerGroupSkip, activeIndex); |
| 2414 |
snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup); |
| 2415 |
} |
| 2416 |
|
| 2417 |
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1; |
| 2418 |
|
| 2419 |
if (activeIndex === previousIndex) { |
| 2420 |
if (snapIndex !== previousSnapIndex) { |
| 2421 |
swiper.snapIndex = snapIndex; |
| 2422 |
swiper.emit('snapIndexChange'); |
| 2423 |
} |
| 2424 |
|
| 2425 |
return; |
| 2426 |
} // Get real index |
| 2427 |
|
| 2428 |
|
| 2429 |
var realIndex = parseInt(swiper.slides.eq(activeIndex).attr('data-swiper-slide-index') || activeIndex, 10); |
| 2430 |
extend(swiper, { |
| 2431 |
snapIndex: snapIndex, |
| 2432 |
realIndex: realIndex, |
| 2433 |
previousIndex: previousIndex, |
| 2434 |
activeIndex: activeIndex |
| 2435 |
}); |
| 2436 |
swiper.emit('activeIndexChange'); |
| 2437 |
swiper.emit('snapIndexChange'); |
| 2438 |
|
| 2439 |
if (previousRealIndex !== realIndex) { |
| 2440 |
swiper.emit('realIndexChange'); |
| 2441 |
} |
| 2442 |
|
| 2443 |
if (swiper.initialized || swiper.params.runCallbacksOnInit) { |
| 2444 |
swiper.emit('slideChange'); |
| 2445 |
} |
| 2446 |
} |
| 2447 |
|
| 2448 |
function updateClickedSlide(e) { |
| 2449 |
var swiper = this; |
| 2450 |
var params = swiper.params; |
| 2451 |
var slide = $(e.target).closest("." + params.slideClass)[0]; |
| 2452 |
var slideFound = false; |
| 2453 |
var slideIndex; |
| 2454 |
|
| 2455 |
if (slide) { |
| 2456 |
for (var i = 0; i < swiper.slides.length; i += 1) { |
| 2457 |
if (swiper.slides[i] === slide) { |
| 2458 |
slideFound = true; |
| 2459 |
slideIndex = i; |
| 2460 |
break; |
| 2461 |
} |
| 2462 |
} |
| 2463 |
} |
| 2464 |
|
| 2465 |
if (slide && slideFound) { |
| 2466 |
swiper.clickedSlide = slide; |
| 2467 |
|
| 2468 |
if (swiper.virtual && swiper.params.virtual.enabled) { |
| 2469 |
swiper.clickedIndex = parseInt($(slide).attr('data-swiper-slide-index'), 10); |
| 2470 |
} else { |
| 2471 |
swiper.clickedIndex = slideIndex; |
| 2472 |
} |
| 2473 |
} else { |
| 2474 |
swiper.clickedSlide = undefined; |
| 2475 |
swiper.clickedIndex = undefined; |
| 2476 |
return; |
| 2477 |
} |
| 2478 |
|
| 2479 |
if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) { |
| 2480 |
swiper.slideToClickedSlide(); |
| 2481 |
} |
| 2482 |
} |
| 2483 |
|
| 2484 |
var update = { |
| 2485 |
updateSize: updateSize, |
| 2486 |
updateSlides: updateSlides, |
| 2487 |
updateAutoHeight: updateAutoHeight, |
| 2488 |
updateSlidesOffset: updateSlidesOffset, |
| 2489 |
updateSlidesProgress: updateSlidesProgress, |
| 2490 |
updateProgress: updateProgress, |
| 2491 |
updateSlidesClasses: updateSlidesClasses, |
| 2492 |
updateActiveIndex: updateActiveIndex, |
| 2493 |
updateClickedSlide: updateClickedSlide |
| 2494 |
}; |
| 2495 |
|
| 2496 |
function getSwiperTranslate(axis) { |
| 2497 |
if (axis === void 0) { |
| 2498 |
axis = this.isHorizontal() ? 'x' : 'y'; |
| 2499 |
} |
| 2500 |
|
| 2501 |
var swiper = this; |
| 2502 |
var params = swiper.params, |
| 2503 |
rtl = swiper.rtlTranslate, |
| 2504 |
translate = swiper.translate, |
| 2505 |
$wrapperEl = swiper.$wrapperEl; |
| 2506 |
|
| 2507 |
if (params.virtualTranslate) { |
| 2508 |
return rtl ? -translate : translate; |
| 2509 |
} |
| 2510 |
|
| 2511 |
if (params.cssMode) { |
| 2512 |
return translate; |
| 2513 |
} |
| 2514 |
|
| 2515 |
var currentTranslate = getTranslate($wrapperEl[0], axis); |
| 2516 |
if (rtl) currentTranslate = -currentTranslate; |
| 2517 |
return currentTranslate || 0; |
| 2518 |
} |
| 2519 |
|
| 2520 |
function setTranslate(translate, byController) { |
| 2521 |
var swiper = this; |
| 2522 |
var rtl = swiper.rtlTranslate, |
| 2523 |
params = swiper.params, |
| 2524 |
$wrapperEl = swiper.$wrapperEl, |
| 2525 |
wrapperEl = swiper.wrapperEl, |
| 2526 |
progress = swiper.progress; |
| 2527 |
var x = 0; |
| 2528 |
var y = 0; |
| 2529 |
var z = 0; |
| 2530 |
|
| 2531 |
if (swiper.isHorizontal()) { |
| 2532 |
x = rtl ? -translate : translate; |
| 2533 |
} else { |
| 2534 |
y = translate; |
| 2535 |
} |
| 2536 |
|
| 2537 |
if (params.roundLengths) { |
| 2538 |
x = Math.floor(x); |
| 2539 |
y = Math.floor(y); |
| 2540 |
} |
| 2541 |
|
| 2542 |
if (params.cssMode) { |
| 2543 |
wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y; |
| 2544 |
} else if (!params.virtualTranslate) { |
| 2545 |
$wrapperEl.transform("translate3d(" + x + "px, " + y + "px, " + z + "px)"); |
| 2546 |
} |
| 2547 |
|
| 2548 |
swiper.previousTranslate = swiper.translate; |
| 2549 |
swiper.translate = swiper.isHorizontal() ? x : y; // Check if we need to update progress |
| 2550 |
|
| 2551 |
var newProgress; |
| 2552 |
var translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); |
| 2553 |
|
| 2554 |
if (translatesDiff === 0) { |
| 2555 |
newProgress = 0; |
| 2556 |
} else { |
| 2557 |
newProgress = (translate - swiper.minTranslate()) / translatesDiff; |
| 2558 |
} |
| 2559 |
|
| 2560 |
if (newProgress !== progress) { |
| 2561 |
swiper.updateProgress(translate); |
| 2562 |
} |
| 2563 |
|
| 2564 |
swiper.emit('setTranslate', swiper.translate, byController); |
| 2565 |
} |
| 2566 |
|
| 2567 |
function minTranslate() { |
| 2568 |
return -this.snapGrid[0]; |
| 2569 |
} |
| 2570 |
|
| 2571 |
function maxTranslate() { |
| 2572 |
return -this.snapGrid[this.snapGrid.length - 1]; |
| 2573 |
} |
| 2574 |
|
| 2575 |
function translateTo(translate, speed, runCallbacks, translateBounds, internal) { |
| 2576 |
if (translate === void 0) { |
| 2577 |
translate = 0; |
| 2578 |
} |
| 2579 |
|
| 2580 |
if (speed === void 0) { |
| 2581 |
speed = this.params.speed; |
| 2582 |
} |
| 2583 |
|
| 2584 |
if (runCallbacks === void 0) { |
| 2585 |
runCallbacks = true; |
| 2586 |
} |
| 2587 |
|
| 2588 |
if (translateBounds === void 0) { |
| 2589 |
translateBounds = true; |
| 2590 |
} |
| 2591 |
|
| 2592 |
var swiper = this; |
| 2593 |
var params = swiper.params, |
| 2594 |
wrapperEl = swiper.wrapperEl; |
| 2595 |
|
| 2596 |
if (swiper.animating && params.preventInteractionOnTransition) { |
| 2597 |
return false; |
| 2598 |
} |
| 2599 |
|
| 2600 |
var minTranslate = swiper.minTranslate(); |
| 2601 |
var maxTranslate = swiper.maxTranslate(); |
| 2602 |
var newTranslate; |
| 2603 |
if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate; // Update progress |
| 2604 |
|
| 2605 |
swiper.updateProgress(newTranslate); |
| 2606 |
|
| 2607 |
if (params.cssMode) { |
| 2608 |
var isH = swiper.isHorizontal(); |
| 2609 |
|
| 2610 |
if (speed === 0) { |
| 2611 |
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate; |
| 2612 |
} else { |
| 2613 |
// eslint-disable-next-line |
| 2614 |
if (wrapperEl.scrollTo) { |
| 2615 |
var _wrapperEl$scrollTo; |
| 2616 |
|
| 2617 |
wrapperEl.scrollTo((_wrapperEl$scrollTo = {}, _wrapperEl$scrollTo[isH ? 'left' : 'top'] = -newTranslate, _wrapperEl$scrollTo.behavior = 'smooth', _wrapperEl$scrollTo)); |
| 2618 |
} else { |
| 2619 |
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate; |
| 2620 |
} |
| 2621 |
} |
| 2622 |
|
| 2623 |
return true; |
| 2624 |
} |
| 2625 |
|
| 2626 |
if (speed === 0) { |
| 2627 |
swiper.setTransition(0); |
| 2628 |
swiper.setTranslate(newTranslate); |
| 2629 |
|
| 2630 |
if (runCallbacks) { |
| 2631 |
swiper.emit('beforeTransitionStart', speed, internal); |
| 2632 |
swiper.emit('transitionEnd'); |
| 2633 |
} |
| 2634 |
} else { |
| 2635 |
swiper.setTransition(speed); |
| 2636 |
swiper.setTranslate(newTranslate); |
| 2637 |
|
| 2638 |
if (runCallbacks) { |
| 2639 |
swiper.emit('beforeTransitionStart', speed, internal); |
| 2640 |
swiper.emit('transitionStart'); |
| 2641 |
} |
| 2642 |
|
| 2643 |
if (!swiper.animating) { |
| 2644 |
swiper.animating = true; |
| 2645 |
|
| 2646 |
if (!swiper.onTranslateToWrapperTransitionEnd) { |
| 2647 |
swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) { |
| 2648 |
if (!swiper || swiper.destroyed) return; |
| 2649 |
if (e.target !== this) return; |
| 2650 |
swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd); |
| 2651 |
swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd); |
| 2652 |
swiper.onTranslateToWrapperTransitionEnd = null; |
| 2653 |
delete swiper.onTranslateToWrapperTransitionEnd; |
| 2654 |
|
| 2655 |
if (runCallbacks) { |
| 2656 |
swiper.emit('transitionEnd'); |
| 2657 |
} |
| 2658 |
}; |
| 2659 |
} |
| 2660 |
|
| 2661 |
swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd); |
| 2662 |
swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd); |
| 2663 |
} |
| 2664 |
} |
| 2665 |
|
| 2666 |
return true; |
| 2667 |
} |
| 2668 |
|
| 2669 |
var translate = { |
| 2670 |
getTranslate: getSwiperTranslate, |
| 2671 |
setTranslate: setTranslate, |
| 2672 |
minTranslate: minTranslate, |
| 2673 |
maxTranslate: maxTranslate, |
| 2674 |
translateTo: translateTo |
| 2675 |
}; |
| 2676 |
|
| 2677 |
function setTransition(duration, byController) { |
| 2678 |
var swiper = this; |
| 2679 |
|
| 2680 |
if (!swiper.params.cssMode) { |
| 2681 |
swiper.$wrapperEl.transition(duration); |
| 2682 |
} |
| 2683 |
|
| 2684 |
swiper.emit('setTransition', duration, byController); |
| 2685 |
} |
| 2686 |
|
| 2687 |
function transitionStart(runCallbacks, direction) { |
| 2688 |
if (runCallbacks === void 0) { |
| 2689 |
runCallbacks = true; |
| 2690 |
} |
| 2691 |
|
| 2692 |
var swiper = this; |
| 2693 |
var activeIndex = swiper.activeIndex, |
| 2694 |
params = swiper.params, |
| 2695 |
previousIndex = swiper.previousIndex; |
| 2696 |
if (params.cssMode) return; |
| 2697 |
|
| 2698 |
if (params.autoHeight) { |
| 2699 |
swiper.updateAutoHeight(); |
| 2700 |
} |
| 2701 |
|
| 2702 |
var dir = direction; |
| 2703 |
|
| 2704 |
if (!dir) { |
| 2705 |
if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset'; |
| 2706 |
} |
| 2707 |
|
| 2708 |
swiper.emit('transitionStart'); |
| 2709 |
|
| 2710 |
if (runCallbacks && activeIndex !== previousIndex) { |
| 2711 |
if (dir === 'reset') { |
| 2712 |
swiper.emit('slideResetTransitionStart'); |
| 2713 |
return; |
| 2714 |
} |
| 2715 |
|
| 2716 |
swiper.emit('slideChangeTransitionStart'); |
| 2717 |
|
| 2718 |
if (dir === 'next') { |
| 2719 |
swiper.emit('slideNextTransitionStart'); |
| 2720 |
} else { |
| 2721 |
swiper.emit('slidePrevTransitionStart'); |
| 2722 |
} |
| 2723 |
} |
| 2724 |
} |
| 2725 |
|
| 2726 |
function transitionEnd(runCallbacks, direction) { |
| 2727 |
if (runCallbacks === void 0) { |
| 2728 |
runCallbacks = true; |
| 2729 |
} |
| 2730 |
|
| 2731 |
var swiper = this; |
| 2732 |
var activeIndex = swiper.activeIndex, |
| 2733 |
previousIndex = swiper.previousIndex, |
| 2734 |
params = swiper.params; |
| 2735 |
swiper.animating = false; |
| 2736 |
if (params.cssMode) return; |
| 2737 |
swiper.setTransition(0); |
| 2738 |
var dir = direction; |
| 2739 |
|
| 2740 |
if (!dir) { |
| 2741 |
if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset'; |
| 2742 |
} |
| 2743 |
|
| 2744 |
swiper.emit('transitionEnd'); |
| 2745 |
|
| 2746 |
if (runCallbacks && activeIndex !== previousIndex) { |
| 2747 |
if (dir === 'reset') { |
| 2748 |
swiper.emit('slideResetTransitionEnd'); |
| 2749 |
return; |
| 2750 |
} |
| 2751 |
|
| 2752 |
swiper.emit('slideChangeTransitionEnd'); |
| 2753 |
|
| 2754 |
if (dir === 'next') { |
| 2755 |
swiper.emit('slideNextTransitionEnd'); |
| 2756 |
} else { |
| 2757 |
swiper.emit('slidePrevTransitionEnd'); |
| 2758 |
} |
| 2759 |
} |
| 2760 |
} |
| 2761 |
|
| 2762 |
var transition = { |
| 2763 |
setTransition: setTransition, |
| 2764 |
transitionStart: transitionStart, |
| 2765 |
transitionEnd: transitionEnd |
| 2766 |
}; |
| 2767 |
|
| 2768 |
function slideTo(index, speed, runCallbacks, internal) { |
| 2769 |
if (index === void 0) { |
| 2770 |
index = 0; |
| 2771 |
} |
| 2772 |
|
| 2773 |
if (speed === void 0) { |
| 2774 |
speed = this.params.speed; |
| 2775 |
} |
| 2776 |
|
| 2777 |
if (runCallbacks === void 0) { |
| 2778 |
runCallbacks = true; |
| 2779 |
} |
| 2780 |
|
| 2781 |
if (typeof index !== 'number' && typeof index !== 'string') { |
| 2782 |
throw new Error("The 'index' argument cannot have type other than 'number' or 'string'. [" + typeof index + "] given."); |
| 2783 |
} |
| 2784 |
|
| 2785 |
if (typeof index === 'string') { |
| 2786 |
/** |
| 2787 |
* The `index` argument converted from `string` to `number`. |
| 2788 |
* @type {number} |
| 2789 |
*/ |
| 2790 |
var indexAsNumber = parseInt(index, 10); |
| 2791 |
/** |
| 2792 |
* Determines whether the `index` argument is a valid `number` |
| 2793 |
* after being converted from the `string` type. |
| 2794 |
* @type {boolean} |
| 2795 |
*/ |
| 2796 |
|
| 2797 |
var isValidNumber = isFinite(indexAsNumber); |
| 2798 |
|
| 2799 |
if (!isValidNumber) { |
| 2800 |
throw new Error("The passed-in 'index' (string) couldn't be converted to 'number'. [" + index + "] given."); |
| 2801 |
} // Knowing that the converted `index` is a valid number, |
| 2802 |
// we can update the original argument's value. |
| 2803 |
|
| 2804 |
|
| 2805 |
index = indexAsNumber; |
| 2806 |
} |
| 2807 |
|
| 2808 |
var swiper = this; |
| 2809 |
var slideIndex = index; |
| 2810 |
if (slideIndex < 0) slideIndex = 0; |
| 2811 |
var params = swiper.params, |
| 2812 |
snapGrid = swiper.snapGrid, |
| 2813 |
slidesGrid = swiper.slidesGrid, |
| 2814 |
previousIndex = swiper.previousIndex, |
| 2815 |
activeIndex = swiper.activeIndex, |
| 2816 |
rtl = swiper.rtlTranslate, |
| 2817 |
wrapperEl = swiper.wrapperEl; |
| 2818 |
|
| 2819 |
if (swiper.animating && params.preventInteractionOnTransition) { |
| 2820 |
return false; |
| 2821 |
} |
| 2822 |
|
| 2823 |
var skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex); |
| 2824 |
var snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup); |
| 2825 |
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1; |
| 2826 |
|
| 2827 |
if ((activeIndex || params.initialSlide || 0) === (previousIndex || 0) && runCallbacks) { |
| 2828 |
swiper.emit('beforeSlideChangeStart'); |
| 2829 |
} |
| 2830 |
|
| 2831 |
var translate = -snapGrid[snapIndex]; // Update progress |
| 2832 |
|
| 2833 |
swiper.updateProgress(translate); // Normalize slideIndex |
| 2834 |
|
| 2835 |
if (params.normalizeSlideIndex) { |
| 2836 |
for (var i = 0; i < slidesGrid.length; i += 1) { |
| 2837 |
var normalizedTranslate = -Math.floor(translate * 100); |
| 2838 |
var normalizedGird = Math.floor(slidesGrid[i] * 100); |
| 2839 |
var normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100); |
| 2840 |
|
| 2841 |
if (typeof slidesGrid[i + 1] !== 'undefined') { |
| 2842 |
if (normalizedTranslate >= normalizedGird && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGird) / 2) { |
| 2843 |
slideIndex = i; |
| 2844 |
} else if (normalizedTranslate >= normalizedGird && normalizedTranslate < normalizedGridNext) { |
| 2845 |
slideIndex = i + 1; |
| 2846 |
} |
| 2847 |
} else if (normalizedTranslate >= normalizedGird) { |
| 2848 |
slideIndex = i; |
| 2849 |
} |
| 2850 |
} |
| 2851 |
} // Directions locks |
| 2852 |
|
| 2853 |
|
| 2854 |
if (swiper.initialized && slideIndex !== activeIndex) { |
| 2855 |
if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) { |
| 2856 |
return false; |
| 2857 |
} |
| 2858 |
|
| 2859 |
if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) { |
| 2860 |
if ((activeIndex || 0) !== slideIndex) return false; |
| 2861 |
} |
| 2862 |
} |
| 2863 |
|
| 2864 |
var direction; |
| 2865 |
if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset'; // Update Index |
| 2866 |
|
| 2867 |
if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) { |
| 2868 |
swiper.updateActiveIndex(slideIndex); // Update Height |
| 2869 |
|
| 2870 |
if (params.autoHeight) { |
| 2871 |
swiper.updateAutoHeight(); |
| 2872 |
} |
| 2873 |
|
| 2874 |
swiper.updateSlidesClasses(); |
| 2875 |
|
| 2876 |
if (params.effect !== 'slide') { |
| 2877 |
swiper.setTranslate(translate); |
| 2878 |
} |
| 2879 |
|
| 2880 |
if (direction !== 'reset') { |
| 2881 |
swiper.transitionStart(runCallbacks, direction); |
| 2882 |
swiper.transitionEnd(runCallbacks, direction); |
| 2883 |
} |
| 2884 |
|
| 2885 |
return false; |
| 2886 |
} |
| 2887 |
|
| 2888 |
if (params.cssMode) { |
| 2889 |
var isH = swiper.isHorizontal(); |
| 2890 |
var t = -translate; |
| 2891 |
|
| 2892 |
if (rtl) { |
| 2893 |
t = wrapperEl.scrollWidth - wrapperEl.offsetWidth - t; |
| 2894 |
} |
| 2895 |
|
| 2896 |
if (speed === 0) { |
| 2897 |
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t; |
| 2898 |
} else { |
| 2899 |
// eslint-disable-next-line |
| 2900 |
if (wrapperEl.scrollTo) { |
| 2901 |
var _wrapperEl$scrollTo; |
| 2902 |
|
| 2903 |
wrapperEl.scrollTo((_wrapperEl$scrollTo = {}, _wrapperEl$scrollTo[isH ? 'left' : 'top'] = t, _wrapperEl$scrollTo.behavior = 'smooth', _wrapperEl$scrollTo)); |
| 2904 |
} else { |
| 2905 |
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t; |
| 2906 |
} |
| 2907 |
} |
| 2908 |
|
| 2909 |
return true; |
| 2910 |
} |
| 2911 |
|
| 2912 |
if (speed === 0) { |
| 2913 |
swiper.setTransition(0); |
| 2914 |
swiper.setTranslate(translate); |
| 2915 |
swiper.updateActiveIndex(slideIndex); |
| 2916 |
swiper.updateSlidesClasses(); |
| 2917 |
swiper.emit('beforeTransitionStart', speed, internal); |
| 2918 |
swiper.transitionStart(runCallbacks, direction); |
| 2919 |
swiper.transitionEnd(runCallbacks, direction); |
| 2920 |
} else { |
| 2921 |
swiper.setTransition(speed); |
| 2922 |
swiper.setTranslate(translate); |
| 2923 |
swiper.updateActiveIndex(slideIndex); |
| 2924 |
swiper.updateSlidesClasses(); |
| 2925 |
swiper.emit('beforeTransitionStart', speed, internal); |
| 2926 |
swiper.transitionStart(runCallbacks, direction); |
| 2927 |
|
| 2928 |
if (!swiper.animating) { |
| 2929 |
swiper.animating = true; |
| 2930 |
|
| 2931 |
if (!swiper.onSlideToWrapperTransitionEnd) { |
| 2932 |
swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) { |
| 2933 |
if (!swiper || swiper.destroyed) return; |
| 2934 |
if (e.target !== this) return; |
| 2935 |
swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd); |
| 2936 |
swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd); |
| 2937 |
swiper.onSlideToWrapperTransitionEnd = null; |
| 2938 |
delete swiper.onSlideToWrapperTransitionEnd; |
| 2939 |
swiper.transitionEnd(runCallbacks, direction); |
| 2940 |
}; |
| 2941 |
} |
| 2942 |
|
| 2943 |
swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd); |
| 2944 |
swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd); |
| 2945 |
} |
| 2946 |
} |
| 2947 |
|
| 2948 |
return true; |
| 2949 |
} |
| 2950 |
|
| 2951 |
function slideToLoop(index, speed, runCallbacks, internal) { |
| 2952 |
if (index === void 0) { |
| 2953 |
index = 0; |
| 2954 |
} |
| 2955 |
|
| 2956 |
if (speed === void 0) { |
| 2957 |
speed = this.params.speed; |
| 2958 |
} |
| 2959 |
|
| 2960 |
if (runCallbacks === void 0) { |
| 2961 |
runCallbacks = true; |
| 2962 |
} |
| 2963 |
|
| 2964 |
var swiper = this; |
| 2965 |
var newIndex = index; |
| 2966 |
|
| 2967 |
if (swiper.params.loop) { |
| 2968 |
newIndex += swiper.loopedSlides; |
| 2969 |
} |
| 2970 |
|
| 2971 |
return swiper.slideTo(newIndex, speed, runCallbacks, internal); |
| 2972 |
} |
| 2973 |
|
| 2974 |
/* eslint no-unused-vars: "off" */ |
| 2975 |
function slideNext(speed, runCallbacks, internal) { |
| 2976 |
if (speed === void 0) { |
| 2977 |
speed = this.params.speed; |
| 2978 |
} |
| 2979 |
|
| 2980 |
if (runCallbacks === void 0) { |
| 2981 |
runCallbacks = true; |
| 2982 |
} |
| 2983 |
|
| 2984 |
var swiper = this; |
| 2985 |
var params = swiper.params, |
| 2986 |
animating = swiper.animating; |
| 2987 |
var increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup; |
| 2988 |
|
| 2989 |
if (params.loop) { |
| 2990 |
if (animating && params.loopPreventsSlide) return false; |
| 2991 |
swiper.loopFix(); // eslint-disable-next-line |
| 2992 |
|
| 2993 |
swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; |
| 2994 |
} |
| 2995 |
|
| 2996 |
return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal); |
| 2997 |
} |
| 2998 |
|
| 2999 |
/* eslint no-unused-vars: "off" */ |
| 3000 |
function slidePrev(speed, runCallbacks, internal) { |
| 3001 |
if (speed === void 0) { |
| 3002 |
speed = this.params.speed; |
| 3003 |
} |
| 3004 |
|
| 3005 |
if (runCallbacks === void 0) { |
| 3006 |
runCallbacks = true; |
| 3007 |
} |
| 3008 |
|
| 3009 |
var swiper = this; |
| 3010 |
var params = swiper.params, |
| 3011 |
animating = swiper.animating, |
| 3012 |
snapGrid = swiper.snapGrid, |
| 3013 |
slidesGrid = swiper.slidesGrid, |
| 3014 |
rtlTranslate = swiper.rtlTranslate; |
| 3015 |
|
| 3016 |
if (params.loop) { |
| 3017 |
if (animating && params.loopPreventsSlide) return false; |
| 3018 |
swiper.loopFix(); // eslint-disable-next-line |
| 3019 |
|
| 3020 |
swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; |
| 3021 |
} |
| 3022 |
|
| 3023 |
var translate = rtlTranslate ? swiper.translate : -swiper.translate; |
| 3024 |
|
| 3025 |
function normalize(val) { |
| 3026 |
if (val < 0) return -Math.floor(Math.abs(val)); |
| 3027 |
return Math.floor(val); |
| 3028 |
} |
| 3029 |
|
| 3030 |
var normalizedTranslate = normalize(translate); |
| 3031 |
var normalizedSnapGrid = snapGrid.map(function (val) { |
| 3032 |
return normalize(val); |
| 3033 |
}); |
| 3034 |
snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate)]; |
| 3035 |
var prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1]; |
| 3036 |
|
| 3037 |
if (typeof prevSnap === 'undefined' && params.cssMode) { |
| 3038 |
snapGrid.forEach(function (snap) { |
| 3039 |
if (!prevSnap && normalizedTranslate >= snap) prevSnap = snap; |
| 3040 |
}); |
| 3041 |
} |
| 3042 |
|
| 3043 |
var prevIndex; |
| 3044 |
|
| 3045 |
if (typeof prevSnap !== 'undefined') { |
| 3046 |
prevIndex = slidesGrid.indexOf(prevSnap); |
| 3047 |
if (prevIndex < 0) prevIndex = swiper.activeIndex - 1; |
| 3048 |
} |
| 3049 |
|
| 3050 |
return swiper.slideTo(prevIndex, speed, runCallbacks, internal); |
| 3051 |
} |
| 3052 |
|
| 3053 |
/* eslint no-unused-vars: "off" */ |
| 3054 |
function slideReset(speed, runCallbacks, internal) { |
| 3055 |
if (speed === void 0) { |
| 3056 |
speed = this.params.speed; |
| 3057 |
} |
| 3058 |
|
| 3059 |
if (runCallbacks === void 0) { |
| 3060 |
runCallbacks = true; |
| 3061 |
} |
| 3062 |
|
| 3063 |
var swiper = this; |
| 3064 |
return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal); |
| 3065 |
} |
| 3066 |
|
| 3067 |
/* eslint no-unused-vars: "off" */ |
| 3068 |
function slideToClosest(speed, runCallbacks, internal, threshold) { |
| 3069 |
if (speed === void 0) { |
| 3070 |
speed = this.params.speed; |
| 3071 |
} |
| 3072 |
|
| 3073 |
if (runCallbacks === void 0) { |
| 3074 |
runCallbacks = true; |
| 3075 |
} |
| 3076 |
|
| 3077 |
if (threshold === void 0) { |
| 3078 |
threshold = 0.5; |
| 3079 |
} |
| 3080 |
|
| 3081 |
var swiper = this; |
| 3082 |
var index = swiper.activeIndex; |
| 3083 |
var skip = Math.min(swiper.params.slidesPerGroupSkip, index); |
| 3084 |
var snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup); |
| 3085 |
var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate; |
| 3086 |
|
| 3087 |
if (translate >= swiper.snapGrid[snapIndex]) { |
| 3088 |
// The current translate is on or after the current snap index, so the choice |
| 3089 |
// is between the current index and the one after it. |
| 3090 |
var currentSnap = swiper.snapGrid[snapIndex]; |
| 3091 |
var nextSnap = swiper.snapGrid[snapIndex + 1]; |
| 3092 |
|
| 3093 |
if (translate - currentSnap > (nextSnap - currentSnap) * threshold) { |
| 3094 |
index += swiper.params.slidesPerGroup; |
| 3095 |
} |
| 3096 |
} else { |
| 3097 |
// The current translate is before the current snap index, so the choice |
| 3098 |
// is between the current index and the one before it. |
| 3099 |
var prevSnap = swiper.snapGrid[snapIndex - 1]; |
| 3100 |
var _currentSnap = swiper.snapGrid[snapIndex]; |
| 3101 |
|
| 3102 |
if (translate - prevSnap <= (_currentSnap - prevSnap) * threshold) { |
| 3103 |
index -= swiper.params.slidesPerGroup; |
| 3104 |
} |
| 3105 |
} |
| 3106 |
|
| 3107 |
index = Math.max(index, 0); |
| 3108 |
index = Math.min(index, swiper.slidesGrid.length - 1); |
| 3109 |
return swiper.slideTo(index, speed, runCallbacks, internal); |
| 3110 |
} |
| 3111 |
|
| 3112 |
function slideToClickedSlide() { |
| 3113 |
var swiper = this; |
| 3114 |
var params = swiper.params, |
| 3115 |
$wrapperEl = swiper.$wrapperEl; |
| 3116 |
var slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView; |
| 3117 |
var slideToIndex = swiper.clickedIndex; |
| 3118 |
var realIndex; |
| 3119 |
|
| 3120 |
if (params.loop) { |
| 3121 |
if (swiper.animating) return; |
| 3122 |
realIndex = parseInt($(swiper.clickedSlide).attr('data-swiper-slide-index'), 10); |
| 3123 |
|
| 3124 |
if (params.centeredSlides) { |
| 3125 |
if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2) { |
| 3126 |
swiper.loopFix(); |
| 3127 |
slideToIndex = $wrapperEl.children("." + params.slideClass + "[data-swiper-slide-index=\"" + realIndex + "\"]:not(." + params.slideDuplicateClass + ")").eq(0).index(); |
| 3128 |
nextTick(function () { |
| 3129 |
swiper.slideTo(slideToIndex); |
| 3130 |
}); |
| 3131 |
} else { |
| 3132 |
swiper.slideTo(slideToIndex); |
| 3133 |
} |
| 3134 |
} else if (slideToIndex > swiper.slides.length - slidesPerView) { |
| 3135 |
swiper.loopFix(); |
| 3136 |
slideToIndex = $wrapperEl.children("." + params.slideClass + "[data-swiper-slide-index=\"" + realIndex + "\"]:not(." + params.slideDuplicateClass + ")").eq(0).index(); |
| 3137 |
nextTick(function () { |
| 3138 |
swiper.slideTo(slideToIndex); |
| 3139 |
}); |
| 3140 |
} else { |
| 3141 |
swiper.slideTo(slideToIndex); |
| 3142 |
} |
| 3143 |
} else { |
| 3144 |
swiper.slideTo(slideToIndex); |
| 3145 |
} |
| 3146 |
} |
| 3147 |
|
| 3148 |
var slide = { |
| 3149 |
slideTo: slideTo, |
| 3150 |
slideToLoop: slideToLoop, |
| 3151 |
slideNext: slideNext, |
| 3152 |
slidePrev: slidePrev, |
| 3153 |
slideReset: slideReset, |
| 3154 |
slideToClosest: slideToClosest, |
| 3155 |
slideToClickedSlide: slideToClickedSlide |
| 3156 |
}; |
| 3157 |
|
| 3158 |
function loopCreate() { |
| 3159 |
var swiper = this; |
| 3160 |
var document = getDocument(); |
| 3161 |
var params = swiper.params, |
| 3162 |
$wrapperEl = swiper.$wrapperEl; // Remove duplicated slides |
| 3163 |
|
| 3164 |
$wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass).remove(); |
| 3165 |
var slides = $wrapperEl.children("." + params.slideClass); |
| 3166 |
|
| 3167 |
if (params.loopFillGroupWithBlank) { |
| 3168 |
var blankSlidesNum = params.slidesPerGroup - slides.length % params.slidesPerGroup; |
| 3169 |
|
| 3170 |
if (blankSlidesNum !== params.slidesPerGroup) { |
| 3171 |
for (var i = 0; i < blankSlidesNum; i += 1) { |
| 3172 |
var blankNode = $(document.createElement('div')).addClass(params.slideClass + " " + params.slideBlankClass); |
| 3173 |
$wrapperEl.append(blankNode); |
| 3174 |
} |
| 3175 |
|
| 3176 |
slides = $wrapperEl.children("." + params.slideClass); |
| 3177 |
} |
| 3178 |
} |
| 3179 |
|
| 3180 |
if (params.slidesPerView === 'auto' && !params.loopedSlides) params.loopedSlides = slides.length; |
| 3181 |
swiper.loopedSlides = Math.ceil(parseFloat(params.loopedSlides || params.slidesPerView, 10)); |
| 3182 |
swiper.loopedSlides += params.loopAdditionalSlides; |
| 3183 |
|
| 3184 |
if (swiper.loopedSlides > slides.length) { |
| 3185 |
swiper.loopedSlides = slides.length; |
| 3186 |
} |
| 3187 |
|
| 3188 |
var prependSlides = []; |
| 3189 |
var appendSlides = []; |
| 3190 |
slides.each(function (el, index) { |
| 3191 |
var slide = $(el); |
| 3192 |
|
| 3193 |
if (index < swiper.loopedSlides) { |
| 3194 |
appendSlides.push(el); |
| 3195 |
} |
| 3196 |
|
| 3197 |
if (index < slides.length && index >= slides.length - swiper.loopedSlides) { |
| 3198 |
prependSlides.push(el); |
| 3199 |
} |
| 3200 |
|
| 3201 |
slide.attr('data-swiper-slide-index', index); |
| 3202 |
}); |
| 3203 |
|
| 3204 |
for (var _i = 0; _i < appendSlides.length; _i += 1) { |
| 3205 |
$wrapperEl.append($(appendSlides[_i].cloneNode(true)).addClass(params.slideDuplicateClass)); |
| 3206 |
} |
| 3207 |
|
| 3208 |
for (var _i2 = prependSlides.length - 1; _i2 >= 0; _i2 -= 1) { |
| 3209 |
$wrapperEl.prepend($(prependSlides[_i2].cloneNode(true)).addClass(params.slideDuplicateClass)); |
| 3210 |
} |
| 3211 |
} |
| 3212 |
|
| 3213 |
function loopFix() { |
| 3214 |
var swiper = this; |
| 3215 |
swiper.emit('beforeLoopFix'); |
| 3216 |
var activeIndex = swiper.activeIndex, |
| 3217 |
slides = swiper.slides, |
| 3218 |
loopedSlides = swiper.loopedSlides, |
| 3219 |
allowSlidePrev = swiper.allowSlidePrev, |
| 3220 |
allowSlideNext = swiper.allowSlideNext, |
| 3221 |
snapGrid = swiper.snapGrid, |
| 3222 |
rtl = swiper.rtlTranslate; |
| 3223 |
var newIndex; |
| 3224 |
swiper.allowSlidePrev = true; |
| 3225 |
swiper.allowSlideNext = true; |
| 3226 |
var snapTranslate = -snapGrid[activeIndex]; |
| 3227 |
var diff = snapTranslate - swiper.getTranslate(); // Fix For Negative Oversliding |
| 3228 |
|
| 3229 |
if (activeIndex < loopedSlides) { |
| 3230 |
newIndex = slides.length - loopedSlides * 3 + activeIndex; |
| 3231 |
newIndex += loopedSlides; |
| 3232 |
var slideChanged = swiper.slideTo(newIndex, 0, false, true); |
| 3233 |
|
| 3234 |
if (slideChanged && diff !== 0) { |
| 3235 |
swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff); |
| 3236 |
} |
| 3237 |
} else if (activeIndex >= slides.length - loopedSlides) { |
| 3238 |
// Fix For Positive Oversliding |
| 3239 |
newIndex = -slides.length + activeIndex + loopedSlides; |
| 3240 |
newIndex += loopedSlides; |
| 3241 |
|
| 3242 |
var _slideChanged = swiper.slideTo(newIndex, 0, false, true); |
| 3243 |
|
| 3244 |
if (_slideChanged && diff !== 0) { |
| 3245 |
swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff); |
| 3246 |
} |
| 3247 |
} |
| 3248 |
|
| 3249 |
swiper.allowSlidePrev = allowSlidePrev; |
| 3250 |
swiper.allowSlideNext = allowSlideNext; |
| 3251 |
swiper.emit('loopFix'); |
| 3252 |
} |
| 3253 |
|
| 3254 |
function loopDestroy() { |
| 3255 |
var swiper = this; |
| 3256 |
var $wrapperEl = swiper.$wrapperEl, |
| 3257 |
params = swiper.params, |
| 3258 |
slides = swiper.slides; |
| 3259 |
$wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass + ",." + params.slideClass + "." + params.slideBlankClass).remove(); |
| 3260 |
slides.removeAttr('data-swiper-slide-index'); |
| 3261 |
} |
| 3262 |
|
| 3263 |
var loop = { |
| 3264 |
loopCreate: loopCreate, |
| 3265 |
loopFix: loopFix, |
| 3266 |
loopDestroy: loopDestroy |
| 3267 |
}; |
| 3268 |
|
| 3269 |
function setGrabCursor(moving) { |
| 3270 |
var swiper = this; |
| 3271 |
if (swiper.support.touch || !swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return; |
| 3272 |
var el = swiper.el; |
| 3273 |
el.style.cursor = 'move'; |
| 3274 |
el.style.cursor = moving ? '-webkit-grabbing' : '-webkit-grab'; |
| 3275 |
el.style.cursor = moving ? '-moz-grabbin' : '-moz-grab'; |
| 3276 |
el.style.cursor = moving ? 'grabbing' : 'grab'; |
| 3277 |
} |
| 3278 |
|
| 3279 |
function unsetGrabCursor() { |
| 3280 |
var swiper = this; |
| 3281 |
|
| 3282 |
if (swiper.support.touch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) { |
| 3283 |
return; |
| 3284 |
} |
| 3285 |
|
| 3286 |
swiper.el.style.cursor = ''; |
| 3287 |
} |
| 3288 |
|
| 3289 |
var grabCursor = { |
| 3290 |
setGrabCursor: setGrabCursor, |
| 3291 |
unsetGrabCursor: unsetGrabCursor |
| 3292 |
}; |
| 3293 |
|
| 3294 |
function appendSlide(slides) { |
| 3295 |
var swiper = this; |
| 3296 |
var $wrapperEl = swiper.$wrapperEl, |
| 3297 |
params = swiper.params; |
| 3298 |
|
| 3299 |
if (params.loop) { |
| 3300 |
swiper.loopDestroy(); |
| 3301 |
} |
| 3302 |
|
| 3303 |
if (typeof slides === 'object' && 'length' in slides) { |
| 3304 |
for (var i = 0; i < slides.length; i += 1) { |
| 3305 |
if (slides[i]) $wrapperEl.append(slides[i]); |
| 3306 |
} |
| 3307 |
} else { |
| 3308 |
$wrapperEl.append(slides); |
| 3309 |
} |
| 3310 |
|
| 3311 |
if (params.loop) { |
| 3312 |
swiper.loopCreate(); |
| 3313 |
} |
| 3314 |
|
| 3315 |
if (!(params.observer && swiper.support.observer)) { |
| 3316 |
swiper.update(); |
| 3317 |
} |
| 3318 |
} |
| 3319 |
|
| 3320 |
function prependSlide(slides) { |
| 3321 |
var swiper = this; |
| 3322 |
var params = swiper.params, |
| 3323 |
$wrapperEl = swiper.$wrapperEl, |
| 3324 |
activeIndex = swiper.activeIndex; |
| 3325 |
|
| 3326 |
if (params.loop) { |
| 3327 |
swiper.loopDestroy(); |
| 3328 |
} |
| 3329 |
|
| 3330 |
var newActiveIndex = activeIndex + 1; |
| 3331 |
|
| 3332 |
if (typeof slides === 'object' && 'length' in slides) { |
| 3333 |
for (var i = 0; i < slides.length; i += 1) { |
| 3334 |
if (slides[i]) $wrapperEl.prepend(slides[i]); |
| 3335 |
} |
| 3336 |
|
| 3337 |
newActiveIndex = activeIndex + slides.length; |
| 3338 |
} else { |
| 3339 |
$wrapperEl.prepend(slides); |
| 3340 |
} |
| 3341 |
|
| 3342 |
if (params.loop) { |
| 3343 |
swiper.loopCreate(); |
| 3344 |
} |
| 3345 |
|
| 3346 |
if (!(params.observer && swiper.support.observer)) { |
| 3347 |
swiper.update(); |
| 3348 |
} |
| 3349 |
|
| 3350 |
swiper.slideTo(newActiveIndex, 0, false); |
| 3351 |
} |
| 3352 |
|
| 3353 |
function addSlide(index, slides) { |
| 3354 |
var swiper = this; |
| 3355 |
var $wrapperEl = swiper.$wrapperEl, |
| 3356 |
params = swiper.params, |
| 3357 |
activeIndex = swiper.activeIndex; |
| 3358 |
var activeIndexBuffer = activeIndex; |
| 3359 |
|
| 3360 |
if (params.loop) { |
| 3361 |
activeIndexBuffer -= swiper.loopedSlides; |
| 3362 |
swiper.loopDestroy(); |
| 3363 |
swiper.slides = $wrapperEl.children("." + params.slideClass); |
| 3364 |
} |
| 3365 |
|
| 3366 |
var baseLength = swiper.slides.length; |
| 3367 |
|
| 3368 |
if (index <= 0) { |
| 3369 |
swiper.prependSlide(slides); |
| 3370 |
return; |
| 3371 |
} |
| 3372 |
|
| 3373 |
if (index >= baseLength) { |
| 3374 |
swiper.appendSlide(slides); |
| 3375 |
return; |
| 3376 |
} |
| 3377 |
|
| 3378 |
var newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer; |
| 3379 |
var slidesBuffer = []; |
| 3380 |
|
| 3381 |
for (var i = baseLength - 1; i >= index; i -= 1) { |
| 3382 |
var currentSlide = swiper.slides.eq(i); |
| 3383 |
currentSlide.remove(); |
| 3384 |
slidesBuffer.unshift(currentSlide); |
| 3385 |
} |
| 3386 |
|
| 3387 |
if (typeof slides === 'object' && 'length' in slides) { |
| 3388 |
for (var _i = 0; _i < slides.length; _i += 1) { |
| 3389 |
if (slides[_i]) $wrapperEl.append(slides[_i]); |
| 3390 |
} |
| 3391 |
|
| 3392 |
newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer; |
| 3393 |
} else { |
| 3394 |
$wrapperEl.append(slides); |
| 3395 |
} |
| 3396 |
|
| 3397 |
for (var _i2 = 0; _i2 < slidesBuffer.length; _i2 += 1) { |
| 3398 |
$wrapperEl.append(slidesBuffer[_i2]); |
| 3399 |
} |
| 3400 |
|
| 3401 |
if (params.loop) { |
| 3402 |
swiper.loopCreate(); |
| 3403 |
} |
| 3404 |
|
| 3405 |
if (!(params.observer && swiper.support.observer)) { |
| 3406 |
swiper.update(); |
| 3407 |
} |
| 3408 |
|
| 3409 |
if (params.loop) { |
| 3410 |
swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false); |
| 3411 |
} else { |
| 3412 |
swiper.slideTo(newActiveIndex, 0, false); |
| 3413 |
} |
| 3414 |
} |
| 3415 |
|
| 3416 |
function removeSlide(slidesIndexes) { |
| 3417 |
var swiper = this; |
| 3418 |
var params = swiper.params, |
| 3419 |
$wrapperEl = swiper.$wrapperEl, |
| 3420 |
activeIndex = swiper.activeIndex; |
| 3421 |
var activeIndexBuffer = activeIndex; |
| 3422 |
|
| 3423 |
if (params.loop) { |
| 3424 |
activeIndexBuffer -= swiper.loopedSlides; |
| 3425 |
swiper.loopDestroy(); |
| 3426 |
swiper.slides = $wrapperEl.children("." + params.slideClass); |
| 3427 |
} |
| 3428 |
|
| 3429 |
var newActiveIndex = activeIndexBuffer; |
| 3430 |
var indexToRemove; |
| 3431 |
|
| 3432 |
if (typeof slidesIndexes === 'object' && 'length' in slidesIndexes) { |
| 3433 |
for (var i = 0; i < slidesIndexes.length; i += 1) { |
| 3434 |
indexToRemove = slidesIndexes[i]; |
| 3435 |
if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove(); |
| 3436 |
if (indexToRemove < newActiveIndex) newActiveIndex -= 1; |
| 3437 |
} |
| 3438 |
|
| 3439 |
newActiveIndex = Math.max(newActiveIndex, 0); |
| 3440 |
} else { |
| 3441 |
indexToRemove = slidesIndexes; |
| 3442 |
if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove(); |
| 3443 |
if (indexToRemove < newActiveIndex) newActiveIndex -= 1; |
| 3444 |
newActiveIndex = Math.max(newActiveIndex, 0); |
| 3445 |
} |
| 3446 |
|
| 3447 |
if (params.loop) { |
| 3448 |
swiper.loopCreate(); |
| 3449 |
} |
| 3450 |
|
| 3451 |
if (!(params.observer && swiper.support.observer)) { |
| 3452 |
swiper.update(); |
| 3453 |
} |
| 3454 |
|
| 3455 |
if (params.loop) { |
| 3456 |
swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false); |
| 3457 |
} else { |
| 3458 |
swiper.slideTo(newActiveIndex, 0, false); |
| 3459 |
} |
| 3460 |
} |
| 3461 |
|
| 3462 |
function removeAllSlides() { |
| 3463 |
var swiper = this; |
| 3464 |
var slidesIndexes = []; |
| 3465 |
|
| 3466 |
for (var i = 0; i < swiper.slides.length; i += 1) { |
| 3467 |
slidesIndexes.push(i); |
| 3468 |
} |
| 3469 |
|
| 3470 |
swiper.removeSlide(slidesIndexes); |
| 3471 |
} |
| 3472 |
|
| 3473 |
var manipulation = { |
| 3474 |
appendSlide: appendSlide, |
| 3475 |
prependSlide: prependSlide, |
| 3476 |
addSlide: addSlide, |
| 3477 |
removeSlide: removeSlide, |
| 3478 |
removeAllSlides: removeAllSlides |
| 3479 |
}; |
| 3480 |
|
| 3481 |
function onTouchStart(event) { |
| 3482 |
var swiper = this; |
| 3483 |
var document = getDocument(); |
| 3484 |
var window = getWindow(); |
| 3485 |
var data = swiper.touchEventsData; |
| 3486 |
var params = swiper.params, |
| 3487 |
touches = swiper.touches; |
| 3488 |
|
| 3489 |
if (swiper.animating && params.preventInteractionOnTransition) { |
| 3490 |
return; |
| 3491 |
} |
| 3492 |
|
| 3493 |
var e = event; |
| 3494 |
if (e.originalEvent) e = e.originalEvent; |
| 3495 |
var $targetEl = $(e.target); |
| 3496 |
|
| 3497 |
if (params.touchEventsTarget === 'wrapper') { |
| 3498 |
if (!$targetEl.closest(swiper.wrapperEl).length) return; |
| 3499 |
} |
| 3500 |
|
| 3501 |
data.isTouchEvent = e.type === 'touchstart'; |
| 3502 |
if (!data.isTouchEvent && 'which' in e && e.which === 3) return; |
| 3503 |
if (!data.isTouchEvent && 'button' in e && e.button > 0) return; |
| 3504 |
if (data.isTouched && data.isMoved) return; // change target el for shadow root componenet |
| 3505 |
|
| 3506 |
var swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== ''; |
| 3507 |
|
| 3508 |
if (swipingClassHasValue && e.target && e.target.shadowRoot && event.path && event.path[0]) { |
| 3509 |
$targetEl = $(event.path[0]); |
| 3510 |
} |
| 3511 |
|
| 3512 |
if (params.noSwiping && $targetEl.closest(params.noSwipingSelector ? params.noSwipingSelector : "." + params.noSwipingClass)[0]) { |
| 3513 |
swiper.allowClick = true; |
| 3514 |
return; |
| 3515 |
} |
| 3516 |
|
| 3517 |
if (params.swipeHandler) { |
| 3518 |
if (!$targetEl.closest(params.swipeHandler)[0]) return; |
| 3519 |
} |
| 3520 |
|
| 3521 |
touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; |
| 3522 |
touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; |
| 3523 |
var startX = touches.currentX; |
| 3524 |
var startY = touches.currentY; // Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore |
| 3525 |
|
| 3526 |
var edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection; |
| 3527 |
var edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold; |
| 3528 |
|
| 3529 |
if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) { |
| 3530 |
if (edgeSwipeDetection === 'prevent') { |
| 3531 |
event.preventDefault(); |
| 3532 |
} else { |
| 3533 |
return; |
| 3534 |
} |
| 3535 |
} |
| 3536 |
|
| 3537 |
extend(data, { |
| 3538 |
isTouched: true, |
| 3539 |
isMoved: false, |
| 3540 |
allowTouchCallbacks: true, |
| 3541 |
isScrolling: undefined, |
| 3542 |
startMoving: undefined |
| 3543 |
}); |
| 3544 |
touches.startX = startX; |
| 3545 |
touches.startY = startY; |
| 3546 |
data.touchStartTime = now(); |
| 3547 |
swiper.allowClick = true; |
| 3548 |
swiper.updateSize(); |
| 3549 |
swiper.swipeDirection = undefined; |
| 3550 |
if (params.threshold > 0) data.allowThresholdMove = false; |
| 3551 |
|
| 3552 |
if (e.type !== 'touchstart') { |
| 3553 |
var preventDefault = true; |
| 3554 |
if ($targetEl.is(data.formElements)) preventDefault = false; |
| 3555 |
|
| 3556 |
if (document.activeElement && $(document.activeElement).is(data.formElements) && document.activeElement !== $targetEl[0]) { |
| 3557 |
document.activeElement.blur(); |
| 3558 |
} |
| 3559 |
|
| 3560 |
var shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault; |
| 3561 |
|
| 3562 |
if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !$targetEl[0].isContentEditable) { |
| 3563 |
e.preventDefault(); |
| 3564 |
} |
| 3565 |
} |
| 3566 |
|
| 3567 |
swiper.emit('touchStart', e); |
| 3568 |
} |
| 3569 |
|
| 3570 |
function onTouchMove(event) { |
| 3571 |
var document = getDocument(); |
| 3572 |
var swiper = this; |
| 3573 |
var data = swiper.touchEventsData; |
| 3574 |
var params = swiper.params, |
| 3575 |
touches = swiper.touches, |
| 3576 |
rtl = swiper.rtlTranslate; |
| 3577 |
var e = event; |
| 3578 |
if (e.originalEvent) e = e.originalEvent; |
| 3579 |
|
| 3580 |
if (!data.isTouched) { |
| 3581 |
if (data.startMoving && data.isScrolling) { |
| 3582 |
swiper.emit('touchMoveOpposite', e); |
| 3583 |
} |
| 3584 |
|
| 3585 |
return; |
| 3586 |
} |
| 3587 |
|
| 3588 |
if (data.isTouchEvent && e.type !== 'touchmove') return; |
| 3589 |
var targetTouch = e.type === 'touchmove' && e.targetTouches && (e.targetTouches[0] || e.changedTouches[0]); |
| 3590 |
var pageX = e.type === 'touchmove' ? targetTouch.pageX : e.pageX; |
| 3591 |
var pageY = e.type === 'touchmove' ? targetTouch.pageY : e.pageY; |
| 3592 |
|
| 3593 |
if (e.preventedByNestedSwiper) { |
| 3594 |
touches.startX = pageX; |
| 3595 |
touches.startY = pageY; |
| 3596 |
return; |
| 3597 |
} |
| 3598 |
|
| 3599 |
if (!swiper.allowTouchMove) { |
| 3600 |
// isMoved = true; |
| 3601 |
swiper.allowClick = false; |
| 3602 |
|
| 3603 |
if (data.isTouched) { |
| 3604 |
extend(touches, { |
| 3605 |
startX: pageX, |
| 3606 |
startY: pageY, |
| 3607 |
currentX: pageX, |
| 3608 |
currentY: pageY |
| 3609 |
}); |
| 3610 |
data.touchStartTime = now(); |
| 3611 |
} |
| 3612 |
|
| 3613 |
return; |
| 3614 |
} |
| 3615 |
|
| 3616 |
if (data.isTouchEvent && params.touchReleaseOnEdges && !params.loop) { |
| 3617 |
if (swiper.isVertical()) { |
| 3618 |
// Vertical |
| 3619 |
if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) { |
| 3620 |
data.isTouched = false; |
| 3621 |
data.isMoved = false; |
| 3622 |
return; |
| 3623 |
} |
| 3624 |
} else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate()) { |
| 3625 |
return; |
| 3626 |
} |
| 3627 |
} |
| 3628 |
|
| 3629 |
if (data.isTouchEvent && document.activeElement) { |
| 3630 |
if (e.target === document.activeElement && $(e.target).is(data.formElements)) { |
| 3631 |
data.isMoved = true; |
| 3632 |
swiper.allowClick = false; |
| 3633 |
return; |
| 3634 |
} |
| 3635 |
} |
| 3636 |
|
| 3637 |
if (data.allowTouchCallbacks) { |
| 3638 |
swiper.emit('touchMove', e); |
| 3639 |
} |
| 3640 |
|
| 3641 |
if (e.targetTouches && e.targetTouches.length > 1) return; |
| 3642 |
touches.currentX = pageX; |
| 3643 |
touches.currentY = pageY; |
| 3644 |
var diffX = touches.currentX - touches.startX; |
| 3645 |
var diffY = touches.currentY - touches.startY; |
| 3646 |
if (swiper.params.threshold && Math.sqrt(Math.pow(diffX, 2) + Math.pow(diffY, 2)) < swiper.params.threshold) return; |
| 3647 |
|
| 3648 |
if (typeof data.isScrolling === 'undefined') { |
| 3649 |
var touchAngle; |
| 3650 |
|
| 3651 |
if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) { |
| 3652 |
data.isScrolling = false; |
| 3653 |
} else { |
| 3654 |
// eslint-disable-next-line |
| 3655 |
if (diffX * diffX + diffY * diffY >= 25) { |
| 3656 |
touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI; |
| 3657 |
data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle; |
| 3658 |
} |
| 3659 |
} |
| 3660 |
} |
| 3661 |
|
| 3662 |
if (data.isScrolling) { |
| 3663 |
swiper.emit('touchMoveOpposite', e); |
| 3664 |
} |
| 3665 |
|
| 3666 |
if (typeof data.startMoving === 'undefined') { |
| 3667 |
if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) { |
| 3668 |
data.startMoving = true; |
| 3669 |
} |
| 3670 |
} |
| 3671 |
|
| 3672 |
if (data.isScrolling) { |
| 3673 |
data.isTouched = false; |
| 3674 |
return; |
| 3675 |
} |
| 3676 |
|
| 3677 |
if (!data.startMoving) { |
| 3678 |
return; |
| 3679 |
} |
| 3680 |
|
| 3681 |
swiper.allowClick = false; |
| 3682 |
|
| 3683 |
if (!params.cssMode && e.cancelable) { |
| 3684 |
e.preventDefault(); |
| 3685 |
} |
| 3686 |
|
| 3687 |
if (params.touchMoveStopPropagation && !params.nested) { |
| 3688 |
e.stopPropagation(); |
| 3689 |
} |
| 3690 |
|
| 3691 |
if (!data.isMoved) { |
| 3692 |
if (params.loop) { |
| 3693 |
swiper.loopFix(); |
| 3694 |
} |
| 3695 |
|
| 3696 |
data.startTranslate = swiper.getTranslate(); |
| 3697 |
swiper.setTransition(0); |
| 3698 |
|
| 3699 |
if (swiper.animating) { |
| 3700 |
swiper.$wrapperEl.trigger('webkitTransitionEnd transitionend'); |
| 3701 |
} |
| 3702 |
|
| 3703 |
data.allowMomentumBounce = false; // Grab Cursor |
| 3704 |
|
| 3705 |
if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { |
| 3706 |
swiper.setGrabCursor(true); |
| 3707 |
} |
| 3708 |
|
| 3709 |
swiper.emit('sliderFirstMove', e); |
| 3710 |
} |
| 3711 |
|
| 3712 |
swiper.emit('sliderMove', e); |
| 3713 |
data.isMoved = true; |
| 3714 |
var diff = swiper.isHorizontal() ? diffX : diffY; |
| 3715 |
touches.diff = diff; |
| 3716 |
diff *= params.touchRatio; |
| 3717 |
if (rtl) diff = -diff; |
| 3718 |
swiper.swipeDirection = diff > 0 ? 'prev' : 'next'; |
| 3719 |
data.currentTranslate = diff + data.startTranslate; |
| 3720 |
var disableParentSwiper = true; |
| 3721 |
var resistanceRatio = params.resistanceRatio; |
| 3722 |
|
| 3723 |
if (params.touchReleaseOnEdges) { |
| 3724 |
resistanceRatio = 0; |
| 3725 |
} |
| 3726 |
|
| 3727 |
if (diff > 0 && data.currentTranslate > swiper.minTranslate()) { |
| 3728 |
disableParentSwiper = false; |
| 3729 |
if (params.resistance) data.currentTranslate = swiper.minTranslate() - 1 + Math.pow(-swiper.minTranslate() + data.startTranslate + diff, resistanceRatio); |
| 3730 |
} else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) { |
| 3731 |
disableParentSwiper = false; |
| 3732 |
if (params.resistance) data.currentTranslate = swiper.maxTranslate() + 1 - Math.pow(swiper.maxTranslate() - data.startTranslate - diff, resistanceRatio); |
| 3733 |
} |
| 3734 |
|
| 3735 |
if (disableParentSwiper) { |
| 3736 |
e.preventedByNestedSwiper = true; |
| 3737 |
} // Directions locks |
| 3738 |
|
| 3739 |
|
| 3740 |
if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) { |
| 3741 |
data.currentTranslate = data.startTranslate; |
| 3742 |
} |
| 3743 |
|
| 3744 |
if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) { |
| 3745 |
data.currentTranslate = data.startTranslate; |
| 3746 |
} |
| 3747 |
|
| 3748 |
if (!swiper.allowSlidePrev && !swiper.allowSlideNext) { |
| 3749 |
data.currentTranslate = data.startTranslate; |
| 3750 |
} // Threshold |
| 3751 |
|
| 3752 |
|
| 3753 |
if (params.threshold > 0) { |
| 3754 |
if (Math.abs(diff) > params.threshold || data.allowThresholdMove) { |
| 3755 |
if (!data.allowThresholdMove) { |
| 3756 |
data.allowThresholdMove = true; |
| 3757 |
touches.startX = touches.currentX; |
| 3758 |
touches.startY = touches.currentY; |
| 3759 |
data.currentTranslate = data.startTranslate; |
| 3760 |
touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY; |
| 3761 |
return; |
| 3762 |
} |
| 3763 |
} else { |
| 3764 |
data.currentTranslate = data.startTranslate; |
| 3765 |
return; |
| 3766 |
} |
| 3767 |
} |
| 3768 |
|
| 3769 |
if (!params.followFinger || params.cssMode) return; // Update active index in free mode |
| 3770 |
|
| 3771 |
if (params.freeMode || params.watchSlidesProgress || params.watchSlidesVisibility) { |
| 3772 |
swiper.updateActiveIndex(); |
| 3773 |
swiper.updateSlidesClasses(); |
| 3774 |
} |
| 3775 |
|
| 3776 |
if (params.freeMode) { |
| 3777 |
// Velocity |
| 3778 |
if (data.velocities.length === 0) { |
| 3779 |
data.velocities.push({ |
| 3780 |
position: touches[swiper.isHorizontal() ? 'startX' : 'startY'], |
| 3781 |
time: data.touchStartTime |
| 3782 |
}); |
| 3783 |
} |
| 3784 |
|
| 3785 |
data.velocities.push({ |
| 3786 |
position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'], |
| 3787 |
time: now() |
| 3788 |
}); |
| 3789 |
} // Update progress |
| 3790 |
|
| 3791 |
|
| 3792 |
swiper.updateProgress(data.currentTranslate); // Update translate |
| 3793 |
|
| 3794 |
swiper.setTranslate(data.currentTranslate); |
| 3795 |
} |
| 3796 |
|
| 3797 |
function onTouchEnd(event) { |
| 3798 |
var swiper = this; |
| 3799 |
var data = swiper.touchEventsData; |
| 3800 |
var params = swiper.params, |
| 3801 |
touches = swiper.touches, |
| 3802 |
rtl = swiper.rtlTranslate, |
| 3803 |
$wrapperEl = swiper.$wrapperEl, |
| 3804 |
slidesGrid = swiper.slidesGrid, |
| 3805 |
snapGrid = swiper.snapGrid; |
| 3806 |
var e = event; |
| 3807 |
if (e.originalEvent) e = e.originalEvent; |
| 3808 |
|
| 3809 |
if (data.allowTouchCallbacks) { |
| 3810 |
swiper.emit('touchEnd', e); |
| 3811 |
} |
| 3812 |
|
| 3813 |
data.allowTouchCallbacks = false; |
| 3814 |
|
| 3815 |
if (!data.isTouched) { |
| 3816 |
if (data.isMoved && params.grabCursor) { |
| 3817 |
swiper.setGrabCursor(false); |
| 3818 |
} |
| 3819 |
|
| 3820 |
data.isMoved = false; |
| 3821 |
data.startMoving = false; |
| 3822 |
return; |
| 3823 |
} // Return Grab Cursor |
| 3824 |
|
| 3825 |
|
| 3826 |
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { |
| 3827 |
swiper.setGrabCursor(false); |
| 3828 |
} // Time diff |
| 3829 |
|
| 3830 |
|
| 3831 |
var touchEndTime = now(); |
| 3832 |
var timeDiff = touchEndTime - data.touchStartTime; // Tap, doubleTap, Click |
| 3833 |
|
| 3834 |
if (swiper.allowClick) { |
| 3835 |
swiper.updateClickedSlide(e); |
| 3836 |
swiper.emit('tap click', e); |
| 3837 |
|
| 3838 |
if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) { |
| 3839 |
swiper.emit('doubleTap doubleClick', e); |
| 3840 |
} |
| 3841 |
} |
| 3842 |
|
| 3843 |
data.lastClickTime = now(); |
| 3844 |
nextTick(function () { |
| 3845 |
if (!swiper.destroyed) swiper.allowClick = true; |
| 3846 |
}); |
| 3847 |
|
| 3848 |
if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) { |
| 3849 |
data.isTouched = false; |
| 3850 |
data.isMoved = false; |
| 3851 |
data.startMoving = false; |
| 3852 |
return; |
| 3853 |
} |
| 3854 |
|
| 3855 |
data.isTouched = false; |
| 3856 |
data.isMoved = false; |
| 3857 |
data.startMoving = false; |
| 3858 |
var currentPos; |
| 3859 |
|
| 3860 |
if (params.followFinger) { |
| 3861 |
currentPos = rtl ? swiper.translate : -swiper.translate; |
| 3862 |
} else { |
| 3863 |
currentPos = -data.currentTranslate; |
| 3864 |
} |
| 3865 |
|
| 3866 |
if (params.cssMode) { |
| 3867 |
return; |
| 3868 |
} |
| 3869 |
|
| 3870 |
if (params.freeMode) { |
| 3871 |
if (currentPos < -swiper.minTranslate()) { |
| 3872 |
swiper.slideTo(swiper.activeIndex); |
| 3873 |
return; |
| 3874 |
} |
| 3875 |
|
| 3876 |
if (currentPos > -swiper.maxTranslate()) { |
| 3877 |
if (swiper.slides.length < snapGrid.length) { |
| 3878 |
swiper.slideTo(snapGrid.length - 1); |
| 3879 |
} else { |
| 3880 |
swiper.slideTo(swiper.slides.length - 1); |
| 3881 |
} |
| 3882 |
|
| 3883 |
return; |
| 3884 |
} |
| 3885 |
|
| 3886 |
if (params.freeModeMomentum) { |
| 3887 |
if (data.velocities.length > 1) { |
| 3888 |
var lastMoveEvent = data.velocities.pop(); |
| 3889 |
var velocityEvent = data.velocities.pop(); |
| 3890 |
var distance = lastMoveEvent.position - velocityEvent.position; |
| 3891 |
var time = lastMoveEvent.time - velocityEvent.time; |
| 3892 |
swiper.velocity = distance / time; |
| 3893 |
swiper.velocity /= 2; |
| 3894 |
|
| 3895 |
if (Math.abs(swiper.velocity) < params.freeModeMinimumVelocity) { |
| 3896 |
swiper.velocity = 0; |
| 3897 |
} // this implies that the user stopped moving a finger then released. |
| 3898 |
// There would be no events with distance zero, so the last event is stale. |
| 3899 |
|
| 3900 |
|
| 3901 |
if (time > 150 || now() - lastMoveEvent.time > 300) { |
| 3902 |
swiper.velocity = 0; |
| 3903 |
} |
| 3904 |
} else { |
| 3905 |
swiper.velocity = 0; |
| 3906 |
} |
| 3907 |
|
| 3908 |
swiper.velocity *= params.freeModeMomentumVelocityRatio; |
| 3909 |
data.velocities.length = 0; |
| 3910 |
var momentumDuration = 1000 * params.freeModeMomentumRatio; |
| 3911 |
var momentumDistance = swiper.velocity * momentumDuration; |
| 3912 |
var newPosition = swiper.translate + momentumDistance; |
| 3913 |
if (rtl) newPosition = -newPosition; |
| 3914 |
var doBounce = false; |
| 3915 |
var afterBouncePosition; |
| 3916 |
var bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeModeMomentumBounceRatio; |
| 3917 |
var needsLoopFix; |
| 3918 |
|
| 3919 |
if (newPosition < swiper.maxTranslate()) { |
| 3920 |
if (params.freeModeMomentumBounce) { |
| 3921 |
if (newPosition + swiper.maxTranslate() < -bounceAmount) { |
| 3922 |
newPosition = swiper.maxTranslate() - bounceAmount; |
| 3923 |
} |
| 3924 |
|
| 3925 |
afterBouncePosition = swiper.maxTranslate(); |
| 3926 |
doBounce = true; |
| 3927 |
data.allowMomentumBounce = true; |
| 3928 |
} else { |
| 3929 |
newPosition = swiper.maxTranslate(); |
| 3930 |
} |
| 3931 |
|
| 3932 |
if (params.loop && params.centeredSlides) needsLoopFix = true; |
| 3933 |
} else if (newPosition > swiper.minTranslate()) { |
| 3934 |
if (params.freeModeMomentumBounce) { |
| 3935 |
if (newPosition - swiper.minTranslate() > bounceAmount) { |
| 3936 |
newPosition = swiper.minTranslate() + bounceAmount; |
| 3937 |
} |
| 3938 |
|
| 3939 |
afterBouncePosition = swiper.minTranslate(); |
| 3940 |
doBounce = true; |
| 3941 |
data.allowMomentumBounce = true; |
| 3942 |
} else { |
| 3943 |
newPosition = swiper.minTranslate(); |
| 3944 |
} |
| 3945 |
|
| 3946 |
if (params.loop && params.centeredSlides) needsLoopFix = true; |
| 3947 |
} else if (params.freeModeSticky) { |
| 3948 |
var nextSlide; |
| 3949 |
|
| 3950 |
for (var j = 0; j < snapGrid.length; j += 1) { |
| 3951 |
if (snapGrid[j] > -newPosition) { |
| 3952 |
nextSlide = j; |
| 3953 |
break; |
| 3954 |
} |
| 3955 |
} |
| 3956 |
|
| 3957 |
if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') { |
| 3958 |
newPosition = snapGrid[nextSlide]; |
| 3959 |
} else { |
| 3960 |
newPosition = snapGrid[nextSlide - 1]; |
| 3961 |
} |
| 3962 |
|
| 3963 |
newPosition = -newPosition; |
| 3964 |
} |
| 3965 |
|
| 3966 |
if (needsLoopFix) { |
| 3967 |
swiper.once('transitionEnd', function () { |
| 3968 |
swiper.loopFix(); |
| 3969 |
}); |
| 3970 |
} // Fix duration |
| 3971 |
|
| 3972 |
|
| 3973 |
if (swiper.velocity !== 0) { |
| 3974 |
if (rtl) { |
| 3975 |
momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity); |
| 3976 |
} else { |
| 3977 |
momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity); |
| 3978 |
} |
| 3979 |
|
| 3980 |
if (params.freeModeSticky) { |
| 3981 |
// If freeModeSticky is active and the user ends a swipe with a slow-velocity |
| 3982 |
// event, then durations can be 20+ seconds to slide one (or zero!) slides. |
| 3983 |
// It's easy to see this when simulating touch with mouse events. To fix this, |
| 3984 |
// limit single-slide swipes to the default slide duration. This also has the |
| 3985 |
// nice side effect of matching slide speed if the user stopped moving before |
| 3986 |
// lifting finger or mouse vs. moving slowly before lifting the finger/mouse. |
| 3987 |
// For faster swipes, also apply limits (albeit higher ones). |
| 3988 |
var moveDistance = Math.abs((rtl ? -newPosition : newPosition) - swiper.translate); |
| 3989 |
var currentSlideSize = swiper.slidesSizesGrid[swiper.activeIndex]; |
| 3990 |
|
| 3991 |
if (moveDistance < currentSlideSize) { |
| 3992 |
momentumDuration = params.speed; |
| 3993 |
} else if (moveDistance < 2 * currentSlideSize) { |
| 3994 |
momentumDuration = params.speed * 1.5; |
| 3995 |
} else { |
| 3996 |
momentumDuration = params.speed * 2.5; |
| 3997 |
} |
| 3998 |
} |
| 3999 |
} else if (params.freeModeSticky) { |
| 4000 |
swiper.slideToClosest(); |
| 4001 |
return; |
| 4002 |
} |
| 4003 |
|
| 4004 |
if (params.freeModeMomentumBounce && doBounce) { |
| 4005 |
swiper.updateProgress(afterBouncePosition); |
| 4006 |
swiper.setTransition(momentumDuration); |
| 4007 |
swiper.setTranslate(newPosition); |
| 4008 |
swiper.transitionStart(true, swiper.swipeDirection); |
| 4009 |
swiper.animating = true; |
| 4010 |
$wrapperEl.transitionEnd(function () { |
| 4011 |
if (!swiper || swiper.destroyed || !data.allowMomentumBounce) return; |
| 4012 |
swiper.emit('momentumBounce'); |
| 4013 |
swiper.setTransition(params.speed); |
| 4014 |
setTimeout(function () { |
| 4015 |
swiper.setTranslate(afterBouncePosition); |
| 4016 |
$wrapperEl.transitionEnd(function () { |
| 4017 |
if (!swiper || swiper.destroyed) return; |
| 4018 |
swiper.transitionEnd(); |
| 4019 |
}); |
| 4020 |
}, 0); |
| 4021 |
}); |
| 4022 |
} else if (swiper.velocity) { |
| 4023 |
swiper.updateProgress(newPosition); |
| 4024 |
swiper.setTransition(momentumDuration); |
| 4025 |
swiper.setTranslate(newPosition); |
| 4026 |
swiper.transitionStart(true, swiper.swipeDirection); |
| 4027 |
|
| 4028 |
if (!swiper.animating) { |
| 4029 |
swiper.animating = true; |
| 4030 |
$wrapperEl.transitionEnd(function () { |
| 4031 |
if (!swiper || swiper.destroyed) return; |
| 4032 |
swiper.transitionEnd(); |
| 4033 |
}); |
| 4034 |
} |
| 4035 |
} else { |
| 4036 |
swiper.emit('_freeModeNoMomentumRelease'); |
| 4037 |
swiper.updateProgress(newPosition); |
| 4038 |
} |
| 4039 |
|
| 4040 |
swiper.updateActiveIndex(); |
| 4041 |
swiper.updateSlidesClasses(); |
| 4042 |
} else if (params.freeModeSticky) { |
| 4043 |
swiper.slideToClosest(); |
| 4044 |
return; |
| 4045 |
} else if (params.freeMode) { |
| 4046 |
swiper.emit('_freeModeNoMomentumRelease'); |
| 4047 |
} |
| 4048 |
|
| 4049 |
if (!params.freeModeMomentum || timeDiff >= params.longSwipesMs) { |
| 4050 |
swiper.updateProgress(); |
| 4051 |
swiper.updateActiveIndex(); |
| 4052 |
swiper.updateSlidesClasses(); |
| 4053 |
} |
| 4054 |
|
| 4055 |
return; |
| 4056 |
} // Find current slide |
| 4057 |
|
| 4058 |
|
| 4059 |
var stopIndex = 0; |
| 4060 |
var groupSize = swiper.slidesSizesGrid[0]; |
| 4061 |
|
| 4062 |
for (var i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) { |
| 4063 |
var _increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup; |
| 4064 |
|
| 4065 |
if (typeof slidesGrid[i + _increment] !== 'undefined') { |
| 4066 |
if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + _increment]) { |
| 4067 |
stopIndex = i; |
| 4068 |
groupSize = slidesGrid[i + _increment] - slidesGrid[i]; |
| 4069 |
} |
| 4070 |
} else if (currentPos >= slidesGrid[i]) { |
| 4071 |
stopIndex = i; |
| 4072 |
groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2]; |
| 4073 |
} |
| 4074 |
} // Find current slide size |
| 4075 |
|
| 4076 |
|
| 4077 |
var ratio = (currentPos - slidesGrid[stopIndex]) / groupSize; |
| 4078 |
var increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup; |
| 4079 |
|
| 4080 |
if (timeDiff > params.longSwipesMs) { |
| 4081 |
// Long touches |
| 4082 |
if (!params.longSwipes) { |
| 4083 |
swiper.slideTo(swiper.activeIndex); |
| 4084 |
return; |
| 4085 |
} |
| 4086 |
|
| 4087 |
if (swiper.swipeDirection === 'next') { |
| 4088 |
if (ratio >= params.longSwipesRatio) swiper.slideTo(stopIndex + increment);else swiper.slideTo(stopIndex); |
| 4089 |
} |
| 4090 |
|
| 4091 |
if (swiper.swipeDirection === 'prev') { |
| 4092 |
if (ratio > 1 - params.longSwipesRatio) swiper.slideTo(stopIndex + increment);else swiper.slideTo(stopIndex); |
| 4093 |
} |
| 4094 |
} else { |
| 4095 |
// Short swipes |
| 4096 |
if (!params.shortSwipes) { |
| 4097 |
swiper.slideTo(swiper.activeIndex); |
| 4098 |
return; |
| 4099 |
} |
| 4100 |
|
| 4101 |
var isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl); |
| 4102 |
|
| 4103 |
if (!isNavButtonTarget) { |
| 4104 |
if (swiper.swipeDirection === 'next') { |
| 4105 |
swiper.slideTo(stopIndex + increment); |
| 4106 |
} |
| 4107 |
|
| 4108 |
if (swiper.swipeDirection === 'prev') { |
| 4109 |
swiper.slideTo(stopIndex); |
| 4110 |
} |
| 4111 |
} else if (e.target === swiper.navigation.nextEl) { |
| 4112 |
swiper.slideTo(stopIndex + increment); |
| 4113 |
} else { |
| 4114 |
swiper.slideTo(stopIndex); |
| 4115 |
} |
| 4116 |
} |
| 4117 |
} |
| 4118 |
|
| 4119 |
function onResize() { |
| 4120 |
var swiper = this; |
| 4121 |
var params = swiper.params, |
| 4122 |
el = swiper.el; |
| 4123 |
if (el && el.offsetWidth === 0) return; // Breakpoints |
| 4124 |
|
| 4125 |
if (params.breakpoints) { |
| 4126 |
swiper.setBreakpoint(); |
| 4127 |
} // Save locks |
| 4128 |
|
| 4129 |
|
| 4130 |
var allowSlideNext = swiper.allowSlideNext, |
| 4131 |
allowSlidePrev = swiper.allowSlidePrev, |
| 4132 |
snapGrid = swiper.snapGrid; // Disable locks on resize |
| 4133 |
|
| 4134 |
swiper.allowSlideNext = true; |
| 4135 |
swiper.allowSlidePrev = true; |
| 4136 |
swiper.updateSize(); |
| 4137 |
swiper.updateSlides(); |
| 4138 |
swiper.updateSlidesClasses(); |
| 4139 |
|
| 4140 |
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) { |
| 4141 |
swiper.slideTo(swiper.slides.length - 1, 0, false, true); |
| 4142 |
} else { |
| 4143 |
swiper.slideTo(swiper.activeIndex, 0, false, true); |
| 4144 |
} |
| 4145 |
|
| 4146 |
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) { |
| 4147 |
swiper.autoplay.run(); |
| 4148 |
} // Return locks after resize |
| 4149 |
|
| 4150 |
|
| 4151 |
swiper.allowSlidePrev = allowSlidePrev; |
| 4152 |
swiper.allowSlideNext = allowSlideNext; |
| 4153 |
|
| 4154 |
if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) { |
| 4155 |
swiper.checkOverflow(); |
| 4156 |
} |
| 4157 |
} |
| 4158 |
|
| 4159 |
function onClick(e) { |
| 4160 |
var swiper = this; |
| 4161 |
|
| 4162 |
if (!swiper.allowClick) { |
| 4163 |
if (swiper.params.preventClicks) e.preventDefault(); |
| 4164 |
|
| 4165 |
if (swiper.params.preventClicksPropagation && swiper.animating) { |
| 4166 |
e.stopPropagation(); |
| 4167 |
e.stopImmediatePropagation(); |
| 4168 |
} |
| 4169 |
} |
| 4170 |
} |
| 4171 |
|
| 4172 |
function onScroll() { |
| 4173 |
var swiper = this; |
| 4174 |
var wrapperEl = swiper.wrapperEl, |
| 4175 |
rtlTranslate = swiper.rtlTranslate; |
| 4176 |
swiper.previousTranslate = swiper.translate; |
| 4177 |
|
| 4178 |
if (swiper.isHorizontal()) { |
| 4179 |
if (rtlTranslate) { |
| 4180 |
swiper.translate = wrapperEl.scrollWidth - wrapperEl.offsetWidth - wrapperEl.scrollLeft; |
| 4181 |
} else { |
| 4182 |
swiper.translate = -wrapperEl.scrollLeft; |
| 4183 |
} |
| 4184 |
} else { |
| 4185 |
swiper.translate = -wrapperEl.scrollTop; |
| 4186 |
} // eslint-disable-next-line |
| 4187 |
|
| 4188 |
|
| 4189 |
if (swiper.translate === -0) swiper.translate = 0; |
| 4190 |
swiper.updateActiveIndex(); |
| 4191 |
swiper.updateSlidesClasses(); |
| 4192 |
var newProgress; |
| 4193 |
var translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); |
| 4194 |
|
| 4195 |
if (translatesDiff === 0) { |
| 4196 |
newProgress = 0; |
| 4197 |
} else { |
| 4198 |
newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff; |
| 4199 |
} |
| 4200 |
|
| 4201 |
if (newProgress !== swiper.progress) { |
| 4202 |
swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate); |
| 4203 |
} |
| 4204 |
|
| 4205 |
swiper.emit('setTranslate', swiper.translate, false); |
| 4206 |
} |
| 4207 |
|
| 4208 |
var dummyEventAttached = false; |
| 4209 |
|
| 4210 |
function dummyEventListener() {} |
| 4211 |
|
| 4212 |
function attachEvents() { |
| 4213 |
var swiper = this; |
| 4214 |
var document = getDocument(); |
| 4215 |
var params = swiper.params, |
| 4216 |
touchEvents = swiper.touchEvents, |
| 4217 |
el = swiper.el, |
| 4218 |
wrapperEl = swiper.wrapperEl, |
| 4219 |
device = swiper.device, |
| 4220 |
support = swiper.support; |
| 4221 |
swiper.onTouchStart = onTouchStart.bind(swiper); |
| 4222 |
swiper.onTouchMove = onTouchMove.bind(swiper); |
| 4223 |
swiper.onTouchEnd = onTouchEnd.bind(swiper); |
| 4224 |
|
| 4225 |
if (params.cssMode) { |
| 4226 |
swiper.onScroll = onScroll.bind(swiper); |
| 4227 |
} |
| 4228 |
|
| 4229 |
swiper.onClick = onClick.bind(swiper); |
| 4230 |
var capture = !!params.nested; // Touch Events |
| 4231 |
|
| 4232 |
if (!support.touch && support.pointerEvents) { |
| 4233 |
el.addEventListener(touchEvents.start, swiper.onTouchStart, false); |
| 4234 |
document.addEventListener(touchEvents.move, swiper.onTouchMove, capture); |
| 4235 |
document.addEventListener(touchEvents.end, swiper.onTouchEnd, false); |
| 4236 |
} else { |
| 4237 |
if (support.touch) { |
| 4238 |
var passiveListener = touchEvents.start === 'touchstart' && support.passiveListener && params.passiveListeners ? { |
| 4239 |
passive: true, |
| 4240 |
capture: false |
| 4241 |
} : false; |
| 4242 |
el.addEventListener(touchEvents.start, swiper.onTouchStart, passiveListener); |
| 4243 |
el.addEventListener(touchEvents.move, swiper.onTouchMove, support.passiveListener ? { |
| 4244 |
passive: false, |
| 4245 |
capture: capture |
| 4246 |
} : capture); |
| 4247 |
el.addEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener); |
| 4248 |
|
| 4249 |
if (touchEvents.cancel) { |
| 4250 |
el.addEventListener(touchEvents.cancel, swiper.onTouchEnd, passiveListener); |
| 4251 |
} |
| 4252 |
|
| 4253 |
if (!dummyEventAttached) { |
| 4254 |
document.addEventListener('touchstart', dummyEventListener); |
| 4255 |
dummyEventAttached = true; |
| 4256 |
} |
| 4257 |
} |
| 4258 |
|
| 4259 |
if (params.simulateTouch && !device.ios && !device.android || params.simulateTouch && !support.touch && device.ios) { |
| 4260 |
el.addEventListener('mousedown', swiper.onTouchStart, false); |
| 4261 |
document.addEventListener('mousemove', swiper.onTouchMove, capture); |
| 4262 |
document.addEventListener('mouseup', swiper.onTouchEnd, false); |
| 4263 |
} |
| 4264 |
} // Prevent Links Clicks |
| 4265 |
|
| 4266 |
|
| 4267 |
if (params.preventClicks || params.preventClicksPropagation) { |
| 4268 |
el.addEventListener('click', swiper.onClick, true); |
| 4269 |
} |
| 4270 |
|
| 4271 |
if (params.cssMode) { |
| 4272 |
wrapperEl.addEventListener('scroll', swiper.onScroll); |
| 4273 |
} // Resize handler |
| 4274 |
|
| 4275 |
|
| 4276 |
if (params.updateOnWindowResize) { |
| 4277 |
swiper.on(device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true); |
| 4278 |
} else { |
| 4279 |
swiper.on('observerUpdate', onResize, true); |
| 4280 |
} |
| 4281 |
} |
| 4282 |
|
| 4283 |
function detachEvents() { |
| 4284 |
var swiper = this; |
| 4285 |
var document = getDocument(); |
| 4286 |
var params = swiper.params, |
| 4287 |
touchEvents = swiper.touchEvents, |
| 4288 |
el = swiper.el, |
| 4289 |
wrapperEl = swiper.wrapperEl, |
| 4290 |
device = swiper.device, |
| 4291 |
support = swiper.support; |
| 4292 |
var capture = !!params.nested; // Touch Events |
| 4293 |
|
| 4294 |
if (!support.touch && support.pointerEvents) { |
| 4295 |
el.removeEventListener(touchEvents.start, swiper.onTouchStart, false); |
| 4296 |
document.removeEventListener(touchEvents.move, swiper.onTouchMove, capture); |
| 4297 |
document.removeEventListener(touchEvents.end, swiper.onTouchEnd, false); |
| 4298 |
} else { |
| 4299 |
if (support.touch) { |
| 4300 |
var passiveListener = touchEvents.start === 'onTouchStart' && support.passiveListener && params.passiveListeners ? { |
| 4301 |
passive: true, |
| 4302 |
capture: false |
| 4303 |
} : false; |
| 4304 |
el.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener); |
| 4305 |
el.removeEventListener(touchEvents.move, swiper.onTouchMove, capture); |
| 4306 |
el.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener); |
| 4307 |
|
| 4308 |
if (touchEvents.cancel) { |
| 4309 |
el.removeEventListener(touchEvents.cancel, swiper.onTouchEnd, passiveListener); |
| 4310 |
} |
| 4311 |
} |
| 4312 |
|
| 4313 |
if (params.simulateTouch && !device.ios && !device.android || params.simulateTouch && !support.touch && device.ios) { |
| 4314 |
el.removeEventListener('mousedown', swiper.onTouchStart, false); |
| 4315 |
document.removeEventListener('mousemove', swiper.onTouchMove, capture); |
| 4316 |
document.removeEventListener('mouseup', swiper.onTouchEnd, false); |
| 4317 |
} |
| 4318 |
} // Prevent Links Clicks |
| 4319 |
|
| 4320 |
|
| 4321 |
if (params.preventClicks || params.preventClicksPropagation) { |
| 4322 |
el.removeEventListener('click', swiper.onClick, true); |
| 4323 |
} |
| 4324 |
|
| 4325 |
if (params.cssMode) { |
| 4326 |
wrapperEl.removeEventListener('scroll', swiper.onScroll); |
| 4327 |
} // Resize handler |
| 4328 |
|
| 4329 |
|
| 4330 |
swiper.off(device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize); |
| 4331 |
} |
| 4332 |
|
| 4333 |
var events = { |
| 4334 |
attachEvents: attachEvents, |
| 4335 |
detachEvents: detachEvents |
| 4336 |
}; |
| 4337 |
|
| 4338 |
function setBreakpoint() { |
| 4339 |
var swiper = this; |
| 4340 |
var activeIndex = swiper.activeIndex, |
| 4341 |
initialized = swiper.initialized, |
| 4342 |
_swiper$loopedSlides = swiper.loopedSlides, |
| 4343 |
loopedSlides = _swiper$loopedSlides === void 0 ? 0 : _swiper$loopedSlides, |
| 4344 |
params = swiper.params, |
| 4345 |
$el = swiper.$el; |
| 4346 |
var breakpoints = params.breakpoints; |
| 4347 |
if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return; // Get breakpoint for window width and update parameters |
| 4348 |
|
| 4349 |
var breakpoint = swiper.getBreakpoint(breakpoints, swiper.params.breakpointsBase, swiper.el); |
| 4350 |
|
| 4351 |
if (breakpoint && swiper.currentBreakpoint !== breakpoint) { |
| 4352 |
var breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined; |
| 4353 |
|
| 4354 |
if (breakpointOnlyParams) { |
| 4355 |
['slidesPerView', 'spaceBetween', 'slidesPerGroup', 'slidesPerGroupSkip', 'slidesPerColumn'].forEach(function (param) { |
| 4356 |
var paramValue = breakpointOnlyParams[param]; |
| 4357 |
if (typeof paramValue === 'undefined') return; |
| 4358 |
|
| 4359 |
if (param === 'slidesPerView' && (paramValue === 'AUTO' || paramValue === 'auto')) { |
| 4360 |
breakpointOnlyParams[param] = 'auto'; |
| 4361 |
} else if (param === 'slidesPerView') { |
| 4362 |
breakpointOnlyParams[param] = parseFloat(paramValue); |
| 4363 |
} else { |
| 4364 |
breakpointOnlyParams[param] = parseInt(paramValue, 10); |
| 4365 |
} |
| 4366 |
}); |
| 4367 |
} |
| 4368 |
|
| 4369 |
var breakpointParams = breakpointOnlyParams || swiper.originalParams; |
| 4370 |
var wasMultiRow = params.slidesPerColumn > 1; |
| 4371 |
var isMultiRow = breakpointParams.slidesPerColumn > 1; |
| 4372 |
|
| 4373 |
if (wasMultiRow && !isMultiRow) { |
| 4374 |
$el.removeClass(params.containerModifierClass + "multirow " + params.containerModifierClass + "multirow-column"); |
| 4375 |
swiper.emitContainerClasses(); |
| 4376 |
} else if (!wasMultiRow && isMultiRow) { |
| 4377 |
$el.addClass(params.containerModifierClass + "multirow"); |
| 4378 |
|
| 4379 |
if (breakpointParams.slidesPerColumnFill === 'column') { |
| 4380 |
$el.addClass(params.containerModifierClass + "multirow-column"); |
| 4381 |
} |
| 4382 |
|
| 4383 |
swiper.emitContainerClasses(); |
| 4384 |
} |
| 4385 |
|
| 4386 |
var directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction; |
| 4387 |
var needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged); |
| 4388 |
|
| 4389 |
if (directionChanged && initialized) { |
| 4390 |
swiper.changeDirection(); |
| 4391 |
} |
| 4392 |
|
| 4393 |
extend(swiper.params, breakpointParams); |
| 4394 |
extend(swiper, { |
| 4395 |
allowTouchMove: swiper.params.allowTouchMove, |
| 4396 |
allowSlideNext: swiper.params.allowSlideNext, |
| 4397 |
allowSlidePrev: swiper.params.allowSlidePrev |
| 4398 |
}); |
| 4399 |
swiper.currentBreakpoint = breakpoint; |
| 4400 |
swiper.emit('_beforeBreakpoint', breakpointParams); |
| 4401 |
|
| 4402 |
if (needsReLoop && initialized) { |
| 4403 |
swiper.loopDestroy(); |
| 4404 |
swiper.loopCreate(); |
| 4405 |
swiper.updateSlides(); |
| 4406 |
swiper.slideTo(activeIndex - loopedSlides + swiper.loopedSlides, 0, false); |
| 4407 |
} |
| 4408 |
|
| 4409 |
swiper.emit('breakpoint', breakpointParams); |
| 4410 |
} |
| 4411 |
} |
| 4412 |
|
| 4413 |
function getBreakpoint(breakpoints, base, containerEl) { |
| 4414 |
if (base === void 0) { |
| 4415 |
base = 'window'; |
| 4416 |
} |
| 4417 |
|
| 4418 |
if (!breakpoints || base === 'container' && !containerEl) return undefined; |
| 4419 |
var breakpoint = false; |
| 4420 |
var window = getWindow(); |
| 4421 |
var currentWidth = base === 'window' ? window.innerWidth : containerEl.clientWidth; |
| 4422 |
var currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight; |
| 4423 |
var points = Object.keys(breakpoints).map(function (point) { |
| 4424 |
if (typeof point === 'string' && point.indexOf('@') === 0) { |
| 4425 |
var minRatio = parseFloat(point.substr(1)); |
| 4426 |
var value = currentHeight * minRatio; |
| 4427 |
return { |
| 4428 |
value: value, |
| 4429 |
point: point |
| 4430 |
}; |
| 4431 |
} |
| 4432 |
|
| 4433 |
return { |
| 4434 |
value: point, |
| 4435 |
point: point |
| 4436 |
}; |
| 4437 |
}); |
| 4438 |
points.sort(function (a, b) { |
| 4439 |
return parseInt(a.value, 10) - parseInt(b.value, 10); |
| 4440 |
}); |
| 4441 |
|
| 4442 |
for (var i = 0; i < points.length; i += 1) { |
| 4443 |
var _points$i = points[i], |
| 4444 |
point = _points$i.point, |
| 4445 |
value = _points$i.value; |
| 4446 |
|
| 4447 |
if (value <= currentWidth) { |
| 4448 |
breakpoint = point; |
| 4449 |
} |
| 4450 |
} |
| 4451 |
|
| 4452 |
return breakpoint || 'max'; |
| 4453 |
} |
| 4454 |
|
| 4455 |
var breakpoints = { |
| 4456 |
setBreakpoint: setBreakpoint, |
| 4457 |
getBreakpoint: getBreakpoint |
| 4458 |
}; |
| 4459 |
|
| 4460 |
function prepareClasses(entries, prefix) { |
| 4461 |
var resultClasses = []; |
| 4462 |
entries.forEach(function (item) { |
| 4463 |
if (typeof item === 'object') { |
| 4464 |
Object.keys(item).forEach(function (classNames) { |
| 4465 |
if (item[classNames]) { |
| 4466 |
resultClasses.push(prefix + classNames); |
| 4467 |
} |
| 4468 |
}); |
| 4469 |
} else if (typeof item === 'string') { |
| 4470 |
resultClasses.push(prefix + item); |
| 4471 |
} |
| 4472 |
}); |
| 4473 |
return resultClasses; |
| 4474 |
} |
| 4475 |
|
| 4476 |
function addClasses() { |
| 4477 |
var swiper = this; |
| 4478 |
var classNames = swiper.classNames, |
| 4479 |
params = swiper.params, |
| 4480 |
rtl = swiper.rtl, |
| 4481 |
$el = swiper.$el, |
| 4482 |
device = swiper.device, |
| 4483 |
support = swiper.support; // prettier-ignore |
| 4484 |
|
| 4485 |
var suffixes = prepareClasses(['initialized', params.direction, { |
| 4486 |
'pointer-events': support.pointerEvents && !support.touch |
| 4487 |
}, { |
| 4488 |
'free-mode': params.freeMode |
| 4489 |
}, { |
| 4490 |
'autoheight': params.autoHeight |
| 4491 |
}, { |
| 4492 |
'rtl': rtl |
| 4493 |
}, { |
| 4494 |
'multirow': params.slidesPerColumn > 1 |
| 4495 |
}, { |
| 4496 |
'multirow-column': params.slidesPerColumn > 1 && params.slidesPerColumnFill === 'column' |
| 4497 |
}, { |
| 4498 |
'android': device.android |
| 4499 |
}, { |
| 4500 |
'ios': device.ios |
| 4501 |
}, { |
| 4502 |
'css-mode': params.cssMode |
| 4503 |
}], params.containerModifierClass); |
| 4504 |
classNames.push.apply(classNames, suffixes); |
| 4505 |
$el.addClass([].concat(classNames).join(' ')); |
| 4506 |
swiper.emitContainerClasses(); |
| 4507 |
} |
| 4508 |
|
| 4509 |
function removeClasses() { |
| 4510 |
var swiper = this; |
| 4511 |
var $el = swiper.$el, |
| 4512 |
classNames = swiper.classNames; |
| 4513 |
$el.removeClass(classNames.join(' ')); |
| 4514 |
swiper.emitContainerClasses(); |
| 4515 |
} |
| 4516 |
|
| 4517 |
var classes = { |
| 4518 |
addClasses: addClasses, |
| 4519 |
removeClasses: removeClasses |
| 4520 |
}; |
| 4521 |
|
| 4522 |
function loadImage(imageEl, src, srcset, sizes, checkForComplete, callback) { |
| 4523 |
var window = getWindow(); |
| 4524 |
var image; |
| 4525 |
|
| 4526 |
function onReady() { |
| 4527 |
if (callback) callback(); |
| 4528 |
} |
| 4529 |
|
| 4530 |
var isPicture = $(imageEl).parent('picture')[0]; |
| 4531 |
|
| 4532 |
if (!isPicture && (!imageEl.complete || !checkForComplete)) { |
| 4533 |
if (src) { |
| 4534 |
image = new window.Image(); |
| 4535 |
image.onload = onReady; |
| 4536 |
image.onerror = onReady; |
| 4537 |
|
| 4538 |
if (sizes) { |
| 4539 |
image.sizes = sizes; |
| 4540 |
} |
| 4541 |
|
| 4542 |
if (srcset) { |
| 4543 |
image.srcset = srcset; |
| 4544 |
} |
| 4545 |
|
| 4546 |
if (src) { |
| 4547 |
image.src = src; |
| 4548 |
} |
| 4549 |
} else { |
| 4550 |
onReady(); |
| 4551 |
} |
| 4552 |
} else { |
| 4553 |
// image already loaded... |
| 4554 |
onReady(); |
| 4555 |
} |
| 4556 |
} |
| 4557 |
|
| 4558 |
function preloadImages() { |
| 4559 |
var swiper = this; |
| 4560 |
swiper.imagesToLoad = swiper.$el.find('img'); |
| 4561 |
|
| 4562 |
function onReady() { |
| 4563 |
if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper.destroyed) return; |
| 4564 |
if (swiper.imagesLoaded !== undefined) swiper.imagesLoaded += 1; |
| 4565 |
|
| 4566 |
if (swiper.imagesLoaded === swiper.imagesToLoad.length) { |
| 4567 |
if (swiper.params.updateOnImagesReady) swiper.update(); |
| 4568 |
swiper.emit('imagesReady'); |
| 4569 |
} |
| 4570 |
} |
| 4571 |
|
| 4572 |
for (var i = 0; i < swiper.imagesToLoad.length; i += 1) { |
| 4573 |
var imageEl = swiper.imagesToLoad[i]; |
| 4574 |
swiper.loadImage(imageEl, imageEl.currentSrc || imageEl.getAttribute('src'), imageEl.srcset || imageEl.getAttribute('srcset'), imageEl.sizes || imageEl.getAttribute('sizes'), true, onReady); |
| 4575 |
} |
| 4576 |
} |
| 4577 |
|
| 4578 |
var images = { |
| 4579 |
loadImage: loadImage, |
| 4580 |
preloadImages: preloadImages |
| 4581 |
}; |
| 4582 |
|
| 4583 |
function checkOverflow() { |
| 4584 |
var swiper = this; |
| 4585 |
var params = swiper.params; |
| 4586 |
var wasLocked = swiper.isLocked; |
| 4587 |
var lastSlidePosition = swiper.slides.length > 0 && params.slidesOffsetBefore + params.spaceBetween * (swiper.slides.length - 1) + swiper.slides[0].offsetWidth * swiper.slides.length; |
| 4588 |
|
| 4589 |
if (params.slidesOffsetBefore && params.slidesOffsetAfter && lastSlidePosition) { |
| 4590 |
swiper.isLocked = lastSlidePosition <= swiper.size; |
| 4591 |
} else { |
| 4592 |
swiper.isLocked = swiper.snapGrid.length === 1; |
| 4593 |
} |
| 4594 |
|
| 4595 |
swiper.allowSlideNext = !swiper.isLocked; |
| 4596 |
swiper.allowSlidePrev = !swiper.isLocked; // events |
| 4597 |
|
| 4598 |
if (wasLocked !== swiper.isLocked) swiper.emit(swiper.isLocked ? 'lock' : 'unlock'); |
| 4599 |
|
| 4600 |
if (wasLocked && wasLocked !== swiper.isLocked) { |
| 4601 |
swiper.isEnd = false; |
| 4602 |
if (swiper.navigation) swiper.navigation.update(); |
| 4603 |
} |
| 4604 |
} |
| 4605 |
|
| 4606 |
var checkOverflow$1 = { |
| 4607 |
checkOverflow: checkOverflow |
| 4608 |
}; |
| 4609 |
|
| 4610 |
var defaults = { |
| 4611 |
init: true, |
| 4612 |
direction: 'horizontal', |
| 4613 |
touchEventsTarget: 'container', |
| 4614 |
initialSlide: 0, |
| 4615 |
speed: 300, |
| 4616 |
cssMode: false, |
| 4617 |
updateOnWindowResize: true, |
| 4618 |
resizeObserver: false, |
| 4619 |
nested: false, |
| 4620 |
// Overrides |
| 4621 |
width: null, |
| 4622 |
height: null, |
| 4623 |
// |
| 4624 |
preventInteractionOnTransition: false, |
| 4625 |
// ssr |
| 4626 |
userAgent: null, |
| 4627 |
url: null, |
| 4628 |
// To support iOS's swipe-to-go-back gesture (when being used in-app). |
| 4629 |
edgeSwipeDetection: false, |
| 4630 |
edgeSwipeThreshold: 20, |
| 4631 |
// Free mode |
| 4632 |
freeMode: false, |
| 4633 |
freeModeMomentum: true, |
| 4634 |
freeModeMomentumRatio: 1, |
| 4635 |
freeModeMomentumBounce: true, |
| 4636 |
freeModeMomentumBounceRatio: 1, |
| 4637 |
freeModeMomentumVelocityRatio: 1, |
| 4638 |
freeModeSticky: false, |
| 4639 |
freeModeMinimumVelocity: 0.02, |
| 4640 |
// Autoheight |
| 4641 |
autoHeight: false, |
| 4642 |
// Set wrapper width |
| 4643 |
setWrapperSize: false, |
| 4644 |
// Virtual Translate |
| 4645 |
virtualTranslate: false, |
| 4646 |
// Effects |
| 4647 |
effect: 'slide', |
| 4648 |
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip' |
| 4649 |
// Breakpoints |
| 4650 |
breakpoints: undefined, |
| 4651 |
breakpointsBase: 'window', |
| 4652 |
// Slides grid |
| 4653 |
spaceBetween: 0, |
| 4654 |
slidesPerView: 1, |
| 4655 |
slidesPerColumn: 1, |
| 4656 |
slidesPerColumnFill: 'column', |
| 4657 |
slidesPerGroup: 1, |
| 4658 |
slidesPerGroupSkip: 0, |
| 4659 |
centeredSlides: false, |
| 4660 |
centeredSlidesBounds: false, |
| 4661 |
slidesOffsetBefore: 0, |
| 4662 |
// in px |
| 4663 |
slidesOffsetAfter: 0, |
| 4664 |
// in px |
| 4665 |
normalizeSlideIndex: true, |
| 4666 |
centerInsufficientSlides: false, |
| 4667 |
// Disable swiper and hide navigation when container not overflow |
| 4668 |
watchOverflow: false, |
| 4669 |
// Round length |
| 4670 |
roundLengths: false, |
| 4671 |
// Touches |
| 4672 |
touchRatio: 1, |
| 4673 |
touchAngle: 45, |
| 4674 |
simulateTouch: true, |
| 4675 |
shortSwipes: true, |
| 4676 |
longSwipes: true, |
| 4677 |
longSwipesRatio: 0.5, |
| 4678 |
longSwipesMs: 300, |
| 4679 |
followFinger: true, |
| 4680 |
allowTouchMove: true, |
| 4681 |
threshold: 0, |
| 4682 |
touchMoveStopPropagation: false, |
| 4683 |
touchStartPreventDefault: true, |
| 4684 |
touchStartForcePreventDefault: false, |
| 4685 |
touchReleaseOnEdges: false, |
| 4686 |
// Unique Navigation Elements |
| 4687 |
uniqueNavElements: true, |
| 4688 |
// Resistance |
| 4689 |
resistance: true, |
| 4690 |
resistanceRatio: 0.85, |
| 4691 |
// Progress |
| 4692 |
watchSlidesProgress: false, |
| 4693 |
watchSlidesVisibility: false, |
| 4694 |
// Cursor |
| 4695 |
grabCursor: false, |
| 4696 |
// Clicks |
| 4697 |
preventClicks: true, |
| 4698 |
preventClicksPropagation: true, |
| 4699 |
slideToClickedSlide: false, |
| 4700 |
// Images |
| 4701 |
preloadImages: true, |
| 4702 |
updateOnImagesReady: true, |
| 4703 |
// loop |
| 4704 |
loop: false, |
| 4705 |
loopAdditionalSlides: 0, |
| 4706 |
loopedSlides: null, |
| 4707 |
loopFillGroupWithBlank: false, |
| 4708 |
loopPreventsSlide: true, |
| 4709 |
// Swiping/no swiping |
| 4710 |
allowSlidePrev: true, |
| 4711 |
allowSlideNext: true, |
| 4712 |
swipeHandler: null, |
| 4713 |
// '.swipe-handler', |
| 4714 |
noSwiping: true, |
| 4715 |
noSwipingClass: 'swiper-no-swiping', |
| 4716 |
noSwipingSelector: null, |
| 4717 |
// Passive Listeners |
| 4718 |
passiveListeners: true, |
| 4719 |
// NS |
| 4720 |
containerModifierClass: 'swiper-container-', |
| 4721 |
// NEW |
| 4722 |
slideClass: 'swiper-slide', |
| 4723 |
slideBlankClass: 'swiper-slide-invisible-blank', |
| 4724 |
slideActiveClass: 'swiper-slide-active', |
| 4725 |
slideDuplicateActiveClass: 'swiper-slide-duplicate-active', |
| 4726 |
slideVisibleClass: 'swiper-slide-visible', |
| 4727 |
slideDuplicateClass: 'swiper-slide-duplicate', |
| 4728 |
slideNextClass: 'swiper-slide-next', |
| 4729 |
slideDuplicateNextClass: 'swiper-slide-duplicate-next', |
| 4730 |
slidePrevClass: 'swiper-slide-prev', |
| 4731 |
slideDuplicatePrevClass: 'swiper-slide-duplicate-prev', |
| 4732 |
wrapperClass: 'swiper-wrapper', |
| 4733 |
// Callbacks |
| 4734 |
runCallbacksOnInit: true, |
| 4735 |
// Internals |
| 4736 |
_emitClasses: false |
| 4737 |
}; |
| 4738 |
|
| 4739 |
var prototypes = { |
| 4740 |
modular: modular, |
| 4741 |
eventsEmitter: eventsEmitter, |
| 4742 |
update: update, |
| 4743 |
translate: translate, |
| 4744 |
transition: transition, |
| 4745 |
slide: slide, |
| 4746 |
loop: loop, |
| 4747 |
grabCursor: grabCursor, |
| 4748 |
manipulation: manipulation, |
| 4749 |
events: events, |
| 4750 |
breakpoints: breakpoints, |
| 4751 |
checkOverflow: checkOverflow$1, |
| 4752 |
classes: classes, |
| 4753 |
images: images |
| 4754 |
}; |
| 4755 |
var extendedDefaults = {}; |
| 4756 |
|
| 4757 |
var Swiper = /*#__PURE__*/function () { |
| 4758 |
function Swiper() { |
| 4759 |
var el; |
| 4760 |
var params; |
| 4761 |
|
| 4762 |
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
| 4763 |
args[_key] = arguments[_key]; |
| 4764 |
} |
| 4765 |
|
| 4766 |
if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object') { |
| 4767 |
params = args[0]; |
| 4768 |
} else { |
| 4769 |
el = args[0]; |
| 4770 |
params = args[1]; |
| 4771 |
} |
| 4772 |
|
| 4773 |
if (!params) params = {}; |
| 4774 |
params = extend({}, params); |
| 4775 |
if (el && !params.el) params.el = el; |
| 4776 |
|
| 4777 |
if (params.el && $(params.el).length > 1) { |
| 4778 |
var swipers = []; |
| 4779 |
$(params.el).each(function (containerEl) { |
| 4780 |
var newParams = extend({}, params, { |
| 4781 |
el: containerEl |
| 4782 |
}); |
| 4783 |
swipers.push(new Swiper(newParams)); |
| 4784 |
}); |
| 4785 |
return swipers; |
| 4786 |
} // Swiper Instance |
| 4787 |
|
| 4788 |
|
| 4789 |
var swiper = this; |
| 4790 |
swiper.__swiper__ = true; |
| 4791 |
swiper.support = getSupport(); |
| 4792 |
swiper.device = getDevice({ |
| 4793 |
userAgent: params.userAgent |
| 4794 |
}); |
| 4795 |
swiper.browser = getBrowser(); |
| 4796 |
swiper.eventsListeners = {}; |
| 4797 |
swiper.eventsAnyListeners = []; |
| 4798 |
|
| 4799 |
if (typeof swiper.modules === 'undefined') { |
| 4800 |
swiper.modules = {}; |
| 4801 |
} |
| 4802 |
|
| 4803 |
Object.keys(swiper.modules).forEach(function (moduleName) { |
| 4804 |
var module = swiper.modules[moduleName]; |
| 4805 |
|
| 4806 |
if (module.params) { |
| 4807 |
var moduleParamName = Object.keys(module.params)[0]; |
| 4808 |
var moduleParams = module.params[moduleParamName]; |
| 4809 |
if (typeof moduleParams !== 'object' || moduleParams === null) return; |
| 4810 |
if (!(moduleParamName in params && 'enabled' in moduleParams)) return; |
| 4811 |
|
| 4812 |
if (params[moduleParamName] === true) { |
| 4813 |
params[moduleParamName] = { |
| 4814 |
enabled: true |
| 4815 |
}; |
| 4816 |
} |
| 4817 |
|
| 4818 |
if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) { |
| 4819 |
params[moduleParamName].enabled = true; |
| 4820 |
} |
| 4821 |
|
| 4822 |
if (!params[moduleParamName]) params[moduleParamName] = { |
| 4823 |
enabled: false |
| 4824 |
}; |
| 4825 |
} |
| 4826 |
}); // Extend defaults with modules params |
| 4827 |
|
| 4828 |
var swiperParams = extend({}, defaults); |
| 4829 |
swiper.useParams(swiperParams); // Extend defaults with passed params |
| 4830 |
|
| 4831 |
swiper.params = extend({}, swiperParams, extendedDefaults, params); |
| 4832 |
swiper.originalParams = extend({}, swiper.params); |
| 4833 |
swiper.passedParams = extend({}, params); // add event listeners |
| 4834 |
|
| 4835 |
if (swiper.params && swiper.params.on) { |
| 4836 |
Object.keys(swiper.params.on).forEach(function (eventName) { |
| 4837 |
swiper.on(eventName, swiper.params.on[eventName]); |
| 4838 |
}); |
| 4839 |
} |
| 4840 |
|
| 4841 |
if (swiper.params && swiper.params.onAny) { |
| 4842 |
swiper.onAny(swiper.params.onAny); |
| 4843 |
} // Save Dom lib |
| 4844 |
|
| 4845 |
|
| 4846 |
swiper.$ = $; // Extend Swiper |
| 4847 |
|
| 4848 |
extend(swiper, { |
| 4849 |
el: el, |
| 4850 |
// Classes |
| 4851 |
classNames: [], |
| 4852 |
// Slides |
| 4853 |
slides: $(), |
| 4854 |
slidesGrid: [], |
| 4855 |
snapGrid: [], |
| 4856 |
slidesSizesGrid: [], |
| 4857 |
// isDirection |
| 4858 |
isHorizontal: function isHorizontal() { |
| 4859 |
return swiper.params.direction === 'horizontal'; |
| 4860 |
}, |
| 4861 |
isVertical: function isVertical() { |
| 4862 |
return swiper.params.direction === 'vertical'; |
| 4863 |
}, |
| 4864 |
// Indexes |
| 4865 |
activeIndex: 0, |
| 4866 |
realIndex: 0, |
| 4867 |
// |
| 4868 |
isBeginning: true, |
| 4869 |
isEnd: false, |
| 4870 |
// Props |
| 4871 |
translate: 0, |
| 4872 |
previousTranslate: 0, |
| 4873 |
progress: 0, |
| 4874 |
velocity: 0, |
| 4875 |
animating: false, |
| 4876 |
// Locks |
| 4877 |
allowSlideNext: swiper.params.allowSlideNext, |
| 4878 |
allowSlidePrev: swiper.params.allowSlidePrev, |
| 4879 |
// Touch Events |
| 4880 |
touchEvents: function touchEvents() { |
| 4881 |
var touch = ['touchstart', 'touchmove', 'touchend', 'touchcancel']; |
| 4882 |
var desktop = ['mousedown', 'mousemove', 'mouseup']; |
| 4883 |
|
| 4884 |
if (swiper.support.pointerEvents) { |
| 4885 |
desktop = ['pointerdown', 'pointermove', 'pointerup']; |
| 4886 |
} |
| 4887 |
|
| 4888 |
swiper.touchEventsTouch = { |
| 4889 |
start: touch[0], |
| 4890 |
move: touch[1], |
| 4891 |
end: touch[2], |
| 4892 |
cancel: touch[3] |
| 4893 |
}; |
| 4894 |
swiper.touchEventsDesktop = { |
| 4895 |
start: desktop[0], |
| 4896 |
move: desktop[1], |
| 4897 |
end: desktop[2] |
| 4898 |
}; |
| 4899 |
return swiper.support.touch || !swiper.params.simulateTouch ? swiper.touchEventsTouch : swiper.touchEventsDesktop; |
| 4900 |
}(), |
| 4901 |
touchEventsData: { |
| 4902 |
isTouched: undefined, |
| 4903 |
isMoved: undefined, |
| 4904 |
allowTouchCallbacks: undefined, |
| 4905 |
touchStartTime: undefined, |
| 4906 |
isScrolling: undefined, |
| 4907 |
currentTranslate: undefined, |
| 4908 |
startTranslate: undefined, |
| 4909 |
allowThresholdMove: undefined, |
| 4910 |
// Form elements to match |
| 4911 |
formElements: 'input, select, option, textarea, button, video, label', |
| 4912 |
// Last click time |
| 4913 |
lastClickTime: now(), |
| 4914 |
clickTimeout: undefined, |
| 4915 |
// Velocities |
| 4916 |
velocities: [], |
| 4917 |
allowMomentumBounce: undefined, |
| 4918 |
isTouchEvent: undefined, |
| 4919 |
startMoving: undefined |
| 4920 |
}, |
| 4921 |
// Clicks |
| 4922 |
allowClick: true, |
| 4923 |
// Touches |
| 4924 |
allowTouchMove: swiper.params.allowTouchMove, |
| 4925 |
touches: { |
| 4926 |
startX: 0, |
| 4927 |
startY: 0, |
| 4928 |
currentX: 0, |
| 4929 |
currentY: 0, |
| 4930 |
diff: 0 |
| 4931 |
}, |
| 4932 |
// Images |
| 4933 |
imagesToLoad: [], |
| 4934 |
imagesLoaded: 0 |
| 4935 |
}); // Install Modules |
| 4936 |
|
| 4937 |
swiper.useModules(); |
| 4938 |
swiper.emit('_swiper'); // Init |
| 4939 |
|
| 4940 |
if (swiper.params.init) { |
| 4941 |
swiper.init(); |
| 4942 |
} // Return app instance |
| 4943 |
|
| 4944 |
|
| 4945 |
return swiper; |
| 4946 |
} |
| 4947 |
|
| 4948 |
var _proto = Swiper.prototype; |
| 4949 |
|
| 4950 |
_proto.setProgress = function setProgress(progress, speed) { |
| 4951 |
var swiper = this; |
| 4952 |
progress = Math.min(Math.max(progress, 0), 1); |
| 4953 |
var min = swiper.minTranslate(); |
| 4954 |
var max = swiper.maxTranslate(); |
| 4955 |
var current = (max - min) * progress + min; |
| 4956 |
swiper.translateTo(current, typeof speed === 'undefined' ? 0 : speed); |
| 4957 |
swiper.updateActiveIndex(); |
| 4958 |
swiper.updateSlidesClasses(); |
| 4959 |
}; |
| 4960 |
|
| 4961 |
_proto.emitContainerClasses = function emitContainerClasses() { |
| 4962 |
var swiper = this; |
| 4963 |
if (!swiper.params._emitClasses || !swiper.el) return; |
| 4964 |
var classes = swiper.el.className.split(' ').filter(function (className) { |
| 4965 |
return className.indexOf('swiper-container') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0; |
| 4966 |
}); |
| 4967 |
swiper.emit('_containerClasses', classes.join(' ')); |
| 4968 |
}; |
| 4969 |
|
| 4970 |
_proto.getSlideClasses = function getSlideClasses(slideEl) { |
| 4971 |
var swiper = this; |
| 4972 |
return slideEl.className.split(' ').filter(function (className) { |
| 4973 |
return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0; |
| 4974 |
}).join(' '); |
| 4975 |
}; |
| 4976 |
|
| 4977 |
_proto.emitSlidesClasses = function emitSlidesClasses() { |
| 4978 |
var swiper = this; |
| 4979 |
if (!swiper.params._emitClasses || !swiper.el) return; |
| 4980 |
var updates = []; |
| 4981 |
swiper.slides.each(function (slideEl) { |
| 4982 |
var classNames = swiper.getSlideClasses(slideEl); |
| 4983 |
updates.push({ |
| 4984 |
slideEl: slideEl, |
| 4985 |
classNames: classNames |
| 4986 |
}); |
| 4987 |
swiper.emit('_slideClass', slideEl, classNames); |
| 4988 |
}); |
| 4989 |
swiper.emit('_slideClasses', updates); |
| 4990 |
}; |
| 4991 |
|
| 4992 |
_proto.slidesPerViewDynamic = function slidesPerViewDynamic() { |
| 4993 |
var swiper = this; |
| 4994 |
var params = swiper.params, |
| 4995 |
slides = swiper.slides, |
| 4996 |
slidesGrid = swiper.slidesGrid, |
| 4997 |
swiperSize = swiper.size, |
| 4998 |
activeIndex = swiper.activeIndex; |
| 4999 |
var spv = 1; |
| 5000 |
|
| 5001 |
if (params.centeredSlides) { |
| 5002 |
var slideSize = slides[activeIndex].swiperSlideSize; |
| 5003 |
var breakLoop; |
| 5004 |
|
| 5005 |
for (var i = activeIndex + 1; i < slides.length; i += 1) { |
| 5006 |
if (slides[i] && !breakLoop) { |
| 5007 |
slideSize += slides[i].swiperSlideSize; |
| 5008 |
spv += 1; |
| 5009 |
if (slideSize > swiperSize) breakLoop = true; |
| 5010 |
} |
| 5011 |
} |
| 5012 |
|
| 5013 |
for (var _i = activeIndex - 1; _i >= 0; _i -= 1) { |
| 5014 |
if (slides[_i] && !breakLoop) { |
| 5015 |
slideSize += slides[_i].swiperSlideSize; |
| 5016 |
spv += 1; |
| 5017 |
if (slideSize > swiperSize) breakLoop = true; |
| 5018 |
} |
| 5019 |
} |
| 5020 |
} else { |
| 5021 |
for (var _i2 = activeIndex + 1; _i2 < slides.length; _i2 += 1) { |
| 5022 |
if (slidesGrid[_i2] - slidesGrid[activeIndex] < swiperSize) { |
| 5023 |
spv += 1; |
| 5024 |
} |
| 5025 |
} |
| 5026 |
} |
| 5027 |
|
| 5028 |
return spv; |
| 5029 |
}; |
| 5030 |
|
| 5031 |
_proto.update = function update() { |
| 5032 |
var swiper = this; |
| 5033 |
if (!swiper || swiper.destroyed) return; |
| 5034 |
var snapGrid = swiper.snapGrid, |
| 5035 |
params = swiper.params; // Breakpoints |
| 5036 |
|
| 5037 |
if (params.breakpoints) { |
| 5038 |
swiper.setBreakpoint(); |
| 5039 |
} |
| 5040 |
|
| 5041 |
swiper.updateSize(); |
| 5042 |
swiper.updateSlides(); |
| 5043 |
swiper.updateProgress(); |
| 5044 |
swiper.updateSlidesClasses(); |
| 5045 |
|
| 5046 |
function setTranslate() { |
| 5047 |
var translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate; |
| 5048 |
var newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate()); |
| 5049 |
swiper.setTranslate(newTranslate); |
| 5050 |
swiper.updateActiveIndex(); |
| 5051 |
swiper.updateSlidesClasses(); |
| 5052 |
} |
| 5053 |
|
| 5054 |
var translated; |
| 5055 |
|
| 5056 |
if (swiper.params.freeMode) { |
| 5057 |
setTranslate(); |
| 5058 |
|
| 5059 |
if (swiper.params.autoHeight) { |
| 5060 |
swiper.updateAutoHeight(); |
| 5061 |
} |
| 5062 |
} else { |
| 5063 |
if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) { |
| 5064 |
translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true); |
| 5065 |
} else { |
| 5066 |
translated = swiper.slideTo(swiper.activeIndex, 0, false, true); |
| 5067 |
} |
| 5068 |
|
| 5069 |
if (!translated) { |
| 5070 |
setTranslate(); |
| 5071 |
} |
| 5072 |
} |
| 5073 |
|
| 5074 |
if (params.watchOverflow && snapGrid !== swiper.snapGrid) { |
| 5075 |
swiper.checkOverflow(); |
| 5076 |
} |
| 5077 |
|
| 5078 |
swiper.emit('update'); |
| 5079 |
}; |
| 5080 |
|
| 5081 |
_proto.changeDirection = function changeDirection(newDirection, needUpdate) { |
| 5082 |
if (needUpdate === void 0) { |
| 5083 |
needUpdate = true; |
| 5084 |
} |
| 5085 |
|
| 5086 |
var swiper = this; |
| 5087 |
var currentDirection = swiper.params.direction; |
| 5088 |
|
| 5089 |
if (!newDirection) { |
| 5090 |
// eslint-disable-next-line |
| 5091 |
newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal'; |
| 5092 |
} |
| 5093 |
|
| 5094 |
if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') { |
| 5095 |
return swiper; |
| 5096 |
} |
| 5097 |
|
| 5098 |
swiper.$el.removeClass("" + swiper.params.containerModifierClass + currentDirection).addClass("" + swiper.params.containerModifierClass + newDirection); |
| 5099 |
swiper.emitContainerClasses(); |
| 5100 |
swiper.params.direction = newDirection; |
| 5101 |
swiper.slides.each(function (slideEl) { |
| 5102 |
if (newDirection === 'vertical') { |
| 5103 |
slideEl.style.width = ''; |
| 5104 |
} else { |
| 5105 |
slideEl.style.height = ''; |
| 5106 |
} |
| 5107 |
}); |
| 5108 |
swiper.emit('changeDirection'); |
| 5109 |
if (needUpdate) swiper.update(); |
| 5110 |
return swiper; |
| 5111 |
}; |
| 5112 |
|
| 5113 |
_proto.mount = function mount(el) { |
| 5114 |
var swiper = this; |
| 5115 |
if (swiper.mounted) return true; // Find el |
| 5116 |
|
| 5117 |
var $el = $(el || swiper.params.el); |
| 5118 |
el = $el[0]; |
| 5119 |
|
| 5120 |
if (!el) { |
| 5121 |
return false; |
| 5122 |
} |
| 5123 |
|
| 5124 |
el.swiper = swiper; // Find Wrapper |
| 5125 |
|
| 5126 |
var $wrapperEl; |
| 5127 |
|
| 5128 |
if (el && el.shadowRoot && el.shadowRoot.querySelector) { |
| 5129 |
$wrapperEl = $(el.shadowRoot.querySelector("." + swiper.params.wrapperClass)); // Children needs to return slot items |
| 5130 |
|
| 5131 |
$wrapperEl.children = function (options) { |
| 5132 |
return $el.children(options); |
| 5133 |
}; |
| 5134 |
} else { |
| 5135 |
$wrapperEl = $el.children("." + swiper.params.wrapperClass); |
| 5136 |
} |
| 5137 |
|
| 5138 |
extend(swiper, { |
| 5139 |
$el: $el, |
| 5140 |
el: el, |
| 5141 |
$wrapperEl: $wrapperEl, |
| 5142 |
wrapperEl: $wrapperEl[0], |
| 5143 |
mounted: true, |
| 5144 |
// RTL |
| 5145 |
rtl: el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl', |
| 5146 |
rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'), |
| 5147 |
wrongRTL: $wrapperEl.css('display') === '-webkit-box' |
| 5148 |
}); |
| 5149 |
return true; |
| 5150 |
}; |
| 5151 |
|
| 5152 |
_proto.init = function init(el) { |
| 5153 |
var swiper = this; |
| 5154 |
if (swiper.initialized) return swiper; |
| 5155 |
var mounted = swiper.mount(el); |
| 5156 |
if (mounted === false) return swiper; |
| 5157 |
swiper.emit('beforeInit'); // Set breakpoint |
| 5158 |
|
| 5159 |
if (swiper.params.breakpoints) { |
| 5160 |
swiper.setBreakpoint(); |
| 5161 |
} // Add Classes |
| 5162 |
|
| 5163 |
|
| 5164 |
swiper.addClasses(); // Create loop |
| 5165 |
|
| 5166 |
if (swiper.params.loop) { |
| 5167 |
swiper.loopCreate(); |
| 5168 |
} // Update size |
| 5169 |
|
| 5170 |
|
| 5171 |
swiper.updateSize(); // Update slides |
| 5172 |
|
| 5173 |
swiper.updateSlides(); |
| 5174 |
|
| 5175 |
if (swiper.params.watchOverflow) { |
| 5176 |
swiper.checkOverflow(); |
| 5177 |
} // Set Grab Cursor |
| 5178 |
|
| 5179 |
|
| 5180 |
if (swiper.params.grabCursor) { |
| 5181 |
swiper.setGrabCursor(); |
| 5182 |
} |
| 5183 |
|
| 5184 |
if (swiper.params.preloadImages) { |
| 5185 |
swiper.preloadImages(); |
| 5186 |
} // Slide To Initial Slide |
| 5187 |
|
| 5188 |
|
| 5189 |
if (swiper.params.loop) { |
| 5190 |
swiper.slideTo(swiper.params.initialSlide + swiper.loopedSlides, 0, swiper.params.runCallbacksOnInit); |
| 5191 |
} else { |
| 5192 |
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit); |
| 5193 |
} // Attach events |
| 5194 |
|
| 5195 |
|
| 5196 |
swiper.attachEvents(); // Init Flag |
| 5197 |
|
| 5198 |
swiper.initialized = true; // Emit |
| 5199 |
|
| 5200 |
swiper.emit('init'); |
| 5201 |
swiper.emit('afterInit'); |
| 5202 |
return swiper; |
| 5203 |
}; |
| 5204 |
|
| 5205 |
_proto.destroy = function destroy(deleteInstance, cleanStyles) { |
| 5206 |
if (deleteInstance === void 0) { |
| 5207 |
deleteInstance = true; |
| 5208 |
} |
| 5209 |
|
| 5210 |
if (cleanStyles === void 0) { |
| 5211 |
cleanStyles = true; |
| 5212 |
} |
| 5213 |
|
| 5214 |
var swiper = this; |
| 5215 |
var params = swiper.params, |
| 5216 |
$el = swiper.$el, |
| 5217 |
$wrapperEl = swiper.$wrapperEl, |
| 5218 |
slides = swiper.slides; |
| 5219 |
|
| 5220 |
if (typeof swiper.params === 'undefined' || swiper.destroyed) { |
| 5221 |
return null; |
| 5222 |
} |
| 5223 |
|
| 5224 |
swiper.emit('beforeDestroy'); // Init Flag |
| 5225 |
|
| 5226 |
swiper.initialized = false; // Detach events |
| 5227 |
|
| 5228 |
swiper.detachEvents(); // Destroy loop |
| 5229 |
|
| 5230 |
if (params.loop) { |
| 5231 |
swiper.loopDestroy(); |
| 5232 |
} // Cleanup styles |
| 5233 |
|
| 5234 |
|
| 5235 |
if (cleanStyles) { |
| 5236 |
swiper.removeClasses(); |
| 5237 |
$el.removeAttr('style'); |
| 5238 |
$wrapperEl.removeAttr('style'); |
| 5239 |
|
| 5240 |
if (slides && slides.length) { |
| 5241 |
slides.removeClass([params.slideVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass].join(' ')).removeAttr('style').removeAttr('data-swiper-slide-index'); |
| 5242 |
} |
| 5243 |
} |
| 5244 |
|
| 5245 |
swiper.emit('destroy'); // Detach emitter events |
| 5246 |
|
| 5247 |
Object.keys(swiper.eventsListeners).forEach(function (eventName) { |
| 5248 |
swiper.off(eventName); |
| 5249 |
}); |
| 5250 |
|
| 5251 |
if (deleteInstance !== false) { |
| 5252 |
swiper.$el[0].swiper = null; |
| 5253 |
deleteProps(swiper); |
| 5254 |
} |
| 5255 |
|
| 5256 |
swiper.destroyed = true; |
| 5257 |
return null; |
| 5258 |
}; |
| 5259 |
|
| 5260 |
Swiper.extendDefaults = function extendDefaults(newDefaults) { |
| 5261 |
extend(extendedDefaults, newDefaults); |
| 5262 |
}; |
| 5263 |
|
| 5264 |
Swiper.installModule = function installModule(module) { |
| 5265 |
if (!Swiper.prototype.modules) Swiper.prototype.modules = {}; |
| 5266 |
var name = module.name || Object.keys(Swiper.prototype.modules).length + "_" + now(); |
| 5267 |
Swiper.prototype.modules[name] = module; |
| 5268 |
}; |
| 5269 |
|
| 5270 |
Swiper.use = function use(module) { |
| 5271 |
if (Array.isArray(module)) { |
| 5272 |
module.forEach(function (m) { |
| 5273 |
return Swiper.installModule(m); |
| 5274 |
}); |
| 5275 |
return Swiper; |
| 5276 |
} |
| 5277 |
|
| 5278 |
Swiper.installModule(module); |
| 5279 |
return Swiper; |
| 5280 |
}; |
| 5281 |
|
| 5282 |
_createClass(Swiper, null, [{ |
| 5283 |
key: "extendedDefaults", |
| 5284 |
get: function get() { |
| 5285 |
return extendedDefaults; |
| 5286 |
} |
| 5287 |
}, { |
| 5288 |
key: "defaults", |
| 5289 |
get: function get() { |
| 5290 |
return defaults; |
| 5291 |
} |
| 5292 |
}]); |
| 5293 |
|
| 5294 |
return Swiper; |
| 5295 |
}(); |
| 5296 |
|
| 5297 |
Object.keys(prototypes).forEach(function (prototypeGroup) { |
| 5298 |
Object.keys(prototypes[prototypeGroup]).forEach(function (protoMethod) { |
| 5299 |
Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod]; |
| 5300 |
}); |
| 5301 |
}); |
| 5302 |
Swiper.use([Resize, Observer$1]); |
| 5303 |
|
| 5304 |
var Virtual = { |
| 5305 |
update: function update(force) { |
| 5306 |
var swiper = this; |
| 5307 |
var _swiper$params = swiper.params, |
| 5308 |
slidesPerView = _swiper$params.slidesPerView, |
| 5309 |
slidesPerGroup = _swiper$params.slidesPerGroup, |
| 5310 |
centeredSlides = _swiper$params.centeredSlides; |
| 5311 |
var _swiper$params$virtua = swiper.params.virtual, |
| 5312 |
addSlidesBefore = _swiper$params$virtua.addSlidesBefore, |
| 5313 |
addSlidesAfter = _swiper$params$virtua.addSlidesAfter; |
| 5314 |
var _swiper$virtual = swiper.virtual, |
| 5315 |
previousFrom = _swiper$virtual.from, |
| 5316 |
previousTo = _swiper$virtual.to, |
| 5317 |
slides = _swiper$virtual.slides, |
| 5318 |
previousSlidesGrid = _swiper$virtual.slidesGrid, |
| 5319 |
renderSlide = _swiper$virtual.renderSlide, |
| 5320 |
previousOffset = _swiper$virtual.offset; |
| 5321 |
swiper.updateActiveIndex(); |
| 5322 |
var activeIndex = swiper.activeIndex || 0; |
| 5323 |
var offsetProp; |
| 5324 |
if (swiper.rtlTranslate) offsetProp = 'right';else offsetProp = swiper.isHorizontal() ? 'left' : 'top'; |
| 5325 |
var slidesAfter; |
| 5326 |
var slidesBefore; |
| 5327 |
|
| 5328 |
if (centeredSlides) { |
| 5329 |
slidesAfter = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesAfter; |
| 5330 |
slidesBefore = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesBefore; |
| 5331 |
} else { |
| 5332 |
slidesAfter = slidesPerView + (slidesPerGroup - 1) + addSlidesAfter; |
| 5333 |
slidesBefore = slidesPerGroup + addSlidesBefore; |
| 5334 |
} |
| 5335 |
|
| 5336 |
var from = Math.max((activeIndex || 0) - slidesBefore, 0); |
| 5337 |
var to = Math.min((activeIndex || 0) + slidesAfter, slides.length - 1); |
| 5338 |
var offset = (swiper.slidesGrid[from] || 0) - (swiper.slidesGrid[0] || 0); |
| 5339 |
extend(swiper.virtual, { |
| 5340 |
from: from, |
| 5341 |
to: to, |
| 5342 |
offset: offset, |
| 5343 |
slidesGrid: swiper.slidesGrid |
| 5344 |
}); |
| 5345 |
|
| 5346 |
function onRendered() { |
| 5347 |
swiper.updateSlides(); |
| 5348 |
swiper.updateProgress(); |
| 5349 |
swiper.updateSlidesClasses(); |
| 5350 |
|
| 5351 |
if (swiper.lazy && swiper.params.lazy.enabled) { |
| 5352 |
swiper.lazy.load(); |
| 5353 |
} |
| 5354 |
} |
| 5355 |
|
| 5356 |
if (previousFrom === from && previousTo === to && !force) { |
| 5357 |
if (swiper.slidesGrid !== previousSlidesGrid && offset !== previousOffset) { |
| 5358 |
swiper.slides.css(offsetProp, offset + "px"); |
| 5359 |
} |
| 5360 |
|
| 5361 |
swiper.updateProgress(); |
| 5362 |
return; |
| 5363 |
} |
| 5364 |
|
| 5365 |
if (swiper.params.virtual.renderExternal) { |
| 5366 |
swiper.params.virtual.renderExternal.call(swiper, { |
| 5367 |
offset: offset, |
| 5368 |
from: from, |
| 5369 |
to: to, |
| 5370 |
slides: function getSlides() { |
| 5371 |
var slidesToRender = []; |
| 5372 |
|
| 5373 |
for (var i = from; i <= to; i += 1) { |
| 5374 |
slidesToRender.push(slides[i]); |
| 5375 |
} |
| 5376 |
|
| 5377 |
return slidesToRender; |
| 5378 |
}() |
| 5379 |
}); |
| 5380 |
|
| 5381 |
if (swiper.params.virtual.renderExternalUpdate) { |
| 5382 |
onRendered(); |
| 5383 |
} |
| 5384 |
|
| 5385 |
return; |
| 5386 |
} |
| 5387 |
|
| 5388 |
var prependIndexes = []; |
| 5389 |
var appendIndexes = []; |
| 5390 |
|
| 5391 |
if (force) { |
| 5392 |
swiper.$wrapperEl.find("." + swiper.params.slideClass).remove(); |
| 5393 |
} else { |
| 5394 |
for (var i = previousFrom; i <= previousTo; i += 1) { |
| 5395 |
if (i < from || i > to) { |
| 5396 |
swiper.$wrapperEl.find("." + swiper.params.slideClass + "[data-swiper-slide-index=\"" + i + "\"]").remove(); |
| 5397 |
} |
| 5398 |
} |
| 5399 |
} |
| 5400 |
|
| 5401 |
for (var _i = 0; _i < slides.length; _i += 1) { |
| 5402 |
if (_i >= from && _i <= to) { |
| 5403 |
if (typeof previousTo === 'undefined' || force) { |
| 5404 |
appendIndexes.push(_i); |
| 5405 |
} else { |
| 5406 |
if (_i > previousTo) appendIndexes.push(_i); |
| 5407 |
if (_i < previousFrom) prependIndexes.push(_i); |
| 5408 |
} |
| 5409 |
} |
| 5410 |
} |
| 5411 |
|
| 5412 |
appendIndexes.forEach(function (index) { |
| 5413 |
swiper.$wrapperEl.append(renderSlide(slides[index], index)); |
| 5414 |
}); |
| 5415 |
prependIndexes.sort(function (a, b) { |
| 5416 |
return b - a; |
| 5417 |
}).forEach(function (index) { |
| 5418 |
swiper.$wrapperEl.prepend(renderSlide(slides[index], index)); |
| 5419 |
}); |
| 5420 |
swiper.$wrapperEl.children('.swiper-slide').css(offsetProp, offset + "px"); |
| 5421 |
onRendered(); |
| 5422 |
}, |
| 5423 |
renderSlide: function renderSlide(slide, index) { |
| 5424 |
var swiper = this; |
| 5425 |
var params = swiper.params.virtual; |
| 5426 |
|
| 5427 |
if (params.cache && swiper.virtual.cache[index]) { |
| 5428 |
return swiper.virtual.cache[index]; |
| 5429 |
} |
| 5430 |
|
| 5431 |
var $slideEl = params.renderSlide ? $(params.renderSlide.call(swiper, slide, index)) : $("<div class=\"" + swiper.params.slideClass + "\" data-swiper-slide-index=\"" + index + "\">" + slide + "</div>"); |
| 5432 |
if (!$slideEl.attr('data-swiper-slide-index')) $slideEl.attr('data-swiper-slide-index', index); |
| 5433 |
if (params.cache) swiper.virtual.cache[index] = $slideEl; |
| 5434 |
return $slideEl; |
| 5435 |
}, |
| 5436 |
appendSlide: function appendSlide(slides) { |
| 5437 |
var swiper = this; |
| 5438 |
|
| 5439 |
if (typeof slides === 'object' && 'length' in slides) { |
| 5440 |
for (var i = 0; i < slides.length; i += 1) { |
| 5441 |
if (slides[i]) swiper.virtual.slides.push(slides[i]); |
| 5442 |
} |
| 5443 |
} else { |
| 5444 |
swiper.virtual.slides.push(slides); |
| 5445 |
} |
| 5446 |
|
| 5447 |
swiper.virtual.update(true); |
| 5448 |
}, |
| 5449 |
prependSlide: function prependSlide(slides) { |
| 5450 |
var swiper = this; |
| 5451 |
var activeIndex = swiper.activeIndex; |
| 5452 |
var newActiveIndex = activeIndex + 1; |
| 5453 |
var numberOfNewSlides = 1; |
| 5454 |
|
| 5455 |
if (Array.isArray(slides)) { |
| 5456 |
for (var i = 0; i < slides.length; i += 1) { |
| 5457 |
if (slides[i]) swiper.virtual.slides.unshift(slides[i]); |
| 5458 |
} |
| 5459 |
|
| 5460 |
newActiveIndex = activeIndex + slides.length; |
| 5461 |
numberOfNewSlides = slides.length; |
| 5462 |
} else { |
| 5463 |
swiper.virtual.slides.unshift(slides); |
| 5464 |
} |
| 5465 |
|
| 5466 |
if (swiper.params.virtual.cache) { |
| 5467 |
var cache = swiper.virtual.cache; |
| 5468 |
var newCache = {}; |
| 5469 |
Object.keys(cache).forEach(function (cachedIndex) { |
| 5470 |
var $cachedEl = cache[cachedIndex]; |
| 5471 |
var cachedElIndex = $cachedEl.attr('data-swiper-slide-index'); |
| 5472 |
|
| 5473 |
if (cachedElIndex) { |
| 5474 |
$cachedEl.attr('data-swiper-slide-index', parseInt(cachedElIndex, 10) + 1); |
| 5475 |
} |
| 5476 |
|
| 5477 |
newCache[parseInt(cachedIndex, 10) + numberOfNewSlides] = $cachedEl; |
| 5478 |
}); |
| 5479 |
swiper.virtual.cache = newCache; |
| 5480 |
} |
| 5481 |
|
| 5482 |
swiper.virtual.update(true); |
| 5483 |
swiper.slideTo(newActiveIndex, 0); |
| 5484 |
}, |
| 5485 |
removeSlide: function removeSlide(slidesIndexes) { |
| 5486 |
var swiper = this; |
| 5487 |
if (typeof slidesIndexes === 'undefined' || slidesIndexes === null) return; |
| 5488 |
var activeIndex = swiper.activeIndex; |
| 5489 |
|
| 5490 |
if (Array.isArray(slidesIndexes)) { |
| 5491 |
for (var i = slidesIndexes.length - 1; i >= 0; i -= 1) { |
| 5492 |
swiper.virtual.slides.splice(slidesIndexes[i], 1); |
| 5493 |
|
| 5494 |
if (swiper.params.virtual.cache) { |
| 5495 |
delete swiper.virtual.cache[slidesIndexes[i]]; |
| 5496 |
} |
| 5497 |
|
| 5498 |
if (slidesIndexes[i] < activeIndex) activeIndex -= 1; |
| 5499 |
activeIndex = Math.max(activeIndex, 0); |
| 5500 |
} |
| 5501 |
} else { |
| 5502 |
swiper.virtual.slides.splice(slidesIndexes, 1); |
| 5503 |
|
| 5504 |
if (swiper.params.virtual.cache) { |
| 5505 |
delete swiper.virtual.cache[slidesIndexes]; |
| 5506 |
} |
| 5507 |
|
| 5508 |
if (slidesIndexes < activeIndex) activeIndex -= 1; |
| 5509 |
activeIndex = Math.max(activeIndex, 0); |
| 5510 |
} |
| 5511 |
|
| 5512 |
swiper.virtual.update(true); |
| 5513 |
swiper.slideTo(activeIndex, 0); |
| 5514 |
}, |
| 5515 |
removeAllSlides: function removeAllSlides() { |
| 5516 |
var swiper = this; |
| 5517 |
swiper.virtual.slides = []; |
| 5518 |
|
| 5519 |
if (swiper.params.virtual.cache) { |
| 5520 |
swiper.virtual.cache = {}; |
| 5521 |
} |
| 5522 |
|
| 5523 |
swiper.virtual.update(true); |
| 5524 |
swiper.slideTo(0, 0); |
| 5525 |
} |
| 5526 |
}; |
| 5527 |
var Virtual$1 = { |
| 5528 |
name: 'virtual', |
| 5529 |
params: { |
| 5530 |
virtual: { |
| 5531 |
enabled: false, |
| 5532 |
slides: [], |
| 5533 |
cache: true, |
| 5534 |
renderSlide: null, |
| 5535 |
renderExternal: null, |
| 5536 |
renderExternalUpdate: true, |
| 5537 |
addSlidesBefore: 0, |
| 5538 |
addSlidesAfter: 0 |
| 5539 |
} |
| 5540 |
}, |
| 5541 |
create: function create() { |
| 5542 |
var swiper = this; |
| 5543 |
bindModuleMethods(swiper, { |
| 5544 |
virtual: _extends({}, Virtual, { |
| 5545 |
slides: swiper.params.virtual.slides, |
| 5546 |
cache: {} |
| 5547 |
}) |
| 5548 |
}); |
| 5549 |
}, |
| 5550 |
on: { |
| 5551 |
beforeInit: function beforeInit(swiper) { |
| 5552 |
if (!swiper.params.virtual.enabled) return; |
| 5553 |
swiper.classNames.push(swiper.params.containerModifierClass + "virtual"); |
| 5554 |
var overwriteParams = { |
| 5555 |
watchSlidesProgress: true |
| 5556 |
}; |
| 5557 |
extend(swiper.params, overwriteParams); |
| 5558 |
extend(swiper.originalParams, overwriteParams); |
| 5559 |
|
| 5560 |
if (!swiper.params.initialSlide) { |
| 5561 |
swiper.virtual.update(); |
| 5562 |
} |
| 5563 |
}, |
| 5564 |
setTranslate: function setTranslate(swiper) { |
| 5565 |
if (!swiper.params.virtual.enabled) return; |
| 5566 |
swiper.virtual.update(); |
| 5567 |
} |
| 5568 |
} |
| 5569 |
}; |
| 5570 |
|
| 5571 |
var Keyboard = { |
| 5572 |
handle: function handle(event) { |
| 5573 |
var swiper = this; |
| 5574 |
var window = getWindow(); |
| 5575 |
var document = getDocument(); |
| 5576 |
var rtl = swiper.rtlTranslate; |
| 5577 |
var e = event; |
| 5578 |
if (e.originalEvent) e = e.originalEvent; // jquery fix |
| 5579 |
|
| 5580 |
var kc = e.keyCode || e.charCode; |
| 5581 |
var pageUpDown = swiper.params.keyboard.pageUpDown; |
| 5582 |
var isPageUp = pageUpDown && kc === 33; |
| 5583 |
var isPageDown = pageUpDown && kc === 34; |
| 5584 |
var isArrowLeft = kc === 37; |
| 5585 |
var isArrowRight = kc === 39; |
| 5586 |
var isArrowUp = kc === 38; |
| 5587 |
var isArrowDown = kc === 40; // Directions locks |
| 5588 |
|
| 5589 |
if (!swiper.allowSlideNext && (swiper.isHorizontal() && isArrowRight || swiper.isVertical() && isArrowDown || isPageDown)) { |
| 5590 |
return false; |
| 5591 |
} |
| 5592 |
|
| 5593 |
if (!swiper.allowSlidePrev && (swiper.isHorizontal() && isArrowLeft || swiper.isVertical() && isArrowUp || isPageUp)) { |
| 5594 |
return false; |
| 5595 |
} |
| 5596 |
|
| 5597 |
if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) { |
| 5598 |
return undefined; |
| 5599 |
} |
| 5600 |
|
| 5601 |
if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) { |
| 5602 |
return undefined; |
| 5603 |
} |
| 5604 |
|
| 5605 |
if (swiper.params.keyboard.onlyInViewport && (isPageUp || isPageDown || isArrowLeft || isArrowRight || isArrowUp || isArrowDown)) { |
| 5606 |
var inView = false; // Check that swiper should be inside of visible area of window |
| 5607 |
|
| 5608 |
if (swiper.$el.parents("." + swiper.params.slideClass).length > 0 && swiper.$el.parents("." + swiper.params.slideActiveClass).length === 0) { |
| 5609 |
return undefined; |
| 5610 |
} |
| 5611 |
|
| 5612 |
var $el = swiper.$el; |
| 5613 |
var swiperWidth = $el[0].clientWidth; |
| 5614 |
var swiperHeight = $el[0].clientHeight; |
| 5615 |
var windowWidth = window.innerWidth; |
| 5616 |
var windowHeight = window.innerHeight; |
| 5617 |
var swiperOffset = swiper.$el.offset(); |
| 5618 |
if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft; |
| 5619 |
var swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiperWidth, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiperHeight], [swiperOffset.left + swiperWidth, swiperOffset.top + swiperHeight]]; |
| 5620 |
|
| 5621 |
for (var i = 0; i < swiperCoord.length; i += 1) { |
| 5622 |
var point = swiperCoord[i]; |
| 5623 |
|
| 5624 |
if (point[0] >= 0 && point[0] <= windowWidth && point[1] >= 0 && point[1] <= windowHeight) { |
| 5625 |
if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line |
| 5626 |
|
| 5627 |
inView = true; |
| 5628 |
} |
| 5629 |
} |
| 5630 |
|
| 5631 |
if (!inView) return undefined; |
| 5632 |
} |
| 5633 |
|
| 5634 |
if (swiper.isHorizontal()) { |
| 5635 |
if (isPageUp || isPageDown || isArrowLeft || isArrowRight) { |
| 5636 |
if (e.preventDefault) e.preventDefault();else e.returnValue = false; |
| 5637 |
} |
| 5638 |
|
| 5639 |
if ((isPageDown || isArrowRight) && !rtl || (isPageUp || isArrowLeft) && rtl) swiper.slideNext(); |
| 5640 |
if ((isPageUp || isArrowLeft) && !rtl || (isPageDown || isArrowRight) && rtl) swiper.slidePrev(); |
| 5641 |
} else { |
| 5642 |
if (isPageUp || isPageDown || isArrowUp || isArrowDown) { |
| 5643 |
if (e.preventDefault) e.preventDefault();else e.returnValue = false; |
| 5644 |
} |
| 5645 |
|
| 5646 |
if (isPageDown || isArrowDown) swiper.slideNext(); |
| 5647 |
if (isPageUp || isArrowUp) swiper.slidePrev(); |
| 5648 |
} |
| 5649 |
|
| 5650 |
swiper.emit('keyPress', kc); |
| 5651 |
return undefined; |
| 5652 |
}, |
| 5653 |
enable: function enable() { |
| 5654 |
var swiper = this; |
| 5655 |
var document = getDocument(); |
| 5656 |
if (swiper.keyboard.enabled) return; |
| 5657 |
$(document).on('keydown', swiper.keyboard.handle); |
| 5658 |
swiper.keyboard.enabled = true; |
| 5659 |
}, |
| 5660 |
disable: function disable() { |
| 5661 |
var swiper = this; |
| 5662 |
var document = getDocument(); |
| 5663 |
if (!swiper.keyboard.enabled) return; |
| 5664 |
$(document).off('keydown', swiper.keyboard.handle); |
| 5665 |
swiper.keyboard.enabled = false; |
| 5666 |
} |
| 5667 |
}; |
| 5668 |
var Keyboard$1 = { |
| 5669 |
name: 'keyboard', |
| 5670 |
params: { |
| 5671 |
keyboard: { |
| 5672 |
enabled: false, |
| 5673 |
onlyInViewport: true, |
| 5674 |
pageUpDown: true |
| 5675 |
} |
| 5676 |
}, |
| 5677 |
create: function create() { |
| 5678 |
var swiper = this; |
| 5679 |
bindModuleMethods(swiper, { |
| 5680 |
keyboard: _extends({ |
| 5681 |
enabled: false |
| 5682 |
}, Keyboard) |
| 5683 |
}); |
| 5684 |
}, |
| 5685 |
on: { |
| 5686 |
init: function init(swiper) { |
| 5687 |
if (swiper.params.keyboard.enabled) { |
| 5688 |
swiper.keyboard.enable(); |
| 5689 |
} |
| 5690 |
}, |
| 5691 |
destroy: function destroy(swiper) { |
| 5692 |
if (swiper.keyboard.enabled) { |
| 5693 |
swiper.keyboard.disable(); |
| 5694 |
} |
| 5695 |
} |
| 5696 |
} |
| 5697 |
}; |
| 5698 |
|
| 5699 |
function isEventSupported() { |
| 5700 |
var document = getDocument(); |
| 5701 |
var eventName = 'onwheel'; |
| 5702 |
var isSupported = (eventName in document); |
| 5703 |
|
| 5704 |
if (!isSupported) { |
| 5705 |
var element = document.createElement('div'); |
| 5706 |
element.setAttribute(eventName, 'return;'); |
| 5707 |
isSupported = typeof element[eventName] === 'function'; |
| 5708 |
} |
| 5709 |
|
| 5710 |
if (!isSupported && document.implementation && document.implementation.hasFeature && // always returns true in newer browsers as per the standard. |
| 5711 |
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature |
| 5712 |
document.implementation.hasFeature('', '') !== true) { |
| 5713 |
// This is the only way to test support for the `wheel` event in IE9+. |
| 5714 |
isSupported = document.implementation.hasFeature('Events.wheel', '3.0'); |
| 5715 |
} |
| 5716 |
|
| 5717 |
return isSupported; |
| 5718 |
} |
| 5719 |
|
| 5720 |
var Mousewheel = { |
| 5721 |
lastScrollTime: now(), |
| 5722 |
lastEventBeforeSnap: undefined, |
| 5723 |
recentWheelEvents: [], |
| 5724 |
event: function event() { |
| 5725 |
var window = getWindow(); |
| 5726 |
if (window.navigator.userAgent.indexOf('firefox') > -1) return 'DOMMouseScroll'; |
| 5727 |
return isEventSupported() ? 'wheel' : 'mousewheel'; |
| 5728 |
}, |
| 5729 |
normalize: function normalize(e) { |
| 5730 |
// Reasonable defaults |
| 5731 |
var PIXEL_STEP = 10; |
| 5732 |
var LINE_HEIGHT = 40; |
| 5733 |
var PAGE_HEIGHT = 800; |
| 5734 |
var sX = 0; |
| 5735 |
var sY = 0; // spinX, spinY |
| 5736 |
|
| 5737 |
var pX = 0; |
| 5738 |
var pY = 0; // pixelX, pixelY |
| 5739 |
// Legacy |
| 5740 |
|
| 5741 |
if ('detail' in e) { |
| 5742 |
sY = e.detail; |
| 5743 |
} |
| 5744 |
|
| 5745 |
if ('wheelDelta' in e) { |
| 5746 |
sY = -e.wheelDelta / 120; |
| 5747 |
} |
| 5748 |
|
| 5749 |
if ('wheelDeltaY' in e) { |
| 5750 |
sY = -e.wheelDeltaY / 120; |
| 5751 |
} |
| 5752 |
|
| 5753 |
if ('wheelDeltaX' in e) { |
| 5754 |
sX = -e.wheelDeltaX / 120; |
| 5755 |
} // side scrolling on FF with DOMMouseScroll |
| 5756 |
|
| 5757 |
|
| 5758 |
if ('axis' in e && e.axis === e.HORIZONTAL_AXIS) { |
| 5759 |
sX = sY; |
| 5760 |
sY = 0; |
| 5761 |
} |
| 5762 |
|
| 5763 |
pX = sX * PIXEL_STEP; |
| 5764 |
pY = sY * PIXEL_STEP; |
| 5765 |
|
| 5766 |
if ('deltaY' in e) { |
| 5767 |
pY = e.deltaY; |
| 5768 |
} |
| 5769 |
|
| 5770 |
if ('deltaX' in e) { |
| 5771 |
pX = e.deltaX; |
| 5772 |
} |
| 5773 |
|
| 5774 |
if (e.shiftKey && !pX) { |
| 5775 |
// if user scrolls with shift he wants horizontal scroll |
| 5776 |
pX = pY; |
| 5777 |
pY = 0; |
| 5778 |
} |
| 5779 |
|
| 5780 |
if ((pX || pY) && e.deltaMode) { |
| 5781 |
if (e.deltaMode === 1) { |
| 5782 |
// delta in LINE units |
| 5783 |
pX *= LINE_HEIGHT; |
| 5784 |
pY *= LINE_HEIGHT; |
| 5785 |
} else { |
| 5786 |
// delta in PAGE units |
| 5787 |
pX *= PAGE_HEIGHT; |
| 5788 |
pY *= PAGE_HEIGHT; |
| 5789 |
} |
| 5790 |
} // Fall-back if spin cannot be determined |
| 5791 |
|
| 5792 |
|
| 5793 |
if (pX && !sX) { |
| 5794 |
sX = pX < 1 ? -1 : 1; |
| 5795 |
} |
| 5796 |
|
| 5797 |
if (pY && !sY) { |
| 5798 |
sY = pY < 1 ? -1 : 1; |
| 5799 |
} |
| 5800 |
|
| 5801 |
return { |
| 5802 |
spinX: sX, |
| 5803 |
spinY: sY, |
| 5804 |
pixelX: pX, |
| 5805 |
pixelY: pY |
| 5806 |
}; |
| 5807 |
}, |
| 5808 |
handleMouseEnter: function handleMouseEnter() { |
| 5809 |
var swiper = this; |
| 5810 |
swiper.mouseEntered = true; |
| 5811 |
}, |
| 5812 |
handleMouseLeave: function handleMouseLeave() { |
| 5813 |
var swiper = this; |
| 5814 |
swiper.mouseEntered = false; |
| 5815 |
}, |
| 5816 |
handle: function handle(event) { |
| 5817 |
var e = event; |
| 5818 |
var disableParentSwiper = true; |
| 5819 |
var swiper = this; |
| 5820 |
var params = swiper.params.mousewheel; |
| 5821 |
|
| 5822 |
if (swiper.params.cssMode) { |
| 5823 |
e.preventDefault(); |
| 5824 |
} |
| 5825 |
|
| 5826 |
var target = swiper.$el; |
| 5827 |
|
| 5828 |
if (swiper.params.mousewheel.eventsTarget !== 'container') { |
| 5829 |
target = $(swiper.params.mousewheel.eventsTarget); |
| 5830 |
} |
| 5831 |
|
| 5832 |
if (!swiper.mouseEntered && !target[0].contains(e.target) && !params.releaseOnEdges) return true; |
| 5833 |
if (e.originalEvent) e = e.originalEvent; // jquery fix |
| 5834 |
|
| 5835 |
var delta = 0; |
| 5836 |
var rtlFactor = swiper.rtlTranslate ? -1 : 1; |
| 5837 |
var data = Mousewheel.normalize(e); |
| 5838 |
|
| 5839 |
if (params.forceToAxis) { |
| 5840 |
if (swiper.isHorizontal()) { |
| 5841 |
if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) delta = -data.pixelX * rtlFactor;else return true; |
| 5842 |
} else if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) delta = -data.pixelY;else return true; |
| 5843 |
} else { |
| 5844 |
delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY; |
| 5845 |
} |
| 5846 |
|
| 5847 |
if (delta === 0) return true; |
| 5848 |
if (params.invert) delta = -delta; // Get the scroll positions |
| 5849 |
|
| 5850 |
var positions = swiper.getTranslate() + delta * params.sensitivity; |
| 5851 |
if (positions >= swiper.minTranslate()) positions = swiper.minTranslate(); |
| 5852 |
if (positions <= swiper.maxTranslate()) positions = swiper.maxTranslate(); // When loop is true: |
| 5853 |
// the disableParentSwiper will be true. |
| 5854 |
// When loop is false: |
| 5855 |
// if the scroll positions is not on edge, |
| 5856 |
// then the disableParentSwiper will be true. |
| 5857 |
// if the scroll on edge positions, |
| 5858 |
// then the disableParentSwiper will be false. |
| 5859 |
|
| 5860 |
disableParentSwiper = swiper.params.loop ? true : !(positions === swiper.minTranslate() || positions === swiper.maxTranslate()); |
| 5861 |
if (disableParentSwiper && swiper.params.nested) e.stopPropagation(); |
| 5862 |
|
| 5863 |
if (!swiper.params.freeMode) { |
| 5864 |
// Register the new event in a variable which stores the relevant data |
| 5865 |
var newEvent = { |
| 5866 |
time: now(), |
| 5867 |
delta: Math.abs(delta), |
| 5868 |
direction: Math.sign(delta), |
| 5869 |
raw: event |
| 5870 |
}; // Keep the most recent events |
| 5871 |
|
| 5872 |
var recentWheelEvents = swiper.mousewheel.recentWheelEvents; |
| 5873 |
|
| 5874 |
if (recentWheelEvents.length >= 2) { |
| 5875 |
recentWheelEvents.shift(); // only store the last N events |
| 5876 |
} |
| 5877 |
|
| 5878 |
var prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined; |
| 5879 |
recentWheelEvents.push(newEvent); // If there is at least one previous recorded event: |
| 5880 |
// If direction has changed or |
| 5881 |
// if the scroll is quicker than the previous one: |
| 5882 |
// Animate the slider. |
| 5883 |
// Else (this is the first time the wheel is moved): |
| 5884 |
// Animate the slider. |
| 5885 |
|
| 5886 |
if (prevEvent) { |
| 5887 |
if (newEvent.direction !== prevEvent.direction || newEvent.delta > prevEvent.delta || newEvent.time > prevEvent.time + 150) { |
| 5888 |
swiper.mousewheel.animateSlider(newEvent); |
| 5889 |
} |
| 5890 |
} else { |
| 5891 |
swiper.mousewheel.animateSlider(newEvent); |
| 5892 |
} // If it's time to release the scroll: |
| 5893 |
// Return now so you don't hit the preventDefault. |
| 5894 |
|
| 5895 |
|
| 5896 |
if (swiper.mousewheel.releaseScroll(newEvent)) { |
| 5897 |
return true; |
| 5898 |
} |
| 5899 |
} else { |
| 5900 |
// Freemode or scrollContainer: |
| 5901 |
// If we recently snapped after a momentum scroll, then ignore wheel events |
| 5902 |
// to give time for the deceleration to finish. Stop ignoring after 500 msecs |
| 5903 |
// or if it's a new scroll (larger delta or inverse sign as last event before |
| 5904 |
// an end-of-momentum snap). |
| 5905 |
var _newEvent = { |
| 5906 |
time: now(), |
| 5907 |
delta: Math.abs(delta), |
| 5908 |
direction: Math.sign(delta) |
| 5909 |
}; |
| 5910 |
var lastEventBeforeSnap = swiper.mousewheel.lastEventBeforeSnap; |
| 5911 |
var ignoreWheelEvents = lastEventBeforeSnap && _newEvent.time < lastEventBeforeSnap.time + 500 && _newEvent.delta <= lastEventBeforeSnap.delta && _newEvent.direction === lastEventBeforeSnap.direction; |
| 5912 |
|
| 5913 |
if (!ignoreWheelEvents) { |
| 5914 |
swiper.mousewheel.lastEventBeforeSnap = undefined; |
| 5915 |
|
| 5916 |
if (swiper.params.loop) { |
| 5917 |
swiper.loopFix(); |
| 5918 |
} |
| 5919 |
|
| 5920 |
var position = swiper.getTranslate() + delta * params.sensitivity; |
| 5921 |
var wasBeginning = swiper.isBeginning; |
| 5922 |
var wasEnd = swiper.isEnd; |
| 5923 |
if (position >= swiper.minTranslate()) position = swiper.minTranslate(); |
| 5924 |
if (position <= swiper.maxTranslate()) position = swiper.maxTranslate(); |
| 5925 |
swiper.setTransition(0); |
| 5926 |
swiper.setTranslate(position); |
| 5927 |
swiper.updateProgress(); |
| 5928 |
swiper.updateActiveIndex(); |
| 5929 |
swiper.updateSlidesClasses(); |
| 5930 |
|
| 5931 |
if (!wasBeginning && swiper.isBeginning || !wasEnd && swiper.isEnd) { |
| 5932 |
swiper.updateSlidesClasses(); |
| 5933 |
} |
| 5934 |
|
| 5935 |
if (swiper.params.freeModeSticky) { |
| 5936 |
// When wheel scrolling starts with sticky (aka snap) enabled, then detect |
| 5937 |
// the end of a momentum scroll by storing recent (N=15?) wheel events. |
| 5938 |
// 1. do all N events have decreasing or same (absolute value) delta? |
| 5939 |
// 2. did all N events arrive in the last M (M=500?) msecs? |
| 5940 |
// 3. does the earliest event have an (absolute value) delta that's |
| 5941 |
// at least P (P=1?) larger than the most recent event's delta? |
| 5942 |
// 4. does the latest event have a delta that's smaller than Q (Q=6?) pixels? |
| 5943 |
// If 1-4 are "yes" then we're near the end of a momentum scroll deceleration. |
| 5944 |
// Snap immediately and ignore remaining wheel events in this scroll. |
| 5945 |
// See comment above for "remaining wheel events in this scroll" determination. |
| 5946 |
// If 1-4 aren't satisfied, then wait to snap until 500ms after the last event. |
| 5947 |
clearTimeout(swiper.mousewheel.timeout); |
| 5948 |
swiper.mousewheel.timeout = undefined; |
| 5949 |
var _recentWheelEvents = swiper.mousewheel.recentWheelEvents; |
| 5950 |
|
| 5951 |
if (_recentWheelEvents.length >= 15) { |
| 5952 |
_recentWheelEvents.shift(); // only store the last N events |
| 5953 |
|
| 5954 |
} |
| 5955 |
|
| 5956 |
var _prevEvent = _recentWheelEvents.length ? _recentWheelEvents[_recentWheelEvents.length - 1] : undefined; |
| 5957 |
|
| 5958 |
var firstEvent = _recentWheelEvents[0]; |
| 5959 |
|
| 5960 |
_recentWheelEvents.push(_newEvent); |
| 5961 |
|
| 5962 |
if (_prevEvent && (_newEvent.delta > _prevEvent.delta || _newEvent.direction !== _prevEvent.direction)) { |
| 5963 |
// Increasing or reverse-sign delta means the user started scrolling again. Clear the wheel event log. |
| 5964 |
_recentWheelEvents.splice(0); |
| 5965 |
} else if (_recentWheelEvents.length >= 15 && _newEvent.time - firstEvent.time < 500 && firstEvent.delta - _newEvent.delta >= 1 && _newEvent.delta <= 6) { |
| 5966 |
// We're at the end of the deceleration of a momentum scroll, so there's no need |
| 5967 |
// to wait for more events. Snap ASAP on the next tick. |
| 5968 |
// Also, because there's some remaining momentum we'll bias the snap in the |
| 5969 |
// direction of the ongoing scroll because it's better UX for the scroll to snap |
| 5970 |
// in the same direction as the scroll instead of reversing to snap. Therefore, |
| 5971 |
// if it's already scrolled more than 20% in the current direction, keep going. |
| 5972 |
var snapToThreshold = delta > 0 ? 0.8 : 0.2; |
| 5973 |
swiper.mousewheel.lastEventBeforeSnap = _newEvent; |
| 5974 |
|
| 5975 |
_recentWheelEvents.splice(0); |
| 5976 |
|
| 5977 |
swiper.mousewheel.timeout = nextTick(function () { |
| 5978 |
swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold); |
| 5979 |
}, 0); // no delay; move on next tick |
| 5980 |
} |
| 5981 |
|
| 5982 |
if (!swiper.mousewheel.timeout) { |
| 5983 |
// if we get here, then we haven't detected the end of a momentum scroll, so |
| 5984 |
// we'll consider a scroll "complete" when there haven't been any wheel events |
| 5985 |
// for 500ms. |
| 5986 |
swiper.mousewheel.timeout = nextTick(function () { |
| 5987 |
var snapToThreshold = 0.5; |
| 5988 |
swiper.mousewheel.lastEventBeforeSnap = _newEvent; |
| 5989 |
|
| 5990 |
_recentWheelEvents.splice(0); |
| 5991 |
|
| 5992 |
swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold); |
| 5993 |
}, 500); |
| 5994 |
} |
| 5995 |
} // Emit event |
| 5996 |
|
| 5997 |
|
| 5998 |
if (!ignoreWheelEvents) swiper.emit('scroll', e); // Stop autoplay |
| 5999 |
|
| 6000 |
if (swiper.params.autoplay && swiper.params.autoplayDisableOnInteraction) swiper.autoplay.stop(); // Return page scroll on edge positions |
| 6001 |
|
| 6002 |
if (position === swiper.minTranslate() || position === swiper.maxTranslate()) return true; |
| 6003 |
} |
| 6004 |
} |
| 6005 |
|
| 6006 |
if (e.preventDefault) e.preventDefault();else e.returnValue = false; |
| 6007 |
return false; |
| 6008 |
}, |
| 6009 |
animateSlider: function animateSlider(newEvent) { |
| 6010 |
var swiper = this; |
| 6011 |
var window = getWindow(); |
| 6012 |
|
| 6013 |
if (this.params.mousewheel.thresholdDelta && newEvent.delta < this.params.mousewheel.thresholdDelta) { |
| 6014 |
// Prevent if delta of wheel scroll delta is below configured threshold |
| 6015 |
return false; |
| 6016 |
} |
| 6017 |
|
| 6018 |
if (this.params.mousewheel.thresholdTime && now() - swiper.mousewheel.lastScrollTime < this.params.mousewheel.thresholdTime) { |
| 6019 |
// Prevent if time between scrolls is below configured threshold |
| 6020 |
return false; |
| 6021 |
} // If the movement is NOT big enough and |
| 6022 |
// if the last time the user scrolled was too close to the current one (avoid continuously triggering the slider): |
| 6023 |
// Don't go any further (avoid insignificant scroll movement). |
| 6024 |
|
| 6025 |
|
| 6026 |
if (newEvent.delta >= 6 && now() - swiper.mousewheel.lastScrollTime < 60) { |
| 6027 |
// Return false as a default |
| 6028 |
return true; |
| 6029 |
} // If user is scrolling towards the end: |
| 6030 |
// If the slider hasn't hit the latest slide or |
| 6031 |
// if the slider is a loop and |
| 6032 |
// if the slider isn't moving right now: |
| 6033 |
// Go to next slide and |
| 6034 |
// emit a scroll event. |
| 6035 |
// Else (the user is scrolling towards the beginning) and |
| 6036 |
// if the slider hasn't hit the first slide or |
| 6037 |
// if the slider is a loop and |
| 6038 |
// if the slider isn't moving right now: |
| 6039 |
// Go to prev slide and |
| 6040 |
// emit a scroll event. |
| 6041 |
|
| 6042 |
|
| 6043 |
if (newEvent.direction < 0) { |
| 6044 |
if ((!swiper.isEnd || swiper.params.loop) && !swiper.animating) { |
| 6045 |
swiper.slideNext(); |
| 6046 |
swiper.emit('scroll', newEvent.raw); |
| 6047 |
} |
| 6048 |
} else if ((!swiper.isBeginning || swiper.params.loop) && !swiper.animating) { |
| 6049 |
swiper.slidePrev(); |
| 6050 |
swiper.emit('scroll', newEvent.raw); |
| 6051 |
} // If you got here is because an animation has been triggered so store the current time |
| 6052 |
|
| 6053 |
|
| 6054 |
swiper.mousewheel.lastScrollTime = new window.Date().getTime(); // Return false as a default |
| 6055 |
|
| 6056 |
return false; |
| 6057 |
}, |
| 6058 |
releaseScroll: function releaseScroll(newEvent) { |
| 6059 |
var swiper = this; |
| 6060 |
var params = swiper.params.mousewheel; |
| 6061 |
|
| 6062 |
if (newEvent.direction < 0) { |
| 6063 |
if (swiper.isEnd && !swiper.params.loop && params.releaseOnEdges) { |
| 6064 |
// Return true to animate scroll on edges |
| 6065 |
return true; |
| 6066 |
} |
| 6067 |
} else if (swiper.isBeginning && !swiper.params.loop && params.releaseOnEdges) { |
| 6068 |
// Return true to animate scroll on edges |
| 6069 |
return true; |
| 6070 |
} |
| 6071 |
|
| 6072 |
return false; |
| 6073 |
}, |
| 6074 |
enable: function enable() { |
| 6075 |
var swiper = this; |
| 6076 |
var event = Mousewheel.event(); |
| 6077 |
|
| 6078 |
if (swiper.params.cssMode) { |
| 6079 |
swiper.wrapperEl.removeEventListener(event, swiper.mousewheel.handle); |
| 6080 |
return true; |
| 6081 |
} |
| 6082 |
|
| 6083 |
if (!event) return false; |
| 6084 |
if (swiper.mousewheel.enabled) return false; |
| 6085 |
var target = swiper.$el; |
| 6086 |
|
| 6087 |
if (swiper.params.mousewheel.eventsTarget !== 'container') { |
| 6088 |
target = $(swiper.params.mousewheel.eventsTarget); |
| 6089 |
} |
| 6090 |
|
| 6091 |
target.on('mouseenter', swiper.mousewheel.handleMouseEnter); |
| 6092 |
target.on('mouseleave', swiper.mousewheel.handleMouseLeave); |
| 6093 |
target.on(event, swiper.mousewheel.handle); |
| 6094 |
swiper.mousewheel.enabled = true; |
| 6095 |
return true; |
| 6096 |
}, |
| 6097 |
disable: function disable() { |
| 6098 |
var swiper = this; |
| 6099 |
var event = Mousewheel.event(); |
| 6100 |
|
| 6101 |
if (swiper.params.cssMode) { |
| 6102 |
swiper.wrapperEl.addEventListener(event, swiper.mousewheel.handle); |
| 6103 |
return true; |
| 6104 |
} |
| 6105 |
|
| 6106 |
if (!event) return false; |
| 6107 |
if (!swiper.mousewheel.enabled) return false; |
| 6108 |
var target = swiper.$el; |
| 6109 |
|
| 6110 |
if (swiper.params.mousewheel.eventsTarget !== 'container') { |
| 6111 |
target = $(swiper.params.mousewheel.eventsTarget); |
| 6112 |
} |
| 6113 |
|
| 6114 |
target.off(event, swiper.mousewheel.handle); |
| 6115 |
swiper.mousewheel.enabled = false; |
| 6116 |
return true; |
| 6117 |
} |
| 6118 |
}; |
| 6119 |
var Mousewheel$1 = { |
| 6120 |
name: 'mousewheel', |
| 6121 |
params: { |
| 6122 |
mousewheel: { |
| 6123 |
enabled: false, |
| 6124 |
releaseOnEdges: false, |
| 6125 |
invert: false, |
| 6126 |
forceToAxis: false, |
| 6127 |
sensitivity: 1, |
| 6128 |
eventsTarget: 'container', |
| 6129 |
thresholdDelta: null, |
| 6130 |
thresholdTime: null |
| 6131 |
} |
| 6132 |
}, |
| 6133 |
create: function create() { |
| 6134 |
var swiper = this; |
| 6135 |
bindModuleMethods(swiper, { |
| 6136 |
mousewheel: { |
| 6137 |
enabled: false, |
| 6138 |
lastScrollTime: now(), |
| 6139 |
lastEventBeforeSnap: undefined, |
| 6140 |
recentWheelEvents: [], |
| 6141 |
enable: Mousewheel.enable, |
| 6142 |
disable: Mousewheel.disable, |
| 6143 |
handle: Mousewheel.handle, |
| 6144 |
handleMouseEnter: Mousewheel.handleMouseEnter, |
| 6145 |
handleMouseLeave: Mousewheel.handleMouseLeave, |
| 6146 |
animateSlider: Mousewheel.animateSlider, |
| 6147 |
releaseScroll: Mousewheel.releaseScroll |
| 6148 |
} |
| 6149 |
}); |
| 6150 |
}, |
| 6151 |
on: { |
| 6152 |
init: function init(swiper) { |
| 6153 |
if (!swiper.params.mousewheel.enabled && swiper.params.cssMode) { |
| 6154 |
swiper.mousewheel.disable(); |
| 6155 |
} |
| 6156 |
|
| 6157 |
if (swiper.params.mousewheel.enabled) swiper.mousewheel.enable(); |
| 6158 |
}, |
| 6159 |
destroy: function destroy(swiper) { |
| 6160 |
if (swiper.params.cssMode) { |
| 6161 |
swiper.mousewheel.enable(); |
| 6162 |
} |
| 6163 |
|
| 6164 |
if (swiper.mousewheel.enabled) swiper.mousewheel.disable(); |
| 6165 |
} |
| 6166 |
} |
| 6167 |
}; |
| 6168 |
|
| 6169 |
var Navigation = { |
| 6170 |
toggleEl: function toggleEl($el, disabled) { |
| 6171 |
$el[disabled ? 'addClass' : 'removeClass'](this.params.navigation.disabledClass); |
| 6172 |
if ($el[0] && $el[0].tagName === 'BUTTON') $el[0].disabled = disabled; |
| 6173 |
}, |
| 6174 |
update: function update() { |
| 6175 |
// Update Navigation Buttons |
| 6176 |
var swiper = this; |
| 6177 |
var params = swiper.params.navigation; |
| 6178 |
var toggleEl = swiper.navigation.toggleEl; |
| 6179 |
if (swiper.params.loop) return; |
| 6180 |
var _swiper$navigation = swiper.navigation, |
| 6181 |
$nextEl = _swiper$navigation.$nextEl, |
| 6182 |
$prevEl = _swiper$navigation.$prevEl; |
| 6183 |
|
| 6184 |
if ($prevEl && $prevEl.length > 0) { |
| 6185 |
if (swiper.isBeginning) { |
| 6186 |
toggleEl($prevEl, true); |
| 6187 |
} else { |
| 6188 |
toggleEl($prevEl, false); |
| 6189 |
} |
| 6190 |
|
| 6191 |
$prevEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); |
| 6192 |
} |
| 6193 |
|
| 6194 |
if ($nextEl && $nextEl.length > 0) { |
| 6195 |
if (swiper.isEnd) { |
| 6196 |
toggleEl($nextEl, true); |
| 6197 |
} else { |
| 6198 |
toggleEl($nextEl, false); |
| 6199 |
} |
| 6200 |
|
| 6201 |
$nextEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); |
| 6202 |
} |
| 6203 |
}, |
| 6204 |
onPrevClick: function onPrevClick(e) { |
| 6205 |
var swiper = this; |
| 6206 |
e.preventDefault(); |
| 6207 |
if (swiper.isBeginning && !swiper.params.loop) return; |
| 6208 |
swiper.slidePrev(); |
| 6209 |
}, |
| 6210 |
onNextClick: function onNextClick(e) { |
| 6211 |
var swiper = this; |
| 6212 |
e.preventDefault(); |
| 6213 |
if (swiper.isEnd && !swiper.params.loop) return; |
| 6214 |
swiper.slideNext(); |
| 6215 |
}, |
| 6216 |
init: function init() { |
| 6217 |
var swiper = this; |
| 6218 |
var params = swiper.params.navigation; |
| 6219 |
if (!(params.nextEl || params.prevEl)) return; |
| 6220 |
var $nextEl; |
| 6221 |
var $prevEl; |
| 6222 |
|
| 6223 |
if (params.nextEl) { |
| 6224 |
$nextEl = $(params.nextEl); |
| 6225 |
|
| 6226 |
if (swiper.params.uniqueNavElements && typeof params.nextEl === 'string' && $nextEl.length > 1 && swiper.$el.find(params.nextEl).length === 1) { |
| 6227 |
$nextEl = swiper.$el.find(params.nextEl); |
| 6228 |
} |
| 6229 |
} |
| 6230 |
|
| 6231 |
if (params.prevEl) { |
| 6232 |
$prevEl = $(params.prevEl); |
| 6233 |
|
| 6234 |
if (swiper.params.uniqueNavElements && typeof params.prevEl === 'string' && $prevEl.length > 1 && swiper.$el.find(params.prevEl).length === 1) { |
| 6235 |
$prevEl = swiper.$el.find(params.prevEl); |
| 6236 |
} |
| 6237 |
} |
| 6238 |
|
| 6239 |
if ($nextEl && $nextEl.length > 0) { |
| 6240 |
$nextEl.on('click', swiper.navigation.onNextClick); |
| 6241 |
} |
| 6242 |
|
| 6243 |
if ($prevEl && $prevEl.length > 0) { |
| 6244 |
$prevEl.on('click', swiper.navigation.onPrevClick); |
| 6245 |
} |
| 6246 |
|
| 6247 |
extend(swiper.navigation, { |
| 6248 |
$nextEl: $nextEl, |
| 6249 |
nextEl: $nextEl && $nextEl[0], |
| 6250 |
$prevEl: $prevEl, |
| 6251 |
prevEl: $prevEl && $prevEl[0] |
| 6252 |
}); |
| 6253 |
}, |
| 6254 |
destroy: function destroy() { |
| 6255 |
var swiper = this; |
| 6256 |
var _swiper$navigation2 = swiper.navigation, |
| 6257 |
$nextEl = _swiper$navigation2.$nextEl, |
| 6258 |
$prevEl = _swiper$navigation2.$prevEl; |
| 6259 |
|
| 6260 |
if ($nextEl && $nextEl.length) { |
| 6261 |
$nextEl.off('click', swiper.navigation.onNextClick); |
| 6262 |
$nextEl.removeClass(swiper.params.navigation.disabledClass); |
| 6263 |
} |
| 6264 |
|
| 6265 |
if ($prevEl && $prevEl.length) { |
| 6266 |
$prevEl.off('click', swiper.navigation.onPrevClick); |
| 6267 |
$prevEl.removeClass(swiper.params.navigation.disabledClass); |
| 6268 |
} |
| 6269 |
} |
| 6270 |
}; |
| 6271 |
var Navigation$1 = { |
| 6272 |
name: 'navigation', |
| 6273 |
params: { |
| 6274 |
navigation: { |
| 6275 |
nextEl: null, |
| 6276 |
prevEl: null, |
| 6277 |
hideOnClick: false, |
| 6278 |
disabledClass: 'swiper-button-disabled', |
| 6279 |
hiddenClass: 'swiper-button-hidden', |
| 6280 |
lockClass: 'swiper-button-lock' |
| 6281 |
} |
| 6282 |
}, |
| 6283 |
create: function create() { |
| 6284 |
var swiper = this; |
| 6285 |
bindModuleMethods(swiper, { |
| 6286 |
navigation: _extends({}, Navigation) |
| 6287 |
}); |
| 6288 |
}, |
| 6289 |
on: { |
| 6290 |
init: function init(swiper) { |
| 6291 |
swiper.navigation.init(); |
| 6292 |
swiper.navigation.update(); |
| 6293 |
}, |
| 6294 |
toEdge: function toEdge(swiper) { |
| 6295 |
swiper.navigation.update(); |
| 6296 |
}, |
| 6297 |
fromEdge: function fromEdge(swiper) { |
| 6298 |
swiper.navigation.update(); |
| 6299 |
}, |
| 6300 |
destroy: function destroy(swiper) { |
| 6301 |
swiper.navigation.destroy(); |
| 6302 |
}, |
| 6303 |
click: function click(swiper, e) { |
| 6304 |
var _swiper$navigation3 = swiper.navigation, |
| 6305 |
$nextEl = _swiper$navigation3.$nextEl, |
| 6306 |
$prevEl = _swiper$navigation3.$prevEl; |
| 6307 |
var targetEl = e.target; |
| 6308 |
|
| 6309 |
if (swiper.params.navigation.hideOnClick && !$(targetEl).is($prevEl) && !$(targetEl).is($nextEl)) { |
| 6310 |
if (swiper.pagination && swiper.params.pagination && swiper.params.pagination.clickable && (swiper.pagination.el === targetEl || swiper.pagination.el.contains(targetEl))) return; |
| 6311 |
var isHidden; |
| 6312 |
|
| 6313 |
if ($nextEl) { |
| 6314 |
isHidden = $nextEl.hasClass(swiper.params.navigation.hiddenClass); |
| 6315 |
} else if ($prevEl) { |
| 6316 |
isHidden = $prevEl.hasClass(swiper.params.navigation.hiddenClass); |
| 6317 |
} |
| 6318 |
|
| 6319 |
if (isHidden === true) { |
| 6320 |
swiper.emit('navigationShow'); |
| 6321 |
} else { |
| 6322 |
swiper.emit('navigationHide'); |
| 6323 |
} |
| 6324 |
|
| 6325 |
if ($nextEl) { |
| 6326 |
$nextEl.toggleClass(swiper.params.navigation.hiddenClass); |
| 6327 |
} |
| 6328 |
|
| 6329 |
if ($prevEl) { |
| 6330 |
$prevEl.toggleClass(swiper.params.navigation.hiddenClass); |
| 6331 |
} |
| 6332 |
} |
| 6333 |
} |
| 6334 |
} |
| 6335 |
}; |
| 6336 |
|
| 6337 |
var Pagination = { |
| 6338 |
update: function update() { |
| 6339 |
// Render || Update Pagination bullets/items |
| 6340 |
var swiper = this; |
| 6341 |
var rtl = swiper.rtl; |
| 6342 |
var params = swiper.params.pagination; |
| 6343 |
if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) return; |
| 6344 |
var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; |
| 6345 |
var $el = swiper.pagination.$el; // Current/Total |
| 6346 |
|
| 6347 |
var current; |
| 6348 |
var total = swiper.params.loop ? Math.ceil((slidesLength - swiper.loopedSlides * 2) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; |
| 6349 |
|
| 6350 |
if (swiper.params.loop) { |
| 6351 |
current = Math.ceil((swiper.activeIndex - swiper.loopedSlides) / swiper.params.slidesPerGroup); |
| 6352 |
|
| 6353 |
if (current > slidesLength - 1 - swiper.loopedSlides * 2) { |
| 6354 |
current -= slidesLength - swiper.loopedSlides * 2; |
| 6355 |
} |
| 6356 |
|
| 6357 |
if (current > total - 1) current -= total; |
| 6358 |
if (current < 0 && swiper.params.paginationType !== 'bullets') current = total + current; |
| 6359 |
} else if (typeof swiper.snapIndex !== 'undefined') { |
| 6360 |
current = swiper.snapIndex; |
| 6361 |
} else { |
| 6362 |
current = swiper.activeIndex || 0; |
| 6363 |
} // Types |
| 6364 |
|
| 6365 |
|
| 6366 |
if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) { |
| 6367 |
var bullets = swiper.pagination.bullets; |
| 6368 |
var firstIndex; |
| 6369 |
var lastIndex; |
| 6370 |
var midIndex; |
| 6371 |
|
| 6372 |
if (params.dynamicBullets) { |
| 6373 |
swiper.pagination.bulletSize = bullets.eq(0)[swiper.isHorizontal() ? 'outerWidth' : 'outerHeight'](true); |
| 6374 |
$el.css(swiper.isHorizontal() ? 'width' : 'height', swiper.pagination.bulletSize * (params.dynamicMainBullets + 4) + "px"); |
| 6375 |
|
| 6376 |
if (params.dynamicMainBullets > 1 && swiper.previousIndex !== undefined) { |
| 6377 |
swiper.pagination.dynamicBulletIndex += current - swiper.previousIndex; |
| 6378 |
|
| 6379 |
if (swiper.pagination.dynamicBulletIndex > params.dynamicMainBullets - 1) { |
| 6380 |
swiper.pagination.dynamicBulletIndex = params.dynamicMainBullets - 1; |
| 6381 |
} else if (swiper.pagination.dynamicBulletIndex < 0) { |
| 6382 |
swiper.pagination.dynamicBulletIndex = 0; |
| 6383 |
} |
| 6384 |
} |
| 6385 |
|
| 6386 |
firstIndex = current - swiper.pagination.dynamicBulletIndex; |
| 6387 |
lastIndex = firstIndex + (Math.min(bullets.length, params.dynamicMainBullets) - 1); |
| 6388 |
midIndex = (lastIndex + firstIndex) / 2; |
| 6389 |
} |
| 6390 |
|
| 6391 |
bullets.removeClass(params.bulletActiveClass + " " + params.bulletActiveClass + "-next " + params.bulletActiveClass + "-next-next " + params.bulletActiveClass + "-prev " + params.bulletActiveClass + "-prev-prev " + params.bulletActiveClass + "-main"); |
| 6392 |
|
| 6393 |
if ($el.length > 1) { |
| 6394 |
bullets.each(function (bullet) { |
| 6395 |
var $bullet = $(bullet); |
| 6396 |
var bulletIndex = $bullet.index(); |
| 6397 |
|
| 6398 |
if (bulletIndex === current) { |
| 6399 |
$bullet.addClass(params.bulletActiveClass); |
| 6400 |
} |
| 6401 |
|
| 6402 |
if (params.dynamicBullets) { |
| 6403 |
if (bulletIndex >= firstIndex && bulletIndex <= lastIndex) { |
| 6404 |
$bullet.addClass(params.bulletActiveClass + "-main"); |
| 6405 |
} |
| 6406 |
|
| 6407 |
if (bulletIndex === firstIndex) { |
| 6408 |
$bullet.prev().addClass(params.bulletActiveClass + "-prev").prev().addClass(params.bulletActiveClass + "-prev-prev"); |
| 6409 |
} |
| 6410 |
|
| 6411 |
if (bulletIndex === lastIndex) { |
| 6412 |
$bullet.next().addClass(params.bulletActiveClass + "-next").next().addClass(params.bulletActiveClass + "-next-next"); |
| 6413 |
} |
| 6414 |
} |
| 6415 |
}); |
| 6416 |
} else { |
| 6417 |
var $bullet = bullets.eq(current); |
| 6418 |
var bulletIndex = $bullet.index(); |
| 6419 |
$bullet.addClass(params.bulletActiveClass); |
| 6420 |
|
| 6421 |
if (params.dynamicBullets) { |
| 6422 |
var $firstDisplayedBullet = bullets.eq(firstIndex); |
| 6423 |
var $lastDisplayedBullet = bullets.eq(lastIndex); |
| 6424 |
|
| 6425 |
for (var i = firstIndex; i <= lastIndex; i += 1) { |
| 6426 |
bullets.eq(i).addClass(params.bulletActiveClass + "-main"); |
| 6427 |
} |
| 6428 |
|
| 6429 |
if (swiper.params.loop) { |
| 6430 |
if (bulletIndex >= bullets.length - params.dynamicMainBullets) { |
| 6431 |
for (var _i = params.dynamicMainBullets; _i >= 0; _i -= 1) { |
| 6432 |
bullets.eq(bullets.length - _i).addClass(params.bulletActiveClass + "-main"); |
| 6433 |
} |
| 6434 |
|
| 6435 |
bullets.eq(bullets.length - params.dynamicMainBullets - 1).addClass(params.bulletActiveClass + "-prev"); |
| 6436 |
} else { |
| 6437 |
$firstDisplayedBullet.prev().addClass(params.bulletActiveClass + "-prev").prev().addClass(params.bulletActiveClass + "-prev-prev"); |
| 6438 |
$lastDisplayedBullet.next().addClass(params.bulletActiveClass + "-next").next().addClass(params.bulletActiveClass + "-next-next"); |
| 6439 |
} |
| 6440 |
} else { |
| 6441 |
$firstDisplayedBullet.prev().addClass(params.bulletActiveClass + "-prev").prev().addClass(params.bulletActiveClass + "-prev-prev"); |
| 6442 |
$lastDisplayedBullet.next().addClass(params.bulletActiveClass + "-next").next().addClass(params.bulletActiveClass + "-next-next"); |
| 6443 |
} |
| 6444 |
} |
| 6445 |
} |
| 6446 |
|
| 6447 |
if (params.dynamicBullets) { |
| 6448 |
var dynamicBulletsLength = Math.min(bullets.length, params.dynamicMainBullets + 4); |
| 6449 |
var bulletsOffset = (swiper.pagination.bulletSize * dynamicBulletsLength - swiper.pagination.bulletSize) / 2 - midIndex * swiper.pagination.bulletSize; |
| 6450 |
var offsetProp = rtl ? 'right' : 'left'; |
| 6451 |
bullets.css(swiper.isHorizontal() ? offsetProp : 'top', bulletsOffset + "px"); |
| 6452 |
} |
| 6453 |
} |
| 6454 |
|
| 6455 |
if (params.type === 'fraction') { |
| 6456 |
$el.find(classesToSelector(params.currentClass)).text(params.formatFractionCurrent(current + 1)); |
| 6457 |
$el.find(classesToSelector(params.totalClass)).text(params.formatFractionTotal(total)); |
| 6458 |
} |
| 6459 |
|
| 6460 |
if (params.type === 'progressbar') { |
| 6461 |
var progressbarDirection; |
| 6462 |
|
| 6463 |
if (params.progressbarOpposite) { |
| 6464 |
progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal'; |
| 6465 |
} else { |
| 6466 |
progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical'; |
| 6467 |
} |
| 6468 |
|
| 6469 |
var scale = (current + 1) / total; |
| 6470 |
var scaleX = 1; |
| 6471 |
var scaleY = 1; |
| 6472 |
|
| 6473 |
if (progressbarDirection === 'horizontal') { |
| 6474 |
scaleX = scale; |
| 6475 |
} else { |
| 6476 |
scaleY = scale; |
| 6477 |
} |
| 6478 |
|
| 6479 |
$el.find(classesToSelector(params.progressbarFillClass)).transform("translate3d(0,0,0) scaleX(" + scaleX + ") scaleY(" + scaleY + ")").transition(swiper.params.speed); |
| 6480 |
} |
| 6481 |
|
| 6482 |
if (params.type === 'custom' && params.renderCustom) { |
| 6483 |
$el.html(params.renderCustom(swiper, current + 1, total)); |
| 6484 |
swiper.emit('paginationRender', $el[0]); |
| 6485 |
} else { |
| 6486 |
swiper.emit('paginationUpdate', $el[0]); |
| 6487 |
} |
| 6488 |
|
| 6489 |
$el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); |
| 6490 |
}, |
| 6491 |
render: function render() { |
| 6492 |
// Render Container |
| 6493 |
var swiper = this; |
| 6494 |
var params = swiper.params.pagination; |
| 6495 |
if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) return; |
| 6496 |
var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; |
| 6497 |
var $el = swiper.pagination.$el; |
| 6498 |
var paginationHTML = ''; |
| 6499 |
|
| 6500 |
if (params.type === 'bullets') { |
| 6501 |
var numberOfBullets = swiper.params.loop ? Math.ceil((slidesLength - swiper.loopedSlides * 2) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; |
| 6502 |
|
| 6503 |
if (swiper.params.freeMode && !swiper.params.loop && numberOfBullets > slidesLength) { |
| 6504 |
numberOfBullets = slidesLength; |
| 6505 |
} |
| 6506 |
|
| 6507 |
for (var i = 0; i < numberOfBullets; i += 1) { |
| 6508 |
if (params.renderBullet) { |
| 6509 |
paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass); |
| 6510 |
} else { |
| 6511 |
paginationHTML += "<" + params.bulletElement + " class=\"" + params.bulletClass + "\"></" + params.bulletElement + ">"; |
| 6512 |
} |
| 6513 |
} |
| 6514 |
|
| 6515 |
$el.html(paginationHTML); |
| 6516 |
swiper.pagination.bullets = $el.find(classesToSelector(params.bulletClass)); |
| 6517 |
} |
| 6518 |
|
| 6519 |
if (params.type === 'fraction') { |
| 6520 |
if (params.renderFraction) { |
| 6521 |
paginationHTML = params.renderFraction.call(swiper, params.currentClass, params.totalClass); |
| 6522 |
} else { |
| 6523 |
paginationHTML = "<span class=\"" + params.currentClass + "\"></span>" + ' / ' + ("<span class=\"" + params.totalClass + "\"></span>"); |
| 6524 |
} |
| 6525 |
|
| 6526 |
$el.html(paginationHTML); |
| 6527 |
} |
| 6528 |
|
| 6529 |
if (params.type === 'progressbar') { |
| 6530 |
if (params.renderProgressbar) { |
| 6531 |
paginationHTML = params.renderProgressbar.call(swiper, params.progressbarFillClass); |
| 6532 |
} else { |
| 6533 |
paginationHTML = "<span class=\"" + params.progressbarFillClass + "\"></span>"; |
| 6534 |
} |
| 6535 |
|
| 6536 |
$el.html(paginationHTML); |
| 6537 |
} |
| 6538 |
|
| 6539 |
if (params.type !== 'custom') { |
| 6540 |
swiper.emit('paginationRender', swiper.pagination.$el[0]); |
| 6541 |
} |
| 6542 |
}, |
| 6543 |
init: function init() { |
| 6544 |
var swiper = this; |
| 6545 |
var params = swiper.params.pagination; |
| 6546 |
if (!params.el) return; |
| 6547 |
var $el = $(params.el); |
| 6548 |
if ($el.length === 0) return; |
| 6549 |
|
| 6550 |
if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1) { |
| 6551 |
$el = swiper.$el.find(params.el); |
| 6552 |
} |
| 6553 |
|
| 6554 |
if (params.type === 'bullets' && params.clickable) { |
| 6555 |
$el.addClass(params.clickableClass); |
| 6556 |
} |
| 6557 |
|
| 6558 |
$el.addClass(params.modifierClass + params.type); |
| 6559 |
|
| 6560 |
if (params.type === 'bullets' && params.dynamicBullets) { |
| 6561 |
$el.addClass("" + params.modifierClass + params.type + "-dynamic"); |
| 6562 |
swiper.pagination.dynamicBulletIndex = 0; |
| 6563 |
|
| 6564 |
if (params.dynamicMainBullets < 1) { |
| 6565 |
params.dynamicMainBullets = 1; |
| 6566 |
} |
| 6567 |
} |
| 6568 |
|
| 6569 |
if (params.type === 'progressbar' && params.progressbarOpposite) { |
| 6570 |
$el.addClass(params.progressbarOppositeClass); |
| 6571 |
} |
| 6572 |
|
| 6573 |
if (params.clickable) { |
| 6574 |
$el.on('click', classesToSelector(params.bulletClass), function onClick(e) { |
| 6575 |
e.preventDefault(); |
| 6576 |
var index = $(this).index() * swiper.params.slidesPerGroup; |
| 6577 |
if (swiper.params.loop) index += swiper.loopedSlides; |
| 6578 |
swiper.slideTo(index); |
| 6579 |
}); |
| 6580 |
} |
| 6581 |
|
| 6582 |
extend(swiper.pagination, { |
| 6583 |
$el: $el, |
| 6584 |
el: $el[0] |
| 6585 |
}); |
| 6586 |
}, |
| 6587 |
destroy: function destroy() { |
| 6588 |
var swiper = this; |
| 6589 |
var params = swiper.params.pagination; |
| 6590 |
if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) return; |
| 6591 |
var $el = swiper.pagination.$el; |
| 6592 |
$el.removeClass(params.hiddenClass); |
| 6593 |
$el.removeClass(params.modifierClass + params.type); |
| 6594 |
if (swiper.pagination.bullets) swiper.pagination.bullets.removeClass(params.bulletActiveClass); |
| 6595 |
|
| 6596 |
if (params.clickable) { |
| 6597 |
$el.off('click', classesToSelector(params.bulletClass)); |
| 6598 |
} |
| 6599 |
} |
| 6600 |
}; |
| 6601 |
var Pagination$1 = { |
| 6602 |
name: 'pagination', |
| 6603 |
params: { |
| 6604 |
pagination: { |
| 6605 |
el: null, |
| 6606 |
bulletElement: 'span', |
| 6607 |
clickable: false, |
| 6608 |
hideOnClick: false, |
| 6609 |
renderBullet: null, |
| 6610 |
renderProgressbar: null, |
| 6611 |
renderFraction: null, |
| 6612 |
renderCustom: null, |
| 6613 |
progressbarOpposite: false, |
| 6614 |
type: 'bullets', |
| 6615 |
// 'bullets' or 'progressbar' or 'fraction' or 'custom' |
| 6616 |
dynamicBullets: false, |
| 6617 |
dynamicMainBullets: 1, |
| 6618 |
formatFractionCurrent: function formatFractionCurrent(number) { |
| 6619 |
return number; |
| 6620 |
}, |
| 6621 |
formatFractionTotal: function formatFractionTotal(number) { |
| 6622 |
return number; |
| 6623 |
}, |
| 6624 |
bulletClass: 'swiper-pagination-bullet', |
| 6625 |
bulletActiveClass: 'swiper-pagination-bullet-active', |
| 6626 |
modifierClass: 'swiper-pagination-', |
| 6627 |
// NEW |
| 6628 |
currentClass: 'swiper-pagination-current', |
| 6629 |
totalClass: 'swiper-pagination-total', |
| 6630 |
hiddenClass: 'swiper-pagination-hidden', |
| 6631 |
progressbarFillClass: 'swiper-pagination-progressbar-fill', |
| 6632 |
progressbarOppositeClass: 'swiper-pagination-progressbar-opposite', |
| 6633 |
clickableClass: 'swiper-pagination-clickable', |
| 6634 |
// NEW |
| 6635 |
lockClass: 'swiper-pagination-lock' |
| 6636 |
} |
| 6637 |
}, |
| 6638 |
create: function create() { |
| 6639 |
var swiper = this; |
| 6640 |
bindModuleMethods(swiper, { |
| 6641 |
pagination: _extends({ |
| 6642 |
dynamicBulletIndex: 0 |
| 6643 |
}, Pagination) |
| 6644 |
}); |
| 6645 |
}, |
| 6646 |
on: { |
| 6647 |
init: function init(swiper) { |
| 6648 |
swiper.pagination.init(); |
| 6649 |
swiper.pagination.render(); |
| 6650 |
swiper.pagination.update(); |
| 6651 |
}, |
| 6652 |
activeIndexChange: function activeIndexChange(swiper) { |
| 6653 |
if (swiper.params.loop) { |
| 6654 |
swiper.pagination.update(); |
| 6655 |
} else if (typeof swiper.snapIndex === 'undefined') { |
| 6656 |
swiper.pagination.update(); |
| 6657 |
} |
| 6658 |
}, |
| 6659 |
snapIndexChange: function snapIndexChange(swiper) { |
| 6660 |
if (!swiper.params.loop) { |
| 6661 |
swiper.pagination.update(); |
| 6662 |
} |
| 6663 |
}, |
| 6664 |
slidesLengthChange: function slidesLengthChange(swiper) { |
| 6665 |
if (swiper.params.loop) { |
| 6666 |
swiper.pagination.render(); |
| 6667 |
swiper.pagination.update(); |
| 6668 |
} |
| 6669 |
}, |
| 6670 |
snapGridLengthChange: function snapGridLengthChange(swiper) { |
| 6671 |
if (!swiper.params.loop) { |
| 6672 |
swiper.pagination.render(); |
| 6673 |
swiper.pagination.update(); |
| 6674 |
} |
| 6675 |
}, |
| 6676 |
destroy: function destroy(swiper) { |
| 6677 |
swiper.pagination.destroy(); |
| 6678 |
}, |
| 6679 |
click: function click(swiper, e) { |
| 6680 |
var targetEl = e.target; |
| 6681 |
|
| 6682 |
if (swiper.params.pagination.el && swiper.params.pagination.hideOnClick && swiper.pagination.$el.length > 0 && !$(targetEl).hasClass(swiper.params.pagination.bulletClass)) { |
| 6683 |
if (swiper.navigation && (swiper.navigation.nextEl && targetEl === swiper.navigation.nextEl || swiper.navigation.prevEl && targetEl === swiper.navigation.prevEl)) return; |
| 6684 |
var isHidden = swiper.pagination.$el.hasClass(swiper.params.pagination.hiddenClass); |
| 6685 |
|
| 6686 |
if (isHidden === true) { |
| 6687 |
swiper.emit('paginationShow'); |
| 6688 |
} else { |
| 6689 |
swiper.emit('paginationHide'); |
| 6690 |
} |
| 6691 |
|
| 6692 |
swiper.pagination.$el.toggleClass(swiper.params.pagination.hiddenClass); |
| 6693 |
} |
| 6694 |
} |
| 6695 |
} |
| 6696 |
}; |
| 6697 |
|
| 6698 |
var Scrollbar = { |
| 6699 |
setTranslate: function setTranslate() { |
| 6700 |
var swiper = this; |
| 6701 |
if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; |
| 6702 |
var scrollbar = swiper.scrollbar, |
| 6703 |
rtl = swiper.rtlTranslate, |
| 6704 |
progress = swiper.progress; |
| 6705 |
var dragSize = scrollbar.dragSize, |
| 6706 |
trackSize = scrollbar.trackSize, |
| 6707 |
$dragEl = scrollbar.$dragEl, |
| 6708 |
$el = scrollbar.$el; |
| 6709 |
var params = swiper.params.scrollbar; |
| 6710 |
var newSize = dragSize; |
| 6711 |
var newPos = (trackSize - dragSize) * progress; |
| 6712 |
|
| 6713 |
if (rtl) { |
| 6714 |
newPos = -newPos; |
| 6715 |
|
| 6716 |
if (newPos > 0) { |
| 6717 |
newSize = dragSize - newPos; |
| 6718 |
newPos = 0; |
| 6719 |
} else if (-newPos + dragSize > trackSize) { |
| 6720 |
newSize = trackSize + newPos; |
| 6721 |
} |
| 6722 |
} else if (newPos < 0) { |
| 6723 |
newSize = dragSize + newPos; |
| 6724 |
newPos = 0; |
| 6725 |
} else if (newPos + dragSize > trackSize) { |
| 6726 |
newSize = trackSize - newPos; |
| 6727 |
} |
| 6728 |
|
| 6729 |
if (swiper.isHorizontal()) { |
| 6730 |
$dragEl.transform("translate3d(" + newPos + "px, 0, 0)"); |
| 6731 |
$dragEl[0].style.width = newSize + "px"; |
| 6732 |
} else { |
| 6733 |
$dragEl.transform("translate3d(0px, " + newPos + "px, 0)"); |
| 6734 |
$dragEl[0].style.height = newSize + "px"; |
| 6735 |
} |
| 6736 |
|
| 6737 |
if (params.hide) { |
| 6738 |
clearTimeout(swiper.scrollbar.timeout); |
| 6739 |
$el[0].style.opacity = 1; |
| 6740 |
swiper.scrollbar.timeout = setTimeout(function () { |
| 6741 |
$el[0].style.opacity = 0; |
| 6742 |
$el.transition(400); |
| 6743 |
}, 1000); |
| 6744 |
} |
| 6745 |
}, |
| 6746 |
setTransition: function setTransition(duration) { |
| 6747 |
var swiper = this; |
| 6748 |
if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; |
| 6749 |
swiper.scrollbar.$dragEl.transition(duration); |
| 6750 |
}, |
| 6751 |
updateSize: function updateSize() { |
| 6752 |
var swiper = this; |
| 6753 |
if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; |
| 6754 |
var scrollbar = swiper.scrollbar; |
| 6755 |
var $dragEl = scrollbar.$dragEl, |
| 6756 |
$el = scrollbar.$el; |
| 6757 |
$dragEl[0].style.width = ''; |
| 6758 |
$dragEl[0].style.height = ''; |
| 6759 |
var trackSize = swiper.isHorizontal() ? $el[0].offsetWidth : $el[0].offsetHeight; |
| 6760 |
var divider = swiper.size / swiper.virtualSize; |
| 6761 |
var moveDivider = divider * (trackSize / swiper.size); |
| 6762 |
var dragSize; |
| 6763 |
|
| 6764 |
if (swiper.params.scrollbar.dragSize === 'auto') { |
| 6765 |
dragSize = trackSize * divider; |
| 6766 |
} else { |
| 6767 |
dragSize = parseInt(swiper.params.scrollbar.dragSize, 10); |
| 6768 |
} |
| 6769 |
|
| 6770 |
if (swiper.isHorizontal()) { |
| 6771 |
$dragEl[0].style.width = dragSize + "px"; |
| 6772 |
} else { |
| 6773 |
$dragEl[0].style.height = dragSize + "px"; |
| 6774 |
} |
| 6775 |
|
| 6776 |
if (divider >= 1) { |
| 6777 |
$el[0].style.display = 'none'; |
| 6778 |
} else { |
| 6779 |
$el[0].style.display = ''; |
| 6780 |
} |
| 6781 |
|
| 6782 |
if (swiper.params.scrollbar.hide) { |
| 6783 |
$el[0].style.opacity = 0; |
| 6784 |
} |
| 6785 |
|
| 6786 |
extend(scrollbar, { |
| 6787 |
trackSize: trackSize, |
| 6788 |
divider: divider, |
| 6789 |
moveDivider: moveDivider, |
| 6790 |
dragSize: dragSize |
| 6791 |
}); |
| 6792 |
scrollbar.$el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](swiper.params.scrollbar.lockClass); |
| 6793 |
}, |
| 6794 |
getPointerPosition: function getPointerPosition(e) { |
| 6795 |
var swiper = this; |
| 6796 |
|
| 6797 |
if (swiper.isHorizontal()) { |
| 6798 |
return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientX : e.clientX; |
| 6799 |
} |
| 6800 |
|
| 6801 |
return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientY : e.clientY; |
| 6802 |
}, |
| 6803 |
setDragPosition: function setDragPosition(e) { |
| 6804 |
var swiper = this; |
| 6805 |
var scrollbar = swiper.scrollbar, |
| 6806 |
rtl = swiper.rtlTranslate; |
| 6807 |
var $el = scrollbar.$el, |
| 6808 |
dragSize = scrollbar.dragSize, |
| 6809 |
trackSize = scrollbar.trackSize, |
| 6810 |
dragStartPos = scrollbar.dragStartPos; |
| 6811 |
var positionRatio; |
| 6812 |
positionRatio = (scrollbar.getPointerPosition(e) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top'] - (dragStartPos !== null ? dragStartPos : dragSize / 2)) / (trackSize - dragSize); |
| 6813 |
positionRatio = Math.max(Math.min(positionRatio, 1), 0); |
| 6814 |
|
| 6815 |
if (rtl) { |
| 6816 |
positionRatio = 1 - positionRatio; |
| 6817 |
} |
| 6818 |
|
| 6819 |
var position = swiper.minTranslate() + (swiper.maxTranslate() - swiper.minTranslate()) * positionRatio; |
| 6820 |
swiper.updateProgress(position); |
| 6821 |
swiper.setTranslate(position); |
| 6822 |
swiper.updateActiveIndex(); |
| 6823 |
swiper.updateSlidesClasses(); |
| 6824 |
}, |
| 6825 |
onDragStart: function onDragStart(e) { |
| 6826 |
var swiper = this; |
| 6827 |
var params = swiper.params.scrollbar; |
| 6828 |
var scrollbar = swiper.scrollbar, |
| 6829 |
$wrapperEl = swiper.$wrapperEl; |
| 6830 |
var $el = scrollbar.$el, |
| 6831 |
$dragEl = scrollbar.$dragEl; |
| 6832 |
swiper.scrollbar.isTouched = true; |
| 6833 |
swiper.scrollbar.dragStartPos = e.target === $dragEl[0] || e.target === $dragEl ? scrollbar.getPointerPosition(e) - e.target.getBoundingClientRect()[swiper.isHorizontal() ? 'left' : 'top'] : null; |
| 6834 |
e.preventDefault(); |
| 6835 |
e.stopPropagation(); |
| 6836 |
$wrapperEl.transition(100); |
| 6837 |
$dragEl.transition(100); |
| 6838 |
scrollbar.setDragPosition(e); |
| 6839 |
clearTimeout(swiper.scrollbar.dragTimeout); |
| 6840 |
$el.transition(0); |
| 6841 |
|
| 6842 |
if (params.hide) { |
| 6843 |
$el.css('opacity', 1); |
| 6844 |
} |
| 6845 |
|
| 6846 |
if (swiper.params.cssMode) { |
| 6847 |
swiper.$wrapperEl.css('scroll-snap-type', 'none'); |
| 6848 |
} |
| 6849 |
|
| 6850 |
swiper.emit('scrollbarDragStart', e); |
| 6851 |
}, |
| 6852 |
onDragMove: function onDragMove(e) { |
| 6853 |
var swiper = this; |
| 6854 |
var scrollbar = swiper.scrollbar, |
| 6855 |
$wrapperEl = swiper.$wrapperEl; |
| 6856 |
var $el = scrollbar.$el, |
| 6857 |
$dragEl = scrollbar.$dragEl; |
| 6858 |
if (!swiper.scrollbar.isTouched) return; |
| 6859 |
if (e.preventDefault) e.preventDefault();else e.returnValue = false; |
| 6860 |
scrollbar.setDragPosition(e); |
| 6861 |
$wrapperEl.transition(0); |
| 6862 |
$el.transition(0); |
| 6863 |
$dragEl.transition(0); |
| 6864 |
swiper.emit('scrollbarDragMove', e); |
| 6865 |
}, |
| 6866 |
onDragEnd: function onDragEnd(e) { |
| 6867 |
var swiper = this; |
| 6868 |
var params = swiper.params.scrollbar; |
| 6869 |
var scrollbar = swiper.scrollbar, |
| 6870 |
$wrapperEl = swiper.$wrapperEl; |
| 6871 |
var $el = scrollbar.$el; |
| 6872 |
if (!swiper.scrollbar.isTouched) return; |
| 6873 |
swiper.scrollbar.isTouched = false; |
| 6874 |
|
| 6875 |
if (swiper.params.cssMode) { |
| 6876 |
swiper.$wrapperEl.css('scroll-snap-type', ''); |
| 6877 |
$wrapperEl.transition(''); |
| 6878 |
} |
| 6879 |
|
| 6880 |
if (params.hide) { |
| 6881 |
clearTimeout(swiper.scrollbar.dragTimeout); |
| 6882 |
swiper.scrollbar.dragTimeout = nextTick(function () { |
| 6883 |
$el.css('opacity', 0); |
| 6884 |
$el.transition(400); |
| 6885 |
}, 1000); |
| 6886 |
} |
| 6887 |
|
| 6888 |
swiper.emit('scrollbarDragEnd', e); |
| 6889 |
|
| 6890 |
if (params.snapOnRelease) { |
| 6891 |
swiper.slideToClosest(); |
| 6892 |
} |
| 6893 |
}, |
| 6894 |
enableDraggable: function enableDraggable() { |
| 6895 |
var swiper = this; |
| 6896 |
if (!swiper.params.scrollbar.el) return; |
| 6897 |
var document = getDocument(); |
| 6898 |
var scrollbar = swiper.scrollbar, |
| 6899 |
touchEventsTouch = swiper.touchEventsTouch, |
| 6900 |
touchEventsDesktop = swiper.touchEventsDesktop, |
| 6901 |
params = swiper.params, |
| 6902 |
support = swiper.support; |
| 6903 |
var $el = scrollbar.$el; |
| 6904 |
var target = $el[0]; |
| 6905 |
var activeListener = support.passiveListener && params.passiveListeners ? { |
| 6906 |
passive: false, |
| 6907 |
capture: false |
| 6908 |
} : false; |
| 6909 |
var passiveListener = support.passiveListener && params.passiveListeners ? { |
| 6910 |
passive: true, |
| 6911 |
capture: false |
| 6912 |
} : false; |
| 6913 |
if (!target) return; |
| 6914 |
|
| 6915 |
if (!support.touch) { |
| 6916 |
target.addEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener); |
| 6917 |
document.addEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener); |
| 6918 |
document.addEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener); |
| 6919 |
} else { |
| 6920 |
target.addEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener); |
| 6921 |
target.addEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener); |
| 6922 |
target.addEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener); |
| 6923 |
} |
| 6924 |
}, |
| 6925 |
disableDraggable: function disableDraggable() { |
| 6926 |
var swiper = this; |
| 6927 |
if (!swiper.params.scrollbar.el) return; |
| 6928 |
var document = getDocument(); |
| 6929 |
var scrollbar = swiper.scrollbar, |
| 6930 |
touchEventsTouch = swiper.touchEventsTouch, |
| 6931 |
touchEventsDesktop = swiper.touchEventsDesktop, |
| 6932 |
params = swiper.params, |
| 6933 |
support = swiper.support; |
| 6934 |
var $el = scrollbar.$el; |
| 6935 |
var target = $el[0]; |
| 6936 |
var activeListener = support.passiveListener && params.passiveListeners ? { |
| 6937 |
passive: false, |
| 6938 |
capture: false |
| 6939 |
} : false; |
| 6940 |
var passiveListener = support.passiveListener && params.passiveListeners ? { |
| 6941 |
passive: true, |
| 6942 |
capture: false |
| 6943 |
} : false; |
| 6944 |
if (!target) return; |
| 6945 |
|
| 6946 |
if (!support.touch) { |
| 6947 |
target.removeEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener); |
| 6948 |
document.removeEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener); |
| 6949 |
document.removeEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener); |
| 6950 |
} else { |
| 6951 |
target.removeEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener); |
| 6952 |
target.removeEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener); |
| 6953 |
target.removeEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener); |
| 6954 |
} |
| 6955 |
}, |
| 6956 |
init: function init() { |
| 6957 |
var swiper = this; |
| 6958 |
if (!swiper.params.scrollbar.el) return; |
| 6959 |
var scrollbar = swiper.scrollbar, |
| 6960 |
$swiperEl = swiper.$el; |
| 6961 |
var params = swiper.params.scrollbar; |
| 6962 |
var $el = $(params.el); |
| 6963 |
|
| 6964 |
if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) { |
| 6965 |
$el = $swiperEl.find(params.el); |
| 6966 |
} |
| 6967 |
|
| 6968 |
var $dragEl = $el.find("." + swiper.params.scrollbar.dragClass); |
| 6969 |
|
| 6970 |
if ($dragEl.length === 0) { |
| 6971 |
$dragEl = $("<div class=\"" + swiper.params.scrollbar.dragClass + "\"></div>"); |
| 6972 |
$el.append($dragEl); |
| 6973 |
} |
| 6974 |
|
| 6975 |
extend(scrollbar, { |
| 6976 |
$el: $el, |
| 6977 |
el: $el[0], |
| 6978 |
$dragEl: $dragEl, |
| 6979 |
dragEl: $dragEl[0] |
| 6980 |
}); |
| 6981 |
|
| 6982 |
if (params.draggable) { |
| 6983 |
scrollbar.enableDraggable(); |
| 6984 |
} |
| 6985 |
}, |
| 6986 |
destroy: function destroy() { |
| 6987 |
var swiper = this; |
| 6988 |
swiper.scrollbar.disableDraggable(); |
| 6989 |
} |
| 6990 |
}; |
| 6991 |
var Scrollbar$1 = { |
| 6992 |
name: 'scrollbar', |
| 6993 |
params: { |
| 6994 |
scrollbar: { |
| 6995 |
el: null, |
| 6996 |
dragSize: 'auto', |
| 6997 |
hide: false, |
| 6998 |
draggable: false, |
| 6999 |
snapOnRelease: true, |
| 7000 |
lockClass: 'swiper-scrollbar-lock', |
| 7001 |
dragClass: 'swiper-scrollbar-drag' |
| 7002 |
} |
| 7003 |
}, |
| 7004 |
create: function create() { |
| 7005 |
var swiper = this; |
| 7006 |
bindModuleMethods(swiper, { |
| 7007 |
scrollbar: _extends({ |
| 7008 |
isTouched: false, |
| 7009 |
timeout: null, |
| 7010 |
dragTimeout: null |
| 7011 |
}, Scrollbar) |
| 7012 |
}); |
| 7013 |
}, |
| 7014 |
on: { |
| 7015 |
init: function init(swiper) { |
| 7016 |
swiper.scrollbar.init(); |
| 7017 |
swiper.scrollbar.updateSize(); |
| 7018 |
swiper.scrollbar.setTranslate(); |
| 7019 |
}, |
| 7020 |
update: function update(swiper) { |
| 7021 |
swiper.scrollbar.updateSize(); |
| 7022 |
}, |
| 7023 |
resize: function resize(swiper) { |
| 7024 |
swiper.scrollbar.updateSize(); |
| 7025 |
}, |
| 7026 |
observerUpdate: function observerUpdate(swiper) { |
| 7027 |
swiper.scrollbar.updateSize(); |
| 7028 |
}, |
| 7029 |
setTranslate: function setTranslate(swiper) { |
| 7030 |
swiper.scrollbar.setTranslate(); |
| 7031 |
}, |
| 7032 |
setTransition: function setTransition(swiper, duration) { |
| 7033 |
swiper.scrollbar.setTransition(duration); |
| 7034 |
}, |
| 7035 |
destroy: function destroy(swiper) { |
| 7036 |
swiper.scrollbar.destroy(); |
| 7037 |
} |
| 7038 |
} |
| 7039 |
}; |
| 7040 |
|
| 7041 |
var Parallax = { |
| 7042 |
setTransform: function setTransform(el, progress) { |
| 7043 |
var swiper = this; |
| 7044 |
var rtl = swiper.rtl; |
| 7045 |
var $el = $(el); |
| 7046 |
var rtlFactor = rtl ? -1 : 1; |
| 7047 |
var p = $el.attr('data-swiper-parallax') || '0'; |
| 7048 |
var x = $el.attr('data-swiper-parallax-x'); |
| 7049 |
var y = $el.attr('data-swiper-parallax-y'); |
| 7050 |
var scale = $el.attr('data-swiper-parallax-scale'); |
| 7051 |
var opacity = $el.attr('data-swiper-parallax-opacity'); |
| 7052 |
|
| 7053 |
if (x || y) { |
| 7054 |
x = x || '0'; |
| 7055 |
y = y || '0'; |
| 7056 |
} else if (swiper.isHorizontal()) { |
| 7057 |
x = p; |
| 7058 |
y = '0'; |
| 7059 |
} else { |
| 7060 |
y = p; |
| 7061 |
x = '0'; |
| 7062 |
} |
| 7063 |
|
| 7064 |
if (x.indexOf('%') >= 0) { |
| 7065 |
x = parseInt(x, 10) * progress * rtlFactor + "%"; |
| 7066 |
} else { |
| 7067 |
x = x * progress * rtlFactor + "px"; |
| 7068 |
} |
| 7069 |
|
| 7070 |
if (y.indexOf('%') >= 0) { |
| 7071 |
y = parseInt(y, 10) * progress + "%"; |
| 7072 |
} else { |
| 7073 |
y = y * progress + "px"; |
| 7074 |
} |
| 7075 |
|
| 7076 |
if (typeof opacity !== 'undefined' && opacity !== null) { |
| 7077 |
var currentOpacity = opacity - (opacity - 1) * (1 - Math.abs(progress)); |
| 7078 |
$el[0].style.opacity = currentOpacity; |
| 7079 |
} |
| 7080 |
|
| 7081 |
if (typeof scale === 'undefined' || scale === null) { |
| 7082 |
$el.transform("translate3d(" + x + ", " + y + ", 0px)"); |
| 7083 |
} else { |
| 7084 |
var currentScale = scale - (scale - 1) * (1 - Math.abs(progress)); |
| 7085 |
$el.transform("translate3d(" + x + ", " + y + ", 0px) scale(" + currentScale + ")"); |
| 7086 |
} |
| 7087 |
}, |
| 7088 |
setTranslate: function setTranslate() { |
| 7089 |
var swiper = this; |
| 7090 |
var $el = swiper.$el, |
| 7091 |
slides = swiper.slides, |
| 7092 |
progress = swiper.progress, |
| 7093 |
snapGrid = swiper.snapGrid; |
| 7094 |
$el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(function (el) { |
| 7095 |
swiper.parallax.setTransform(el, progress); |
| 7096 |
}); |
| 7097 |
slides.each(function (slideEl, slideIndex) { |
| 7098 |
var slideProgress = slideEl.progress; |
| 7099 |
|
| 7100 |
if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') { |
| 7101 |
slideProgress += Math.ceil(slideIndex / 2) - progress * (snapGrid.length - 1); |
| 7102 |
} |
| 7103 |
|
| 7104 |
slideProgress = Math.min(Math.max(slideProgress, -1), 1); |
| 7105 |
$(slideEl).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(function (el) { |
| 7106 |
swiper.parallax.setTransform(el, slideProgress); |
| 7107 |
}); |
| 7108 |
}); |
| 7109 |
}, |
| 7110 |
setTransition: function setTransition(duration) { |
| 7111 |
if (duration === void 0) { |
| 7112 |
duration = this.params.speed; |
| 7113 |
} |
| 7114 |
|
| 7115 |
var swiper = this; |
| 7116 |
var $el = swiper.$el; |
| 7117 |
$el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(function (parallaxEl) { |
| 7118 |
var $parallaxEl = $(parallaxEl); |
| 7119 |
var parallaxDuration = parseInt($parallaxEl.attr('data-swiper-parallax-duration'), 10) || duration; |
| 7120 |
if (duration === 0) parallaxDuration = 0; |
| 7121 |
$parallaxEl.transition(parallaxDuration); |
| 7122 |
}); |
| 7123 |
} |
| 7124 |
}; |
| 7125 |
var Parallax$1 = { |
| 7126 |
name: 'parallax', |
| 7127 |
params: { |
| 7128 |
parallax: { |
| 7129 |
enabled: false |
| 7130 |
} |
| 7131 |
}, |
| 7132 |
create: function create() { |
| 7133 |
var swiper = this; |
| 7134 |
bindModuleMethods(swiper, { |
| 7135 |
parallax: _extends({}, Parallax) |
| 7136 |
}); |
| 7137 |
}, |
| 7138 |
on: { |
| 7139 |
beforeInit: function beforeInit(swiper) { |
| 7140 |
if (!swiper.params.parallax.enabled) return; |
| 7141 |
swiper.params.watchSlidesProgress = true; |
| 7142 |
swiper.originalParams.watchSlidesProgress = true; |
| 7143 |
}, |
| 7144 |
init: function init(swiper) { |
| 7145 |
if (!swiper.params.parallax.enabled) return; |
| 7146 |
swiper.parallax.setTranslate(); |
| 7147 |
}, |
| 7148 |
setTranslate: function setTranslate(swiper) { |
| 7149 |
if (!swiper.params.parallax.enabled) return; |
| 7150 |
swiper.parallax.setTranslate(); |
| 7151 |
}, |
| 7152 |
setTransition: function setTransition(swiper, duration) { |
| 7153 |
if (!swiper.params.parallax.enabled) return; |
| 7154 |
swiper.parallax.setTransition(duration); |
| 7155 |
} |
| 7156 |
} |
| 7157 |
}; |
| 7158 |
|
| 7159 |
var Zoom = { |
| 7160 |
// Calc Scale From Multi-touches |
| 7161 |
getDistanceBetweenTouches: function getDistanceBetweenTouches(e) { |
| 7162 |
if (e.targetTouches.length < 2) return 1; |
| 7163 |
var x1 = e.targetTouches[0].pageX; |
| 7164 |
var y1 = e.targetTouches[0].pageY; |
| 7165 |
var x2 = e.targetTouches[1].pageX; |
| 7166 |
var y2 = e.targetTouches[1].pageY; |
| 7167 |
var distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)); |
| 7168 |
return distance; |
| 7169 |
}, |
| 7170 |
// Events |
| 7171 |
onGestureStart: function onGestureStart(e) { |
| 7172 |
var swiper = this; |
| 7173 |
var support = swiper.support; |
| 7174 |
var params = swiper.params.zoom; |
| 7175 |
var zoom = swiper.zoom; |
| 7176 |
var gesture = zoom.gesture; |
| 7177 |
zoom.fakeGestureTouched = false; |
| 7178 |
zoom.fakeGestureMoved = false; |
| 7179 |
|
| 7180 |
if (!support.gestures) { |
| 7181 |
if (e.type !== 'touchstart' || e.type === 'touchstart' && e.targetTouches.length < 2) { |
| 7182 |
return; |
| 7183 |
} |
| 7184 |
|
| 7185 |
zoom.fakeGestureTouched = true; |
| 7186 |
gesture.scaleStart = Zoom.getDistanceBetweenTouches(e); |
| 7187 |
} |
| 7188 |
|
| 7189 |
if (!gesture.$slideEl || !gesture.$slideEl.length) { |
| 7190 |
gesture.$slideEl = $(e.target).closest("." + swiper.params.slideClass); |
| 7191 |
if (gesture.$slideEl.length === 0) gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); |
| 7192 |
gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target'); |
| 7193 |
gesture.$imageWrapEl = gesture.$imageEl.parent("." + params.containerClass); |
| 7194 |
gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; |
| 7195 |
|
| 7196 |
if (gesture.$imageWrapEl.length === 0) { |
| 7197 |
gesture.$imageEl = undefined; |
| 7198 |
return; |
| 7199 |
} |
| 7200 |
} |
| 7201 |
|
| 7202 |
if (gesture.$imageEl) { |
| 7203 |
gesture.$imageEl.transition(0); |
| 7204 |
} |
| 7205 |
|
| 7206 |
swiper.zoom.isScaling = true; |
| 7207 |
}, |
| 7208 |
onGestureChange: function onGestureChange(e) { |
| 7209 |
var swiper = this; |
| 7210 |
var support = swiper.support; |
| 7211 |
var params = swiper.params.zoom; |
| 7212 |
var zoom = swiper.zoom; |
| 7213 |
var gesture = zoom.gesture; |
| 7214 |
|
| 7215 |
if (!support.gestures) { |
| 7216 |
if (e.type !== 'touchmove' || e.type === 'touchmove' && e.targetTouches.length < 2) { |
| 7217 |
return; |
| 7218 |
} |
| 7219 |
|
| 7220 |
zoom.fakeGestureMoved = true; |
| 7221 |
gesture.scaleMove = Zoom.getDistanceBetweenTouches(e); |
| 7222 |
} |
| 7223 |
|
| 7224 |
if (!gesture.$imageEl || gesture.$imageEl.length === 0) { |
| 7225 |
if (e.type === 'gesturechange') zoom.onGestureStart(e); |
| 7226 |
return; |
| 7227 |
} |
| 7228 |
|
| 7229 |
if (support.gestures) { |
| 7230 |
zoom.scale = e.scale * zoom.currentScale; |
| 7231 |
} else { |
| 7232 |
zoom.scale = gesture.scaleMove / gesture.scaleStart * zoom.currentScale; |
| 7233 |
} |
| 7234 |
|
| 7235 |
if (zoom.scale > gesture.maxRatio) { |
| 7236 |
zoom.scale = gesture.maxRatio - 1 + Math.pow(zoom.scale - gesture.maxRatio + 1, 0.5); |
| 7237 |
} |
| 7238 |
|
| 7239 |
if (zoom.scale < params.minRatio) { |
| 7240 |
zoom.scale = params.minRatio + 1 - Math.pow(params.minRatio - zoom.scale + 1, 0.5); |
| 7241 |
} |
| 7242 |
|
| 7243 |
gesture.$imageEl.transform("translate3d(0,0,0) scale(" + zoom.scale + ")"); |
| 7244 |
}, |
| 7245 |
onGestureEnd: function onGestureEnd(e) { |
| 7246 |
var swiper = this; |
| 7247 |
var device = swiper.device; |
| 7248 |
var support = swiper.support; |
| 7249 |
var params = swiper.params.zoom; |
| 7250 |
var zoom = swiper.zoom; |
| 7251 |
var gesture = zoom.gesture; |
| 7252 |
|
| 7253 |
if (!support.gestures) { |
| 7254 |
if (!zoom.fakeGestureTouched || !zoom.fakeGestureMoved) { |
| 7255 |
return; |
| 7256 |
} |
| 7257 |
|
| 7258 |
if (e.type !== 'touchend' || e.type === 'touchend' && e.changedTouches.length < 2 && !device.android) { |
| 7259 |
return; |
| 7260 |
} |
| 7261 |
|
| 7262 |
zoom.fakeGestureTouched = false; |
| 7263 |
zoom.fakeGestureMoved = false; |
| 7264 |
} |
| 7265 |
|
| 7266 |
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; |
| 7267 |
zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio); |
| 7268 |
gesture.$imageEl.transition(swiper.params.speed).transform("translate3d(0,0,0) scale(" + zoom.scale + ")"); |
| 7269 |
zoom.currentScale = zoom.scale; |
| 7270 |
zoom.isScaling = false; |
| 7271 |
if (zoom.scale === 1) gesture.$slideEl = undefined; |
| 7272 |
}, |
| 7273 |
onTouchStart: function onTouchStart(e) { |
| 7274 |
var swiper = this; |
| 7275 |
var device = swiper.device; |
| 7276 |
var zoom = swiper.zoom; |
| 7277 |
var gesture = zoom.gesture, |
| 7278 |
image = zoom.image; |
| 7279 |
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; |
| 7280 |
if (image.isTouched) return; |
| 7281 |
if (device.android && e.cancelable) e.preventDefault(); |
| 7282 |
image.isTouched = true; |
| 7283 |
image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; |
| 7284 |
image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; |
| 7285 |
}, |
| 7286 |
onTouchMove: function onTouchMove(e) { |
| 7287 |
var swiper = this; |
| 7288 |
var zoom = swiper.zoom; |
| 7289 |
var gesture = zoom.gesture, |
| 7290 |
image = zoom.image, |
| 7291 |
velocity = zoom.velocity; |
| 7292 |
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; |
| 7293 |
swiper.allowClick = false; |
| 7294 |
if (!image.isTouched || !gesture.$slideEl) return; |
| 7295 |
|
| 7296 |
if (!image.isMoved) { |
| 7297 |
image.width = gesture.$imageEl[0].offsetWidth; |
| 7298 |
image.height = gesture.$imageEl[0].offsetHeight; |
| 7299 |
image.startX = getTranslate(gesture.$imageWrapEl[0], 'x') || 0; |
| 7300 |
image.startY = getTranslate(gesture.$imageWrapEl[0], 'y') || 0; |
| 7301 |
gesture.slideWidth = gesture.$slideEl[0].offsetWidth; |
| 7302 |
gesture.slideHeight = gesture.$slideEl[0].offsetHeight; |
| 7303 |
gesture.$imageWrapEl.transition(0); |
| 7304 |
|
| 7305 |
if (swiper.rtl) { |
| 7306 |
image.startX = -image.startX; |
| 7307 |
image.startY = -image.startY; |
| 7308 |
} |
| 7309 |
} // Define if we need image drag |
| 7310 |
|
| 7311 |
|
| 7312 |
var scaledWidth = image.width * zoom.scale; |
| 7313 |
var scaledHeight = image.height * zoom.scale; |
| 7314 |
if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) return; |
| 7315 |
image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0); |
| 7316 |
image.maxX = -image.minX; |
| 7317 |
image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0); |
| 7318 |
image.maxY = -image.minY; |
| 7319 |
image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; |
| 7320 |
image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; |
| 7321 |
|
| 7322 |
if (!image.isMoved && !zoom.isScaling) { |
| 7323 |
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)) { |
| 7324 |
image.isTouched = false; |
| 7325 |
return; |
| 7326 |
} |
| 7327 |
|
| 7328 |
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)) { |
| 7329 |
image.isTouched = false; |
| 7330 |
return; |
| 7331 |
} |
| 7332 |
} |
| 7333 |
|
| 7334 |
if (e.cancelable) { |
| 7335 |
e.preventDefault(); |
| 7336 |
} |
| 7337 |
|
| 7338 |
e.stopPropagation(); |
| 7339 |
image.isMoved = true; |
| 7340 |
image.currentX = image.touchesCurrent.x - image.touchesStart.x + image.startX; |
| 7341 |
image.currentY = image.touchesCurrent.y - image.touchesStart.y + image.startY; |
| 7342 |
|
| 7343 |
if (image.currentX < image.minX) { |
| 7344 |
image.currentX = image.minX + 1 - Math.pow(image.minX - image.currentX + 1, 0.8); |
| 7345 |
} |
| 7346 |
|
| 7347 |
if (image.currentX > image.maxX) { |
| 7348 |
image.currentX = image.maxX - 1 + Math.pow(image.currentX - image.maxX + 1, 0.8); |
| 7349 |
} |
| 7350 |
|
| 7351 |
if (image.currentY < image.minY) { |
| 7352 |
image.currentY = image.minY + 1 - Math.pow(image.minY - image.currentY + 1, 0.8); |
| 7353 |
} |
| 7354 |
|
| 7355 |
if (image.currentY > image.maxY) { |
| 7356 |
image.currentY = image.maxY - 1 + Math.pow(image.currentY - image.maxY + 1, 0.8); |
| 7357 |
} // Velocity |
| 7358 |
|
| 7359 |
|
| 7360 |
if (!velocity.prevPositionX) velocity.prevPositionX = image.touchesCurrent.x; |
| 7361 |
if (!velocity.prevPositionY) velocity.prevPositionY = image.touchesCurrent.y; |
| 7362 |
if (!velocity.prevTime) velocity.prevTime = Date.now(); |
| 7363 |
velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2; |
| 7364 |
velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2; |
| 7365 |
if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) velocity.x = 0; |
| 7366 |
if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) velocity.y = 0; |
| 7367 |
velocity.prevPositionX = image.touchesCurrent.x; |
| 7368 |
velocity.prevPositionY = image.touchesCurrent.y; |
| 7369 |
velocity.prevTime = Date.now(); |
| 7370 |
gesture.$imageWrapEl.transform("translate3d(" + image.currentX + "px, " + image.currentY + "px,0)"); |
| 7371 |
}, |
| 7372 |
onTouchEnd: function onTouchEnd() { |
| 7373 |
var swiper = this; |
| 7374 |
var zoom = swiper.zoom; |
| 7375 |
var gesture = zoom.gesture, |
| 7376 |
image = zoom.image, |
| 7377 |
velocity = zoom.velocity; |
| 7378 |
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; |
| 7379 |
|
| 7380 |
if (!image.isTouched || !image.isMoved) { |
| 7381 |
image.isTouched = false; |
| 7382 |
image.isMoved = false; |
| 7383 |
return; |
| 7384 |
} |
| 7385 |
|
| 7386 |
image.isTouched = false; |
| 7387 |
image.isMoved = false; |
| 7388 |
var momentumDurationX = 300; |
| 7389 |
var momentumDurationY = 300; |
| 7390 |
var momentumDistanceX = velocity.x * momentumDurationX; |
| 7391 |
var newPositionX = image.currentX + momentumDistanceX; |
| 7392 |
var momentumDistanceY = velocity.y * momentumDurationY; |
| 7393 |
var newPositionY = image.currentY + momentumDistanceY; // Fix duration |
| 7394 |
|
| 7395 |
if (velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x); |
| 7396 |
if (velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y); |
| 7397 |
var momentumDuration = Math.max(momentumDurationX, momentumDurationY); |
| 7398 |
image.currentX = newPositionX; |
| 7399 |
image.currentY = newPositionY; // Define if we need image drag |
| 7400 |
|
| 7401 |
var scaledWidth = image.width * zoom.scale; |
| 7402 |
var scaledHeight = image.height * zoom.scale; |
| 7403 |
image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0); |
| 7404 |
image.maxX = -image.minX; |
| 7405 |
image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0); |
| 7406 |
image.maxY = -image.minY; |
| 7407 |
image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX); |
| 7408 |
image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY); |
| 7409 |
gesture.$imageWrapEl.transition(momentumDuration).transform("translate3d(" + image.currentX + "px, " + image.currentY + "px,0)"); |
| 7410 |
}, |
| 7411 |
onTransitionEnd: function onTransitionEnd() { |
| 7412 |
var swiper = this; |
| 7413 |
var zoom = swiper.zoom; |
| 7414 |
var gesture = zoom.gesture; |
| 7415 |
|
| 7416 |
if (gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex) { |
| 7417 |
if (gesture.$imageEl) { |
| 7418 |
gesture.$imageEl.transform('translate3d(0,0,0) scale(1)'); |
| 7419 |
} |
| 7420 |
|
| 7421 |
if (gesture.$imageWrapEl) { |
| 7422 |
gesture.$imageWrapEl.transform('translate3d(0,0,0)'); |
| 7423 |
} |
| 7424 |
|
| 7425 |
zoom.scale = 1; |
| 7426 |
zoom.currentScale = 1; |
| 7427 |
gesture.$slideEl = undefined; |
| 7428 |
gesture.$imageEl = undefined; |
| 7429 |
gesture.$imageWrapEl = undefined; |
| 7430 |
} |
| 7431 |
}, |
| 7432 |
// Toggle Zoom |
| 7433 |
toggle: function toggle(e) { |
| 7434 |
var swiper = this; |
| 7435 |
var zoom = swiper.zoom; |
| 7436 |
|
| 7437 |
if (zoom.scale && zoom.scale !== 1) { |
| 7438 |
// Zoom Out |
| 7439 |
zoom.out(); |
| 7440 |
} else { |
| 7441 |
// Zoom In |
| 7442 |
zoom.in(e); |
| 7443 |
} |
| 7444 |
}, |
| 7445 |
in: function _in(e) { |
| 7446 |
var swiper = this; |
| 7447 |
var window = getWindow(); |
| 7448 |
var zoom = swiper.zoom; |
| 7449 |
var params = swiper.params.zoom; |
| 7450 |
var gesture = zoom.gesture, |
| 7451 |
image = zoom.image; |
| 7452 |
|
| 7453 |
if (!gesture.$slideEl) { |
| 7454 |
if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) { |
| 7455 |
gesture.$slideEl = swiper.$wrapperEl.children("." + swiper.params.slideActiveClass); |
| 7456 |
} else { |
| 7457 |
gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); |
| 7458 |
} |
| 7459 |
|
| 7460 |
gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target'); |
| 7461 |
gesture.$imageWrapEl = gesture.$imageEl.parent("." + params.containerClass); |
| 7462 |
} |
| 7463 |
|
| 7464 |
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; |
| 7465 |
gesture.$slideEl.addClass("" + params.zoomedSlideClass); |
| 7466 |
var touchX; |
| 7467 |
var touchY; |
| 7468 |
var offsetX; |
| 7469 |
var offsetY; |
| 7470 |
var diffX; |
| 7471 |
var diffY; |
| 7472 |
var translateX; |
| 7473 |
var translateY; |
| 7474 |
var imageWidth; |
| 7475 |
var imageHeight; |
| 7476 |
var scaledWidth; |
| 7477 |
var scaledHeight; |
| 7478 |
var translateMinX; |
| 7479 |
var translateMinY; |
| 7480 |
var translateMaxX; |
| 7481 |
var translateMaxY; |
| 7482 |
var slideWidth; |
| 7483 |
var slideHeight; |
| 7484 |
|
| 7485 |
if (typeof image.touchesStart.x === 'undefined' && e) { |
| 7486 |
touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX; |
| 7487 |
touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY; |
| 7488 |
} else { |
| 7489 |
touchX = image.touchesStart.x; |
| 7490 |
touchY = image.touchesStart.y; |
| 7491 |
} |
| 7492 |
|
| 7493 |
zoom.scale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; |
| 7494 |
zoom.currentScale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; |
| 7495 |
|
| 7496 |
if (e) { |
| 7497 |
slideWidth = gesture.$slideEl[0].offsetWidth; |
| 7498 |
slideHeight = gesture.$slideEl[0].offsetHeight; |
| 7499 |
offsetX = gesture.$slideEl.offset().left + window.scrollX; |
| 7500 |
offsetY = gesture.$slideEl.offset().top + window.scrollY; |
| 7501 |
diffX = offsetX + slideWidth / 2 - touchX; |
| 7502 |
diffY = offsetY + slideHeight / 2 - touchY; |
| 7503 |
imageWidth = gesture.$imageEl[0].offsetWidth; |
| 7504 |
imageHeight = gesture.$imageEl[0].offsetHeight; |
| 7505 |
scaledWidth = imageWidth * zoom.scale; |
| 7506 |
scaledHeight = imageHeight * zoom.scale; |
| 7507 |
translateMinX = Math.min(slideWidth / 2 - scaledWidth / 2, 0); |
| 7508 |
translateMinY = Math.min(slideHeight / 2 - scaledHeight / 2, 0); |
| 7509 |
translateMaxX = -translateMinX; |
| 7510 |
translateMaxY = -translateMinY; |
| 7511 |
translateX = diffX * zoom.scale; |
| 7512 |
translateY = diffY * zoom.scale; |
| 7513 |
|
| 7514 |
if (translateX < translateMinX) { |
| 7515 |
translateX = translateMinX; |
| 7516 |
} |
| 7517 |
|
| 7518 |
if (translateX > translateMaxX) { |
| 7519 |
translateX = translateMaxX; |
| 7520 |
} |
| 7521 |
|
| 7522 |
if (translateY < translateMinY) { |
| 7523 |
translateY = translateMinY; |
| 7524 |
} |
| 7525 |
|
| 7526 |
if (translateY > translateMaxY) { |
| 7527 |
translateY = translateMaxY; |
| 7528 |
} |
| 7529 |
} else { |
| 7530 |
translateX = 0; |
| 7531 |
translateY = 0; |
| 7532 |
} |
| 7533 |
|
| 7534 |
gesture.$imageWrapEl.transition(300).transform("translate3d(" + translateX + "px, " + translateY + "px,0)"); |
| 7535 |
gesture.$imageEl.transition(300).transform("translate3d(0,0,0) scale(" + zoom.scale + ")"); |
| 7536 |
}, |
| 7537 |
out: function out() { |
| 7538 |
var swiper = this; |
| 7539 |
var zoom = swiper.zoom; |
| 7540 |
var params = swiper.params.zoom; |
| 7541 |
var gesture = zoom.gesture; |
| 7542 |
|
| 7543 |
if (!gesture.$slideEl) { |
| 7544 |
if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) { |
| 7545 |
gesture.$slideEl = swiper.$wrapperEl.children("." + swiper.params.slideActiveClass); |
| 7546 |
} else { |
| 7547 |
gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); |
| 7548 |
} |
| 7549 |
|
| 7550 |
gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target'); |
| 7551 |
gesture.$imageWrapEl = gesture.$imageEl.parent("." + params.containerClass); |
| 7552 |
} |
| 7553 |
|
| 7554 |
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; |
| 7555 |
zoom.scale = 1; |
| 7556 |
zoom.currentScale = 1; |
| 7557 |
gesture.$imageWrapEl.transition(300).transform('translate3d(0,0,0)'); |
| 7558 |
gesture.$imageEl.transition(300).transform('translate3d(0,0,0) scale(1)'); |
| 7559 |
gesture.$slideEl.removeClass("" + params.zoomedSlideClass); |
| 7560 |
gesture.$slideEl = undefined; |
| 7561 |
}, |
| 7562 |
toggleGestures: function toggleGestures(method) { |
| 7563 |
var swiper = this; |
| 7564 |
var zoom = swiper.zoom; |
| 7565 |
var selector = zoom.slideSelector, |
| 7566 |
passive = zoom.passiveListener; |
| 7567 |
swiper.$wrapperEl[method]('gesturestart', selector, zoom.onGestureStart, passive); |
| 7568 |
swiper.$wrapperEl[method]('gesturechange', selector, zoom.onGestureChange, passive); |
| 7569 |
swiper.$wrapperEl[method]('gestureend', selector, zoom.onGestureEnd, passive); |
| 7570 |
}, |
| 7571 |
enableGestures: function enableGestures() { |
| 7572 |
if (this.zoom.gesturesEnabled) return; |
| 7573 |
this.zoom.gesturesEnabled = true; |
| 7574 |
this.zoom.toggleGestures('on'); |
| 7575 |
}, |
| 7576 |
disableGestures: function disableGestures() { |
| 7577 |
if (!this.zoom.gesturesEnabled) return; |
| 7578 |
this.zoom.gesturesEnabled = false; |
| 7579 |
this.zoom.toggleGestures('off'); |
| 7580 |
}, |
| 7581 |
// Attach/Detach Events |
| 7582 |
enable: function enable() { |
| 7583 |
var swiper = this; |
| 7584 |
var support = swiper.support; |
| 7585 |
var zoom = swiper.zoom; |
| 7586 |
if (zoom.enabled) return; |
| 7587 |
zoom.enabled = true; |
| 7588 |
var passiveListener = swiper.touchEvents.start === 'touchstart' && support.passiveListener && swiper.params.passiveListeners ? { |
| 7589 |
passive: true, |
| 7590 |
capture: false |
| 7591 |
} : false; |
| 7592 |
var activeListenerWithCapture = support.passiveListener ? { |
| 7593 |
passive: false, |
| 7594 |
capture: true |
| 7595 |
} : true; |
| 7596 |
var slideSelector = "." + swiper.params.slideClass; |
| 7597 |
swiper.zoom.passiveListener = passiveListener; |
| 7598 |
swiper.zoom.slideSelector = slideSelector; // Scale image |
| 7599 |
|
| 7600 |
if (support.gestures) { |
| 7601 |
swiper.$wrapperEl.on(swiper.touchEvents.start, swiper.zoom.enableGestures, passiveListener); |
| 7602 |
swiper.$wrapperEl.on(swiper.touchEvents.end, swiper.zoom.disableGestures, passiveListener); |
| 7603 |
} else if (swiper.touchEvents.start === 'touchstart') { |
| 7604 |
swiper.$wrapperEl.on(swiper.touchEvents.start, slideSelector, zoom.onGestureStart, passiveListener); |
| 7605 |
swiper.$wrapperEl.on(swiper.touchEvents.move, slideSelector, zoom.onGestureChange, activeListenerWithCapture); |
| 7606 |
swiper.$wrapperEl.on(swiper.touchEvents.end, slideSelector, zoom.onGestureEnd, passiveListener); |
| 7607 |
|
| 7608 |
if (swiper.touchEvents.cancel) { |
| 7609 |
swiper.$wrapperEl.on(swiper.touchEvents.cancel, slideSelector, zoom.onGestureEnd, passiveListener); |
| 7610 |
} |
| 7611 |
} // Move image |
| 7612 |
|
| 7613 |
|
| 7614 |
swiper.$wrapperEl.on(swiper.touchEvents.move, "." + swiper.params.zoom.containerClass, zoom.onTouchMove, activeListenerWithCapture); |
| 7615 |
}, |
| 7616 |
disable: function disable() { |
| 7617 |
var swiper = this; |
| 7618 |
var zoom = swiper.zoom; |
| 7619 |
if (!zoom.enabled) return; |
| 7620 |
var support = swiper.support; |
| 7621 |
swiper.zoom.enabled = false; |
| 7622 |
var passiveListener = swiper.touchEvents.start === 'touchstart' && support.passiveListener && swiper.params.passiveListeners ? { |
| 7623 |
passive: true, |
| 7624 |
capture: false |
| 7625 |
} : false; |
| 7626 |
var activeListenerWithCapture = support.passiveListener ? { |
| 7627 |
passive: false, |
| 7628 |
capture: true |
| 7629 |
} : true; |
| 7630 |
var slideSelector = "." + swiper.params.slideClass; // Scale image |
| 7631 |
|
| 7632 |
if (support.gestures) { |
| 7633 |
swiper.$wrapperEl.off(swiper.touchEvents.start, swiper.zoom.enableGestures, passiveListener); |
| 7634 |
swiper.$wrapperEl.off(swiper.touchEvents.end, swiper.zoom.disableGestures, passiveListener); |
| 7635 |
} else if (swiper.touchEvents.start === 'touchstart') { |
| 7636 |
swiper.$wrapperEl.off(swiper.touchEvents.start, slideSelector, zoom.onGestureStart, passiveListener); |
| 7637 |
swiper.$wrapperEl.off(swiper.touchEvents.move, slideSelector, zoom.onGestureChange, activeListenerWithCapture); |
| 7638 |
swiper.$wrapperEl.off(swiper.touchEvents.end, slideSelector, zoom.onGestureEnd, passiveListener); |
| 7639 |
|
| 7640 |
if (swiper.touchEvents.cancel) { |
| 7641 |
swiper.$wrapperEl.off(swiper.touchEvents.cancel, slideSelector, zoom.onGestureEnd, passiveListener); |
| 7642 |
} |
| 7643 |
} // Move image |
| 7644 |
|
| 7645 |
|
| 7646 |
swiper.$wrapperEl.off(swiper.touchEvents.move, "." + swiper.params.zoom.containerClass, zoom.onTouchMove, activeListenerWithCapture); |
| 7647 |
} |
| 7648 |
}; |
| 7649 |
var Zoom$1 = { |
| 7650 |
name: 'zoom', |
| 7651 |
params: { |
| 7652 |
zoom: { |
| 7653 |
enabled: false, |
| 7654 |
maxRatio: 3, |
| 7655 |
minRatio: 1, |
| 7656 |
toggle: true, |
| 7657 |
containerClass: 'swiper-zoom-container', |
| 7658 |
zoomedSlideClass: 'swiper-slide-zoomed' |
| 7659 |
} |
| 7660 |
}, |
| 7661 |
create: function create() { |
| 7662 |
var swiper = this; |
| 7663 |
bindModuleMethods(swiper, { |
| 7664 |
zoom: _extends({ |
| 7665 |
enabled: false, |
| 7666 |
scale: 1, |
| 7667 |
currentScale: 1, |
| 7668 |
isScaling: false, |
| 7669 |
gesture: { |
| 7670 |
$slideEl: undefined, |
| 7671 |
slideWidth: undefined, |
| 7672 |
slideHeight: undefined, |
| 7673 |
$imageEl: undefined, |
| 7674 |
$imageWrapEl: undefined, |
| 7675 |
maxRatio: 3 |
| 7676 |
}, |
| 7677 |
image: { |
| 7678 |
isTouched: undefined, |
| 7679 |
isMoved: undefined, |
| 7680 |
currentX: undefined, |
| 7681 |
currentY: undefined, |
| 7682 |
minX: undefined, |
| 7683 |
minY: undefined, |
| 7684 |
maxX: undefined, |
| 7685 |
maxY: undefined, |
| 7686 |
width: undefined, |
| 7687 |
height: undefined, |
| 7688 |
startX: undefined, |
| 7689 |
startY: undefined, |
| 7690 |
touchesStart: {}, |
| 7691 |
touchesCurrent: {} |
| 7692 |
}, |
| 7693 |
velocity: { |
| 7694 |
x: undefined, |
| 7695 |
y: undefined, |
| 7696 |
prevPositionX: undefined, |
| 7697 |
prevPositionY: undefined, |
| 7698 |
prevTime: undefined |
| 7699 |
} |
| 7700 |
}, Zoom) |
| 7701 |
}); |
| 7702 |
var scale = 1; |
| 7703 |
Object.defineProperty(swiper.zoom, 'scale', { |
| 7704 |
get: function get() { |
| 7705 |
return scale; |
| 7706 |
}, |
| 7707 |
set: function set(value) { |
| 7708 |
if (scale !== value) { |
| 7709 |
var imageEl = swiper.zoom.gesture.$imageEl ? swiper.zoom.gesture.$imageEl[0] : undefined; |
| 7710 |
var slideEl = swiper.zoom.gesture.$slideEl ? swiper.zoom.gesture.$slideEl[0] : undefined; |
| 7711 |
swiper.emit('zoomChange', value, imageEl, slideEl); |
| 7712 |
} |
| 7713 |
|
| 7714 |
scale = value; |
| 7715 |
} |
| 7716 |
}); |
| 7717 |
}, |
| 7718 |
on: { |
| 7719 |
init: function init(swiper) { |
| 7720 |
if (swiper.params.zoom.enabled) { |
| 7721 |
swiper.zoom.enable(); |
| 7722 |
} |
| 7723 |
}, |
| 7724 |
destroy: function destroy(swiper) { |
| 7725 |
swiper.zoom.disable(); |
| 7726 |
}, |
| 7727 |
touchStart: function touchStart(swiper, e) { |
| 7728 |
if (!swiper.zoom.enabled) return; |
| 7729 |
swiper.zoom.onTouchStart(e); |
| 7730 |
}, |
| 7731 |
touchEnd: function touchEnd(swiper, e) { |
| 7732 |
if (!swiper.zoom.enabled) return; |
| 7733 |
swiper.zoom.onTouchEnd(e); |
| 7734 |
}, |
| 7735 |
doubleTap: function doubleTap(swiper, e) { |
| 7736 |
if (!swiper.animating && swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) { |
| 7737 |
swiper.zoom.toggle(e); |
| 7738 |
} |
| 7739 |
}, |
| 7740 |
transitionEnd: function transitionEnd(swiper) { |
| 7741 |
if (swiper.zoom.enabled && swiper.params.zoom.enabled) { |
| 7742 |
swiper.zoom.onTransitionEnd(); |
| 7743 |
} |
| 7744 |
}, |
| 7745 |
slideChange: function slideChange(swiper) { |
| 7746 |
if (swiper.zoom.enabled && swiper.params.zoom.enabled && swiper.params.cssMode) { |
| 7747 |
swiper.zoom.onTransitionEnd(); |
| 7748 |
} |
| 7749 |
} |
| 7750 |
} |
| 7751 |
}; |
| 7752 |
|
| 7753 |
var Lazy = { |
| 7754 |
loadInSlide: function loadInSlide(index, loadInDuplicate) { |
| 7755 |
if (loadInDuplicate === void 0) { |
| 7756 |
loadInDuplicate = true; |
| 7757 |
} |
| 7758 |
|
| 7759 |
var swiper = this; |
| 7760 |
var params = swiper.params.lazy; |
| 7761 |
if (typeof index === 'undefined') return; |
| 7762 |
if (swiper.slides.length === 0) return; |
| 7763 |
var isVirtual = swiper.virtual && swiper.params.virtual.enabled; |
| 7764 |
var $slideEl = isVirtual ? swiper.$wrapperEl.children("." + swiper.params.slideClass + "[data-swiper-slide-index=\"" + index + "\"]") : swiper.slides.eq(index); |
| 7765 |
var $images = $slideEl.find("." + params.elementClass + ":not(." + params.loadedClass + "):not(." + params.loadingClass + ")"); |
| 7766 |
|
| 7767 |
if ($slideEl.hasClass(params.elementClass) && !$slideEl.hasClass(params.loadedClass) && !$slideEl.hasClass(params.loadingClass)) { |
| 7768 |
$images.push($slideEl[0]); |
| 7769 |
} |
| 7770 |
|
| 7771 |
if ($images.length === 0) return; |
| 7772 |
$images.each(function (imageEl) { |
| 7773 |
var $imageEl = $(imageEl); |
| 7774 |
$imageEl.addClass(params.loadingClass); |
| 7775 |
var background = $imageEl.attr('data-background'); |
| 7776 |
var src = $imageEl.attr('data-src'); |
| 7777 |
var srcset = $imageEl.attr('data-srcset'); |
| 7778 |
var sizes = $imageEl.attr('data-sizes'); |
| 7779 |
var $pictureEl = $imageEl.parent('picture'); |
| 7780 |
swiper.loadImage($imageEl[0], src || background, srcset, sizes, false, function () { |
| 7781 |
if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper && !swiper.params || swiper.destroyed) return; |
| 7782 |
|
| 7783 |
if (background) { |
| 7784 |
$imageEl.css('background-image', "url(\"" + background + "\")"); |
| 7785 |
$imageEl.removeAttr('data-background'); |
| 7786 |
} else { |
| 7787 |
if (srcset) { |
| 7788 |
$imageEl.attr('srcset', srcset); |
| 7789 |
$imageEl.removeAttr('data-srcset'); |
| 7790 |
} |
| 7791 |
|
| 7792 |
if (sizes) { |
| 7793 |
$imageEl.attr('sizes', sizes); |
| 7794 |
$imageEl.removeAttr('data-sizes'); |
| 7795 |
} |
| 7796 |
|
| 7797 |
if ($pictureEl.length) { |
| 7798 |
$pictureEl.children('source').each(function (sourceEl) { |
| 7799 |
var $source = $(sourceEl); |
| 7800 |
|
| 7801 |
if ($source.attr('data-srcset')) { |
| 7802 |
$source.attr('srcset', $source.attr('data-srcset')); |
| 7803 |
$source.removeAttr('data-srcset'); |
| 7804 |
} |
| 7805 |
}); |
| 7806 |
} |
| 7807 |
|
| 7808 |
if (src) { |
| 7809 |
$imageEl.attr('src', src); |
| 7810 |
$imageEl.removeAttr('data-src'); |
| 7811 |
} |
| 7812 |
} |
| 7813 |
|
| 7814 |
$imageEl.addClass(params.loadedClass).removeClass(params.loadingClass); |
| 7815 |
$slideEl.find("." + params.preloaderClass).remove(); |
| 7816 |
|
| 7817 |
if (swiper.params.loop && loadInDuplicate) { |
| 7818 |
var slideOriginalIndex = $slideEl.attr('data-swiper-slide-index'); |
| 7819 |
|
| 7820 |
if ($slideEl.hasClass(swiper.params.slideDuplicateClass)) { |
| 7821 |
var originalSlide = swiper.$wrapperEl.children("[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]:not(." + swiper.params.slideDuplicateClass + ")"); |
| 7822 |
swiper.lazy.loadInSlide(originalSlide.index(), false); |
| 7823 |
} else { |
| 7824 |
var duplicatedSlide = swiper.$wrapperEl.children("." + swiper.params.slideDuplicateClass + "[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]"); |
| 7825 |
swiper.lazy.loadInSlide(duplicatedSlide.index(), false); |
| 7826 |
} |
| 7827 |
} |
| 7828 |
|
| 7829 |
swiper.emit('lazyImageReady', $slideEl[0], $imageEl[0]); |
| 7830 |
|
| 7831 |
if (swiper.params.autoHeight) { |
| 7832 |
swiper.updateAutoHeight(); |
| 7833 |
} |
| 7834 |
}); |
| 7835 |
swiper.emit('lazyImageLoad', $slideEl[0], $imageEl[0]); |
| 7836 |
}); |
| 7837 |
}, |
| 7838 |
load: function load() { |
| 7839 |
var swiper = this; |
| 7840 |
var $wrapperEl = swiper.$wrapperEl, |
| 7841 |
swiperParams = swiper.params, |
| 7842 |
slides = swiper.slides, |
| 7843 |
activeIndex = swiper.activeIndex; |
| 7844 |
var isVirtual = swiper.virtual && swiperParams.virtual.enabled; |
| 7845 |
var params = swiperParams.lazy; |
| 7846 |
var slidesPerView = swiperParams.slidesPerView; |
| 7847 |
|
| 7848 |
if (slidesPerView === 'auto') { |
| 7849 |
slidesPerView = 0; |
| 7850 |
} |
| 7851 |
|
| 7852 |
function slideExist(index) { |
| 7853 |
if (isVirtual) { |
| 7854 |
if ($wrapperEl.children("." + swiperParams.slideClass + "[data-swiper-slide-index=\"" + index + "\"]").length) { |
| 7855 |
return true; |
| 7856 |
} |
| 7857 |
} else if (slides[index]) return true; |
| 7858 |
|
| 7859 |
return false; |
| 7860 |
} |
| 7861 |
|
| 7862 |
function slideIndex(slideEl) { |
| 7863 |
if (isVirtual) { |
| 7864 |
return $(slideEl).attr('data-swiper-slide-index'); |
| 7865 |
} |
| 7866 |
|
| 7867 |
return $(slideEl).index(); |
| 7868 |
} |
| 7869 |
|
| 7870 |
if (!swiper.lazy.initialImageLoaded) swiper.lazy.initialImageLoaded = true; |
| 7871 |
|
| 7872 |
if (swiper.params.watchSlidesVisibility) { |
| 7873 |
$wrapperEl.children("." + swiperParams.slideVisibleClass).each(function (slideEl) { |
| 7874 |
var index = isVirtual ? $(slideEl).attr('data-swiper-slide-index') : $(slideEl).index(); |
| 7875 |
swiper.lazy.loadInSlide(index); |
| 7876 |
}); |
| 7877 |
} else if (slidesPerView > 1) { |
| 7878 |
for (var i = activeIndex; i < activeIndex + slidesPerView; i += 1) { |
| 7879 |
if (slideExist(i)) swiper.lazy.loadInSlide(i); |
| 7880 |
} |
| 7881 |
} else { |
| 7882 |
swiper.lazy.loadInSlide(activeIndex); |
| 7883 |
} |
| 7884 |
|
| 7885 |
if (params.loadPrevNext) { |
| 7886 |
if (slidesPerView > 1 || params.loadPrevNextAmount && params.loadPrevNextAmount > 1) { |
| 7887 |
var amount = params.loadPrevNextAmount; |
| 7888 |
var spv = slidesPerView; |
| 7889 |
var maxIndex = Math.min(activeIndex + spv + Math.max(amount, spv), slides.length); |
| 7890 |
var minIndex = Math.max(activeIndex - Math.max(spv, amount), 0); // Next Slides |
| 7891 |
|
| 7892 |
for (var _i = activeIndex + slidesPerView; _i < maxIndex; _i += 1) { |
| 7893 |
if (slideExist(_i)) swiper.lazy.loadInSlide(_i); |
| 7894 |
} // Prev Slides |
| 7895 |
|
| 7896 |
|
| 7897 |
for (var _i2 = minIndex; _i2 < activeIndex; _i2 += 1) { |
| 7898 |
if (slideExist(_i2)) swiper.lazy.loadInSlide(_i2); |
| 7899 |
} |
| 7900 |
} else { |
| 7901 |
var nextSlide = $wrapperEl.children("." + swiperParams.slideNextClass); |
| 7902 |
if (nextSlide.length > 0) swiper.lazy.loadInSlide(slideIndex(nextSlide)); |
| 7903 |
var prevSlide = $wrapperEl.children("." + swiperParams.slidePrevClass); |
| 7904 |
if (prevSlide.length > 0) swiper.lazy.loadInSlide(slideIndex(prevSlide)); |
| 7905 |
} |
| 7906 |
} |
| 7907 |
}, |
| 7908 |
checkInViewOnLoad: function checkInViewOnLoad() { |
| 7909 |
var window = getWindow(); |
| 7910 |
var swiper = this; |
| 7911 |
if (!swiper || swiper.destroyed) return; |
| 7912 |
var $scrollElement = swiper.params.lazy.scrollingElement ? $(swiper.params.lazy.scrollingElement) : $(window); |
| 7913 |
var isWindow = $scrollElement[0] === window; |
| 7914 |
var scrollElementWidth = isWindow ? window.innerWidth : $scrollElement[0].offsetWidth; |
| 7915 |
var scrollElementHeight = isWindow ? window.innerHeight : $scrollElement[0].offsetHeight; |
| 7916 |
var swiperOffset = swiper.$el.offset(); |
| 7917 |
var rtl = swiper.rtlTranslate; |
| 7918 |
var inView = false; |
| 7919 |
if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft; |
| 7920 |
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]]; |
| 7921 |
|
| 7922 |
for (var i = 0; i < swiperCoord.length; i += 1) { |
| 7923 |
var point = swiperCoord[i]; |
| 7924 |
|
| 7925 |
if (point[0] >= 0 && point[0] <= scrollElementWidth && point[1] >= 0 && point[1] <= scrollElementHeight) { |
| 7926 |
if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line |
| 7927 |
|
| 7928 |
inView = true; |
| 7929 |
} |
| 7930 |
} |
| 7931 |
|
| 7932 |
if (inView) { |
| 7933 |
swiper.lazy.load(); |
| 7934 |
$scrollElement.off('scroll', swiper.lazy.checkInViewOnLoad); |
| 7935 |
} else if (!swiper.lazy.scrollHandlerAttached) { |
| 7936 |
swiper.lazy.scrollHandlerAttached = true; |
| 7937 |
$scrollElement.on('scroll', swiper.lazy.checkInViewOnLoad); |
| 7938 |
} |
| 7939 |
} |
| 7940 |
}; |
| 7941 |
var Lazy$1 = { |
| 7942 |
name: 'lazy', |
| 7943 |
params: { |
| 7944 |
lazy: { |
| 7945 |
checkInView: false, |
| 7946 |
enabled: false, |
| 7947 |
loadPrevNext: false, |
| 7948 |
loadPrevNextAmount: 1, |
| 7949 |
loadOnTransitionStart: false, |
| 7950 |
scrollingElement: '', |
| 7951 |
elementClass: 'swiper-lazy', |
| 7952 |
loadingClass: 'swiper-lazy-loading', |
| 7953 |
loadedClass: 'swiper-lazy-loaded', |
| 7954 |
preloaderClass: 'swiper-lazy-preloader' |
| 7955 |
} |
| 7956 |
}, |
| 7957 |
create: function create() { |
| 7958 |
var swiper = this; |
| 7959 |
bindModuleMethods(swiper, { |
| 7960 |
lazy: _extends({ |
| 7961 |
initialImageLoaded: false |
| 7962 |
}, Lazy) |
| 7963 |
}); |
| 7964 |
}, |
| 7965 |
on: { |
| 7966 |
beforeInit: function beforeInit(swiper) { |
| 7967 |
if (swiper.params.lazy.enabled && swiper.params.preloadImages) { |
| 7968 |
swiper.params.preloadImages = false; |
| 7969 |
} |
| 7970 |
}, |
| 7971 |
init: function init(swiper) { |
| 7972 |
if (swiper.params.lazy.enabled && !swiper.params.loop && swiper.params.initialSlide === 0) { |
| 7973 |
if (swiper.params.lazy.checkInView) { |
| 7974 |
swiper.lazy.checkInViewOnLoad(); |
| 7975 |
} else { |
| 7976 |
swiper.lazy.load(); |
| 7977 |
} |
| 7978 |
} |
| 7979 |
}, |
| 7980 |
scroll: function scroll(swiper) { |
| 7981 |
if (swiper.params.freeMode && !swiper.params.freeModeSticky) { |
| 7982 |
swiper.lazy.load(); |
| 7983 |
} |
| 7984 |
}, |
| 7985 |
'scrollbarDragMove resize _freeModeNoMomentumRelease': function lazyLoad(swiper) { |
| 7986 |
if (swiper.params.lazy.enabled) { |
| 7987 |
swiper.lazy.load(); |
| 7988 |
} |
| 7989 |
}, |
| 7990 |
transitionStart: function transitionStart(swiper) { |
| 7991 |
if (swiper.params.lazy.enabled) { |
| 7992 |
if (swiper.params.lazy.loadOnTransitionStart || !swiper.params.lazy.loadOnTransitionStart && !swiper.lazy.initialImageLoaded) { |
| 7993 |
swiper.lazy.load(); |
| 7994 |
} |
| 7995 |
} |
| 7996 |
}, |
| 7997 |
transitionEnd: function transitionEnd(swiper) { |
| 7998 |
if (swiper.params.lazy.enabled && !swiper.params.lazy.loadOnTransitionStart) { |
| 7999 |
swiper.lazy.load(); |
| 8000 |
} |
| 8001 |
}, |
| 8002 |
slideChange: function slideChange(swiper) { |
| 8003 |
if (swiper.params.lazy.enabled && swiper.params.cssMode) { |
| 8004 |
swiper.lazy.load(); |
| 8005 |
} |
| 8006 |
} |
| 8007 |
} |
| 8008 |
}; |
| 8009 |
|
| 8010 |
var Controller = { |
| 8011 |
LinearSpline: function LinearSpline(x, y) { |
| 8012 |
var binarySearch = function search() { |
| 8013 |
var maxIndex; |
| 8014 |
var minIndex; |
| 8015 |
var guess; |
| 8016 |
return function (array, val) { |
| 8017 |
minIndex = -1; |
| 8018 |
maxIndex = array.length; |
| 8019 |
|
| 8020 |
while (maxIndex - minIndex > 1) { |
| 8021 |
guess = maxIndex + minIndex >> 1; |
| 8022 |
|
| 8023 |
if (array[guess] <= val) { |
| 8024 |
minIndex = guess; |
| 8025 |
} else { |
| 8026 |
maxIndex = guess; |
| 8027 |
} |
| 8028 |
} |
| 8029 |
|
| 8030 |
return maxIndex; |
| 8031 |
}; |
| 8032 |
}(); |
| 8033 |
|
| 8034 |
this.x = x; |
| 8035 |
this.y = y; |
| 8036 |
this.lastIndex = x.length - 1; // Given an x value (x2), return the expected y2 value: |
| 8037 |
// (x1,y1) is the known point before given value, |
| 8038 |
// (x3,y3) is the known point after given value. |
| 8039 |
|
| 8040 |
var i1; |
| 8041 |
var i3; |
| 8042 |
|
| 8043 |
this.interpolate = function interpolate(x2) { |
| 8044 |
if (!x2) return 0; // Get the indexes of x1 and x3 (the array indexes before and after given x2): |
| 8045 |
|
| 8046 |
i3 = binarySearch(this.x, x2); |
| 8047 |
i1 = i3 - 1; // We have our indexes i1 & i3, so we can calculate already: |
| 8048 |
// y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1 |
| 8049 |
|
| 8050 |
return (x2 - this.x[i1]) * (this.y[i3] - this.y[i1]) / (this.x[i3] - this.x[i1]) + this.y[i1]; |
| 8051 |
}; |
| 8052 |
|
| 8053 |
return this; |
| 8054 |
}, |
| 8055 |
// xxx: for now i will just save one spline function to to |
| 8056 |
getInterpolateFunction: function getInterpolateFunction(c) { |
| 8057 |
var swiper = this; |
| 8058 |
|
| 8059 |
if (!swiper.controller.spline) { |
| 8060 |
swiper.controller.spline = swiper.params.loop ? new Controller.LinearSpline(swiper.slidesGrid, c.slidesGrid) : new Controller.LinearSpline(swiper.snapGrid, c.snapGrid); |
| 8061 |
} |
| 8062 |
}, |
| 8063 |
setTranslate: function setTranslate(_setTranslate, byController) { |
| 8064 |
var swiper = this; |
| 8065 |
var controlled = swiper.controller.control; |
| 8066 |
var multiplier; |
| 8067 |
var controlledTranslate; |
| 8068 |
var Swiper = swiper.constructor; |
| 8069 |
|
| 8070 |
function setControlledTranslate(c) { |
| 8071 |
// this will create an Interpolate function based on the snapGrids |
| 8072 |
// x is the Grid of the scrolled scroller and y will be the controlled scroller |
| 8073 |
// it makes sense to create this only once and recall it for the interpolation |
| 8074 |
// the function does a lot of value caching for performance |
| 8075 |
var translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate; |
| 8076 |
|
| 8077 |
if (swiper.params.controller.by === 'slide') { |
| 8078 |
swiper.controller.getInterpolateFunction(c); // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid |
| 8079 |
// but it did not work out |
| 8080 |
|
| 8081 |
controlledTranslate = -swiper.controller.spline.interpolate(-translate); |
| 8082 |
} |
| 8083 |
|
| 8084 |
if (!controlledTranslate || swiper.params.controller.by === 'container') { |
| 8085 |
multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate()); |
| 8086 |
controlledTranslate = (translate - swiper.minTranslate()) * multiplier + c.minTranslate(); |
| 8087 |
} |
| 8088 |
|
| 8089 |
if (swiper.params.controller.inverse) { |
| 8090 |
controlledTranslate = c.maxTranslate() - controlledTranslate; |
| 8091 |
} |
| 8092 |
|
| 8093 |
c.updateProgress(controlledTranslate); |
| 8094 |
c.setTranslate(controlledTranslate, swiper); |
| 8095 |
c.updateActiveIndex(); |
| 8096 |
c.updateSlidesClasses(); |
| 8097 |
} |
| 8098 |
|
| 8099 |
if (Array.isArray(controlled)) { |
| 8100 |
for (var i = 0; i < controlled.length; i += 1) { |
| 8101 |
if (controlled[i] !== byController && controlled[i] instanceof Swiper) { |
| 8102 |
setControlledTranslate(controlled[i]); |
| 8103 |
} |
| 8104 |
} |
| 8105 |
} else if (controlled instanceof Swiper && byController !== controlled) { |
| 8106 |
setControlledTranslate(controlled); |
| 8107 |
} |
| 8108 |
}, |
| 8109 |
setTransition: function setTransition(duration, byController) { |
| 8110 |
var swiper = this; |
| 8111 |
var Swiper = swiper.constructor; |
| 8112 |
var controlled = swiper.controller.control; |
| 8113 |
var i; |
| 8114 |
|
| 8115 |
function setControlledTransition(c) { |
| 8116 |
c.setTransition(duration, swiper); |
| 8117 |
|
| 8118 |
if (duration !== 0) { |
| 8119 |
c.transitionStart(); |
| 8120 |
|
| 8121 |
if (c.params.autoHeight) { |
| 8122 |
nextTick(function () { |
| 8123 |
c.updateAutoHeight(); |
| 8124 |
}); |
| 8125 |
} |
| 8126 |
|
| 8127 |
c.$wrapperEl.transitionEnd(function () { |
| 8128 |
if (!controlled) return; |
| 8129 |
|
| 8130 |
if (c.params.loop && swiper.params.controller.by === 'slide') { |
| 8131 |
c.loopFix(); |
| 8132 |
} |
| 8133 |
|
| 8134 |
c.transitionEnd(); |
| 8135 |
}); |
| 8136 |
} |
| 8137 |
} |
| 8138 |
|
| 8139 |
if (Array.isArray(controlled)) { |
| 8140 |
for (i = 0; i < controlled.length; i += 1) { |
| 8141 |
if (controlled[i] !== byController && controlled[i] instanceof Swiper) { |
| 8142 |
setControlledTransition(controlled[i]); |
| 8143 |
} |
| 8144 |
} |
| 8145 |
} else if (controlled instanceof Swiper && byController !== controlled) { |
| 8146 |
setControlledTransition(controlled); |
| 8147 |
} |
| 8148 |
} |
| 8149 |
}; |
| 8150 |
var Controller$1 = { |
| 8151 |
name: 'controller', |
| 8152 |
params: { |
| 8153 |
controller: { |
| 8154 |
control: undefined, |
| 8155 |
inverse: false, |
| 8156 |
by: 'slide' // or 'container' |
| 8157 |
|
| 8158 |
} |
| 8159 |
}, |
| 8160 |
create: function create() { |
| 8161 |
var swiper = this; |
| 8162 |
bindModuleMethods(swiper, { |
| 8163 |
controller: _extends({ |
| 8164 |
control: swiper.params.controller.control |
| 8165 |
}, Controller) |
| 8166 |
}); |
| 8167 |
}, |
| 8168 |
on: { |
| 8169 |
update: function update(swiper) { |
| 8170 |
if (!swiper.controller.control) return; |
| 8171 |
|
| 8172 |
if (swiper.controller.spline) { |
| 8173 |
swiper.controller.spline = undefined; |
| 8174 |
delete swiper.controller.spline; |
| 8175 |
} |
| 8176 |
}, |
| 8177 |
resize: function resize(swiper) { |
| 8178 |
if (!swiper.controller.control) return; |
| 8179 |
|
| 8180 |
if (swiper.controller.spline) { |
| 8181 |
swiper.controller.spline = undefined; |
| 8182 |
delete swiper.controller.spline; |
| 8183 |
} |
| 8184 |
}, |
| 8185 |
observerUpdate: function observerUpdate(swiper) { |
| 8186 |
if (!swiper.controller.control) return; |
| 8187 |
|
| 8188 |
if (swiper.controller.spline) { |
| 8189 |
swiper.controller.spline = undefined; |
| 8190 |
delete swiper.controller.spline; |
| 8191 |
} |
| 8192 |
}, |
| 8193 |
setTranslate: function setTranslate(swiper, translate, byController) { |
| 8194 |
if (!swiper.controller.control) return; |
| 8195 |
swiper.controller.setTranslate(translate, byController); |
| 8196 |
}, |
| 8197 |
setTransition: function setTransition(swiper, duration, byController) { |
| 8198 |
if (!swiper.controller.control) return; |
| 8199 |
swiper.controller.setTransition(duration, byController); |
| 8200 |
} |
| 8201 |
} |
| 8202 |
}; |
| 8203 |
|
| 8204 |
var A11y = { |
| 8205 |
getRandomNumber: function getRandomNumber(size) { |
| 8206 |
if (size === void 0) { |
| 8207 |
size = 16; |
| 8208 |
} |
| 8209 |
|
| 8210 |
var randomChar = function randomChar() { |
| 8211 |
return Math.round(16 * Math.random()).toString(16); |
| 8212 |
}; |
| 8213 |
|
| 8214 |
return 'x'.repeat(size).replace(/x/g, randomChar); |
| 8215 |
}, |
| 8216 |
makeElFocusable: function makeElFocusable($el) { |
| 8217 |
$el.attr('tabIndex', '0'); |
| 8218 |
return $el; |
| 8219 |
}, |
| 8220 |
makeElNotFocusable: function makeElNotFocusable($el) { |
| 8221 |
$el.attr('tabIndex', '-1'); |
| 8222 |
return $el; |
| 8223 |
}, |
| 8224 |
addElRole: function addElRole($el, role) { |
| 8225 |
$el.attr('role', role); |
| 8226 |
return $el; |
| 8227 |
}, |
| 8228 |
addElRoleDescription: function addElRoleDescription($el, description) { |
| 8229 |
$el.attr('aria-roledescription', description); |
| 8230 |
return $el; |
| 8231 |
}, |
| 8232 |
addElControls: function addElControls($el, controls) { |
| 8233 |
$el.attr('aria-controls', controls); |
| 8234 |
return $el; |
| 8235 |
}, |
| 8236 |
addElLabel: function addElLabel($el, label) { |
| 8237 |
$el.attr('aria-label', label); |
| 8238 |
return $el; |
| 8239 |
}, |
| 8240 |
addElId: function addElId($el, id) { |
| 8241 |
$el.attr('id', id); |
| 8242 |
return $el; |
| 8243 |
}, |
| 8244 |
addElLive: function addElLive($el, live) { |
| 8245 |
$el.attr('aria-live', live); |
| 8246 |
return $el; |
| 8247 |
}, |
| 8248 |
disableEl: function disableEl($el) { |
| 8249 |
$el.attr('aria-disabled', true); |
| 8250 |
return $el; |
| 8251 |
}, |
| 8252 |
enableEl: function enableEl($el) { |
| 8253 |
$el.attr('aria-disabled', false); |
| 8254 |
return $el; |
| 8255 |
}, |
| 8256 |
onEnterOrSpaceKey: function onEnterOrSpaceKey(e) { |
| 8257 |
if (e.keyCode !== 13 && e.keyCode !== 32) return; |
| 8258 |
var swiper = this; |
| 8259 |
var params = swiper.params.a11y; |
| 8260 |
var $targetEl = $(e.target); |
| 8261 |
|
| 8262 |
if (swiper.navigation && swiper.navigation.$nextEl && $targetEl.is(swiper.navigation.$nextEl)) { |
| 8263 |
if (!(swiper.isEnd && !swiper.params.loop)) { |
| 8264 |
swiper.slideNext(); |
| 8265 |
} |
| 8266 |
|
| 8267 |
if (swiper.isEnd) { |
| 8268 |
swiper.a11y.notify(params.lastSlideMessage); |
| 8269 |
} else { |
| 8270 |
swiper.a11y.notify(params.nextSlideMessage); |
| 8271 |
} |
| 8272 |
} |
| 8273 |
|
| 8274 |
if (swiper.navigation && swiper.navigation.$prevEl && $targetEl.is(swiper.navigation.$prevEl)) { |
| 8275 |
if (!(swiper.isBeginning && !swiper.params.loop)) { |
| 8276 |
swiper.slidePrev(); |
| 8277 |
} |
| 8278 |
|
| 8279 |
if (swiper.isBeginning) { |
| 8280 |
swiper.a11y.notify(params.firstSlideMessage); |
| 8281 |
} else { |
| 8282 |
swiper.a11y.notify(params.prevSlideMessage); |
| 8283 |
} |
| 8284 |
} |
| 8285 |
|
| 8286 |
if (swiper.pagination && $targetEl.is(classesToSelector(swiper.params.pagination.bulletClass))) { |
| 8287 |
$targetEl[0].click(); |
| 8288 |
} |
| 8289 |
}, |
| 8290 |
notify: function notify(message) { |
| 8291 |
var swiper = this; |
| 8292 |
var notification = swiper.a11y.liveRegion; |
| 8293 |
if (notification.length === 0) return; |
| 8294 |
notification.html(''); |
| 8295 |
notification.html(message); |
| 8296 |
}, |
| 8297 |
updateNavigation: function updateNavigation() { |
| 8298 |
var swiper = this; |
| 8299 |
if (swiper.params.loop || !swiper.navigation) return; |
| 8300 |
var _swiper$navigation = swiper.navigation, |
| 8301 |
$nextEl = _swiper$navigation.$nextEl, |
| 8302 |
$prevEl = _swiper$navigation.$prevEl; |
| 8303 |
|
| 8304 |
if ($prevEl && $prevEl.length > 0) { |
| 8305 |
if (swiper.isBeginning) { |
| 8306 |
swiper.a11y.disableEl($prevEl); |
| 8307 |
swiper.a11y.makeElNotFocusable($prevEl); |
| 8308 |
} else { |
| 8309 |
swiper.a11y.enableEl($prevEl); |
| 8310 |
swiper.a11y.makeElFocusable($prevEl); |
| 8311 |
} |
| 8312 |
} |
| 8313 |
|
| 8314 |
if ($nextEl && $nextEl.length > 0) { |
| 8315 |
if (swiper.isEnd) { |
| 8316 |
swiper.a11y.disableEl($nextEl); |
| 8317 |
swiper.a11y.makeElNotFocusable($nextEl); |
| 8318 |
} else { |
| 8319 |
swiper.a11y.enableEl($nextEl); |
| 8320 |
swiper.a11y.makeElFocusable($nextEl); |
| 8321 |
} |
| 8322 |
} |
| 8323 |
}, |
| 8324 |
updatePagination: function updatePagination() { |
| 8325 |
var swiper = this; |
| 8326 |
var params = swiper.params.a11y; |
| 8327 |
|
| 8328 |
if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { |
| 8329 |
swiper.pagination.bullets.each(function (bulletEl) { |
| 8330 |
var $bulletEl = $(bulletEl); |
| 8331 |
swiper.a11y.makeElFocusable($bulletEl); |
| 8332 |
|
| 8333 |
if (!swiper.params.pagination.renderBullet) { |
| 8334 |
swiper.a11y.addElRole($bulletEl, 'button'); |
| 8335 |
swiper.a11y.addElLabel($bulletEl, params.paginationBulletMessage.replace(/\{\{index\}\}/, $bulletEl.index() + 1)); |
| 8336 |
} |
| 8337 |
}); |
| 8338 |
} |
| 8339 |
}, |
| 8340 |
init: function init() { |
| 8341 |
var swiper = this; |
| 8342 |
var params = swiper.params.a11y; |
| 8343 |
swiper.$el.append(swiper.a11y.liveRegion); // Container |
| 8344 |
|
| 8345 |
var $containerEl = swiper.$el; |
| 8346 |
|
| 8347 |
if (params.containerRoleDescriptionMessage) { |
| 8348 |
swiper.a11y.addElRoleDescription($containerEl, params.containerRoleDescriptionMessage); |
| 8349 |
} |
| 8350 |
|
| 8351 |
if (params.containerMessage) { |
| 8352 |
swiper.a11y.addElLabel($containerEl, params.containerMessage); |
| 8353 |
} // Wrapper |
| 8354 |
|
| 8355 |
|
| 8356 |
var $wrapperEl = swiper.$wrapperEl; |
| 8357 |
var wrapperId = $wrapperEl.attr('id') || "swiper-wrapper-" + swiper.a11y.getRandomNumber(16); |
| 8358 |
var live; |
| 8359 |
swiper.a11y.addElId($wrapperEl, wrapperId); |
| 8360 |
|
| 8361 |
if (swiper.params.autoplay && swiper.params.autoplay.enabled) { |
| 8362 |
live = 'off'; |
| 8363 |
} else { |
| 8364 |
live = 'polite'; |
| 8365 |
} |
| 8366 |
|
| 8367 |
swiper.a11y.addElLive($wrapperEl, live); // Slide |
| 8368 |
|
| 8369 |
if (params.itemRoleDescriptionMessage) { |
| 8370 |
swiper.a11y.addElRoleDescription($(swiper.slides), params.itemRoleDescriptionMessage); |
| 8371 |
} |
| 8372 |
|
| 8373 |
swiper.a11y.addElRole($(swiper.slides), 'group'); |
| 8374 |
swiper.slides.each(function (slideEl) { |
| 8375 |
var $slideEl = $(slideEl); |
| 8376 |
var ariaLabelMessage = params.slideLabelMessage.replace(/\{\{index\}\}/, $slideEl.index() + 1).replace(/\{\{slidesLength\}\}/, swiper.slides.length); |
| 8377 |
swiper.a11y.addElLabel($slideEl, ariaLabelMessage); |
| 8378 |
}); // Navigation |
| 8379 |
|
| 8380 |
var $nextEl; |
| 8381 |
var $prevEl; |
| 8382 |
|
| 8383 |
if (swiper.navigation && swiper.navigation.$nextEl) { |
| 8384 |
$nextEl = swiper.navigation.$nextEl; |
| 8385 |
} |
| 8386 |
|
| 8387 |
if (swiper.navigation && swiper.navigation.$prevEl) { |
| 8388 |
$prevEl = swiper.navigation.$prevEl; |
| 8389 |
} |
| 8390 |
|
| 8391 |
if ($nextEl && $nextEl.length) { |
| 8392 |
swiper.a11y.makeElFocusable($nextEl); |
| 8393 |
|
| 8394 |
if ($nextEl[0].tagName !== 'BUTTON') { |
| 8395 |
swiper.a11y.addElRole($nextEl, 'button'); |
| 8396 |
$nextEl.on('keydown', swiper.a11y.onEnterOrSpaceKey); |
| 8397 |
} |
| 8398 |
|
| 8399 |
swiper.a11y.addElLabel($nextEl, params.nextSlideMessage); |
| 8400 |
swiper.a11y.addElControls($nextEl, wrapperId); |
| 8401 |
} |
| 8402 |
|
| 8403 |
if ($prevEl && $prevEl.length) { |
| 8404 |
swiper.a11y.makeElFocusable($prevEl); |
| 8405 |
|
| 8406 |
if ($prevEl[0].tagName !== 'BUTTON') { |
| 8407 |
swiper.a11y.addElRole($prevEl, 'button'); |
| 8408 |
$prevEl.on('keydown', swiper.a11y.onEnterOrSpaceKey); |
| 8409 |
} |
| 8410 |
|
| 8411 |
swiper.a11y.addElLabel($prevEl, params.prevSlideMessage); |
| 8412 |
swiper.a11y.addElControls($prevEl, wrapperId); |
| 8413 |
} // Pagination |
| 8414 |
|
| 8415 |
|
| 8416 |
if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { |
| 8417 |
swiper.pagination.$el.on('keydown', classesToSelector(swiper.params.pagination.bulletClass), swiper.a11y.onEnterOrSpaceKey); |
| 8418 |
} |
| 8419 |
}, |
| 8420 |
destroy: function destroy() { |
| 8421 |
var swiper = this; |
| 8422 |
if (swiper.a11y.liveRegion && swiper.a11y.liveRegion.length > 0) swiper.a11y.liveRegion.remove(); |
| 8423 |
var $nextEl; |
| 8424 |
var $prevEl; |
| 8425 |
|
| 8426 |
if (swiper.navigation && swiper.navigation.$nextEl) { |
| 8427 |
$nextEl = swiper.navigation.$nextEl; |
| 8428 |
} |
| 8429 |
|
| 8430 |
if (swiper.navigation && swiper.navigation.$prevEl) { |
| 8431 |
$prevEl = swiper.navigation.$prevEl; |
| 8432 |
} |
| 8433 |
|
| 8434 |
if ($nextEl) { |
| 8435 |
$nextEl.off('keydown', swiper.a11y.onEnterOrSpaceKey); |
| 8436 |
} |
| 8437 |
|
| 8438 |
if ($prevEl) { |
| 8439 |
$prevEl.off('keydown', swiper.a11y.onEnterOrSpaceKey); |
| 8440 |
} // Pagination |
| 8441 |
|
| 8442 |
|
| 8443 |
if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { |
| 8444 |
swiper.pagination.$el.off('keydown', classesToSelector(swiper.params.pagination.bulletClass), swiper.a11y.onEnterOrSpaceKey); |
| 8445 |
} |
| 8446 |
} |
| 8447 |
}; |
| 8448 |
var A11y$1 = { |
| 8449 |
name: 'a11y', |
| 8450 |
params: { |
| 8451 |
a11y: { |
| 8452 |
enabled: true, |
| 8453 |
notificationClass: 'swiper-notification', |
| 8454 |
prevSlideMessage: 'Previous slide', |
| 8455 |
nextSlideMessage: 'Next slide', |
| 8456 |
firstSlideMessage: 'This is the first slide', |
| 8457 |
lastSlideMessage: 'This is the last slide', |
| 8458 |
paginationBulletMessage: 'Go to slide {{index}}', |
| 8459 |
slideLabelMessage: '{{index}} / {{slidesLength}}', |
| 8460 |
containerMessage: null, |
| 8461 |
containerRoleDescriptionMessage: null, |
| 8462 |
itemRoleDescriptionMessage: null |
| 8463 |
} |
| 8464 |
}, |
| 8465 |
create: function create() { |
| 8466 |
var swiper = this; |
| 8467 |
bindModuleMethods(swiper, { |
| 8468 |
a11y: _extends({}, A11y, { |
| 8469 |
liveRegion: $("<span class=\"" + swiper.params.a11y.notificationClass + "\" aria-live=\"assertive\" aria-atomic=\"true\"></span>") |
| 8470 |
}) |
| 8471 |
}); |
| 8472 |
}, |
| 8473 |
on: { |
| 8474 |
afterInit: function afterInit(swiper) { |
| 8475 |
if (!swiper.params.a11y.enabled) return; |
| 8476 |
swiper.a11y.init(); |
| 8477 |
swiper.a11y.updateNavigation(); |
| 8478 |
}, |
| 8479 |
toEdge: function toEdge(swiper) { |
| 8480 |
if (!swiper.params.a11y.enabled) return; |
| 8481 |
swiper.a11y.updateNavigation(); |
| 8482 |
}, |
| 8483 |
fromEdge: function fromEdge(swiper) { |
| 8484 |
if (!swiper.params.a11y.enabled) return; |
| 8485 |
swiper.a11y.updateNavigation(); |
| 8486 |
}, |
| 8487 |
paginationUpdate: function paginationUpdate(swiper) { |
| 8488 |
if (!swiper.params.a11y.enabled) return; |
| 8489 |
swiper.a11y.updatePagination(); |
| 8490 |
}, |
| 8491 |
destroy: function destroy(swiper) { |
| 8492 |
if (!swiper.params.a11y.enabled) return; |
| 8493 |
swiper.a11y.destroy(); |
| 8494 |
} |
| 8495 |
} |
| 8496 |
}; |
| 8497 |
|
| 8498 |
var History = { |
| 8499 |
init: function init() { |
| 8500 |
var swiper = this; |
| 8501 |
var window = getWindow(); |
| 8502 |
if (!swiper.params.history) return; |
| 8503 |
|
| 8504 |
if (!window.history || !window.history.pushState) { |
| 8505 |
swiper.params.history.enabled = false; |
| 8506 |
swiper.params.hashNavigation.enabled = true; |
| 8507 |
return; |
| 8508 |
} |
| 8509 |
|
| 8510 |
var history = swiper.history; |
| 8511 |
history.initialized = true; |
| 8512 |
history.paths = History.getPathValues(swiper.params.url); |
| 8513 |
if (!history.paths.key && !history.paths.value) return; |
| 8514 |
history.scrollToSlide(0, history.paths.value, swiper.params.runCallbacksOnInit); |
| 8515 |
|
| 8516 |
if (!swiper.params.history.replaceState) { |
| 8517 |
window.addEventListener('popstate', swiper.history.setHistoryPopState); |
| 8518 |
} |
| 8519 |
}, |
| 8520 |
destroy: function destroy() { |
| 8521 |
var swiper = this; |
| 8522 |
var window = getWindow(); |
| 8523 |
|
| 8524 |
if (!swiper.params.history.replaceState) { |
| 8525 |
window.removeEventListener('popstate', swiper.history.setHistoryPopState); |
| 8526 |
} |
| 8527 |
}, |
| 8528 |
setHistoryPopState: function setHistoryPopState() { |
| 8529 |
var swiper = this; |
| 8530 |
swiper.history.paths = History.getPathValues(swiper.params.url); |
| 8531 |
swiper.history.scrollToSlide(swiper.params.speed, swiper.history.paths.value, false); |
| 8532 |
}, |
| 8533 |
getPathValues: function getPathValues(urlOverride) { |
| 8534 |
var window = getWindow(); |
| 8535 |
var location; |
| 8536 |
|
| 8537 |
if (urlOverride) { |
| 8538 |
location = new URL(urlOverride); |
| 8539 |
} else { |
| 8540 |
location = window.location; |
| 8541 |
} |
| 8542 |
|
| 8543 |
var pathArray = location.pathname.slice(1).split('/').filter(function (part) { |
| 8544 |
return part !== ''; |
| 8545 |
}); |
| 8546 |
var total = pathArray.length; |
| 8547 |
var key = pathArray[total - 2]; |
| 8548 |
var value = pathArray[total - 1]; |
| 8549 |
return { |
| 8550 |
key: key, |
| 8551 |
value: value |
| 8552 |
}; |
| 8553 |
}, |
| 8554 |
setHistory: function setHistory(key, index) { |
| 8555 |
var swiper = this; |
| 8556 |
var window = getWindow(); |
| 8557 |
if (!swiper.history.initialized || !swiper.params.history.enabled) return; |
| 8558 |
var location; |
| 8559 |
|
| 8560 |
if (swiper.params.url) { |
| 8561 |
location = new URL(swiper.params.url); |
| 8562 |
} else { |
| 8563 |
location = window.location; |
| 8564 |
} |
| 8565 |
|
| 8566 |
var slide = swiper.slides.eq(index); |
| 8567 |
var value = History.slugify(slide.attr('data-history')); |
| 8568 |
|
| 8569 |
if (!location.pathname.includes(key)) { |
| 8570 |
value = key + "/" + value; |
| 8571 |
} |
| 8572 |
|
| 8573 |
var currentState = window.history.state; |
| 8574 |
|
| 8575 |
if (currentState && currentState.value === value) { |
| 8576 |
return; |
| 8577 |
} |
| 8578 |
|
| 8579 |
if (swiper.params.history.replaceState) { |
| 8580 |
window.history.replaceState({ |
| 8581 |
value: value |
| 8582 |
}, null, value); |
| 8583 |
} else { |
| 8584 |
window.history.pushState({ |
| 8585 |
value: value |
| 8586 |
}, null, value); |
| 8587 |
} |
| 8588 |
}, |
| 8589 |
slugify: function slugify(text) { |
| 8590 |
return text.toString().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, ''); |
| 8591 |
}, |
| 8592 |
scrollToSlide: function scrollToSlide(speed, value, runCallbacks) { |
| 8593 |
var swiper = this; |
| 8594 |
|
| 8595 |
if (value) { |
| 8596 |
for (var i = 0, length = swiper.slides.length; i < length; i += 1) { |
| 8597 |
var slide = swiper.slides.eq(i); |
| 8598 |
var slideHistory = History.slugify(slide.attr('data-history')); |
| 8599 |
|
| 8600 |
if (slideHistory === value && !slide.hasClass(swiper.params.slideDuplicateClass)) { |
| 8601 |
var index = slide.index(); |
| 8602 |
swiper.slideTo(index, speed, runCallbacks); |
| 8603 |
} |
| 8604 |
} |
| 8605 |
} else { |
| 8606 |
swiper.slideTo(0, speed, runCallbacks); |
| 8607 |
} |
| 8608 |
} |
| 8609 |
}; |
| 8610 |
var History$1 = { |
| 8611 |
name: 'history', |
| 8612 |
params: { |
| 8613 |
history: { |
| 8614 |
enabled: false, |
| 8615 |
replaceState: false, |
| 8616 |
key: 'slides' |
| 8617 |
} |
| 8618 |
}, |
| 8619 |
create: function create() { |
| 8620 |
var swiper = this; |
| 8621 |
bindModuleMethods(swiper, { |
| 8622 |
history: _extends({}, History) |
| 8623 |
}); |
| 8624 |
}, |
| 8625 |
on: { |
| 8626 |
init: function init(swiper) { |
| 8627 |
if (swiper.params.history.enabled) { |
| 8628 |
swiper.history.init(); |
| 8629 |
} |
| 8630 |
}, |
| 8631 |
destroy: function destroy(swiper) { |
| 8632 |
if (swiper.params.history.enabled) { |
| 8633 |
swiper.history.destroy(); |
| 8634 |
} |
| 8635 |
}, |
| 8636 |
transitionEnd: function transitionEnd(swiper) { |
| 8637 |
if (swiper.history.initialized) { |
| 8638 |
swiper.history.setHistory(swiper.params.history.key, swiper.activeIndex); |
| 8639 |
} |
| 8640 |
}, |
| 8641 |
slideChange: function slideChange(swiper) { |
| 8642 |
if (swiper.history.initialized && swiper.params.cssMode) { |
| 8643 |
swiper.history.setHistory(swiper.params.history.key, swiper.activeIndex); |
| 8644 |
} |
| 8645 |
} |
| 8646 |
} |
| 8647 |
}; |
| 8648 |
|
| 8649 |
var HashNavigation = { |
| 8650 |
onHashCange: function onHashCange() { |
| 8651 |
var swiper = this; |
| 8652 |
var document = getDocument(); |
| 8653 |
swiper.emit('hashChange'); |
| 8654 |
var newHash = document.location.hash.replace('#', ''); |
| 8655 |
var activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash'); |
| 8656 |
|
| 8657 |
if (newHash !== activeSlideHash) { |
| 8658 |
var newIndex = swiper.$wrapperEl.children("." + swiper.params.slideClass + "[data-hash=\"" + newHash + "\"]").index(); |
| 8659 |
if (typeof newIndex === 'undefined') return; |
| 8660 |
swiper.slideTo(newIndex); |
| 8661 |
} |
| 8662 |
}, |
| 8663 |
setHash: function setHash() { |
| 8664 |
var swiper = this; |
| 8665 |
var window = getWindow(); |
| 8666 |
var document = getDocument(); |
| 8667 |
if (!swiper.hashNavigation.initialized || !swiper.params.hashNavigation.enabled) return; |
| 8668 |
|
| 8669 |
if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) { |
| 8670 |
window.history.replaceState(null, null, "#" + swiper.slides.eq(swiper.activeIndex).attr('data-hash') || ''); |
| 8671 |
swiper.emit('hashSet'); |
| 8672 |
} else { |
| 8673 |
var slide = swiper.slides.eq(swiper.activeIndex); |
| 8674 |
var hash = slide.attr('data-hash') || slide.attr('data-history'); |
| 8675 |
document.location.hash = hash || ''; |
| 8676 |
swiper.emit('hashSet'); |
| 8677 |
} |
| 8678 |
}, |
| 8679 |
init: function init() { |
| 8680 |
var swiper = this; |
| 8681 |
var document = getDocument(); |
| 8682 |
var window = getWindow(); |
| 8683 |
if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return; |
| 8684 |
swiper.hashNavigation.initialized = true; |
| 8685 |
var hash = document.location.hash.replace('#', ''); |
| 8686 |
|
| 8687 |
if (hash) { |
| 8688 |
var speed = 0; |
| 8689 |
|
| 8690 |
for (var i = 0, length = swiper.slides.length; i < length; i += 1) { |
| 8691 |
var slide = swiper.slides.eq(i); |
| 8692 |
var slideHash = slide.attr('data-hash') || slide.attr('data-history'); |
| 8693 |
|
| 8694 |
if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) { |
| 8695 |
var index = slide.index(); |
| 8696 |
swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true); |
| 8697 |
} |
| 8698 |
} |
| 8699 |
} |
| 8700 |
|
| 8701 |
if (swiper.params.hashNavigation.watchState) { |
| 8702 |
$(window).on('hashchange', swiper.hashNavigation.onHashCange); |
| 8703 |
} |
| 8704 |
}, |
| 8705 |
destroy: function destroy() { |
| 8706 |
var swiper = this; |
| 8707 |
var window = getWindow(); |
| 8708 |
|
| 8709 |
if (swiper.params.hashNavigation.watchState) { |
| 8710 |
$(window).off('hashchange', swiper.hashNavigation.onHashCange); |
| 8711 |
} |
| 8712 |
} |
| 8713 |
}; |
| 8714 |
var HashNavigation$1 = { |
| 8715 |
name: 'hash-navigation', |
| 8716 |
params: { |
| 8717 |
hashNavigation: { |
| 8718 |
enabled: false, |
| 8719 |
replaceState: false, |
| 8720 |
watchState: false |
| 8721 |
} |
| 8722 |
}, |
| 8723 |
create: function create() { |
| 8724 |
var swiper = this; |
| 8725 |
bindModuleMethods(swiper, { |
| 8726 |
hashNavigation: _extends({ |
| 8727 |
initialized: false |
| 8728 |
}, HashNavigation) |
| 8729 |
}); |
| 8730 |
}, |
| 8731 |
on: { |
| 8732 |
init: function init(swiper) { |
| 8733 |
if (swiper.params.hashNavigation.enabled) { |
| 8734 |
swiper.hashNavigation.init(); |
| 8735 |
} |
| 8736 |
}, |
| 8737 |
destroy: function destroy(swiper) { |
| 8738 |
if (swiper.params.hashNavigation.enabled) { |
| 8739 |
swiper.hashNavigation.destroy(); |
| 8740 |
} |
| 8741 |
}, |
| 8742 |
transitionEnd: function transitionEnd(swiper) { |
| 8743 |
if (swiper.hashNavigation.initialized) { |
| 8744 |
swiper.hashNavigation.setHash(); |
| 8745 |
} |
| 8746 |
}, |
| 8747 |
slideChange: function slideChange(swiper) { |
| 8748 |
if (swiper.hashNavigation.initialized && swiper.params.cssMode) { |
| 8749 |
swiper.hashNavigation.setHash(); |
| 8750 |
} |
| 8751 |
} |
| 8752 |
} |
| 8753 |
}; |
| 8754 |
|
| 8755 |
var Autoplay = { |
| 8756 |
run: function run() { |
| 8757 |
var swiper = this; |
| 8758 |
var $activeSlideEl = swiper.slides.eq(swiper.activeIndex); |
| 8759 |
var delay = swiper.params.autoplay.delay; |
| 8760 |
|
| 8761 |
if ($activeSlideEl.attr('data-swiper-autoplay')) { |
| 8762 |
delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay; |
| 8763 |
} |
| 8764 |
|
| 8765 |
clearTimeout(swiper.autoplay.timeout); |
| 8766 |
swiper.autoplay.timeout = nextTick(function () { |
| 8767 |
var autoplayResult; |
| 8768 |
|
| 8769 |
if (swiper.params.autoplay.reverseDirection) { |
| 8770 |
if (swiper.params.loop) { |
| 8771 |
swiper.loopFix(); |
| 8772 |
autoplayResult = swiper.slidePrev(swiper.params.speed, true, true); |
| 8773 |
swiper.emit('autoplay'); |
| 8774 |
} else if (!swiper.isBeginning) { |
| 8775 |
autoplayResult = swiper.slidePrev(swiper.params.speed, true, true); |
| 8776 |
swiper.emit('autoplay'); |
| 8777 |
} else if (!swiper.params.autoplay.stopOnLastSlide) { |
| 8778 |
autoplayResult = swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true); |
| 8779 |
swiper.emit('autoplay'); |
| 8780 |
} else { |
| 8781 |
swiper.autoplay.stop(); |
| 8782 |
} |
| 8783 |
} else if (swiper.params.loop) { |
| 8784 |
swiper.loopFix(); |
| 8785 |
autoplayResult = swiper.slideNext(swiper.params.speed, true, true); |
| 8786 |
swiper.emit('autoplay'); |
| 8787 |
} else if (!swiper.isEnd) { |
| 8788 |
autoplayResult = swiper.slideNext(swiper.params.speed, true, true); |
| 8789 |
swiper.emit('autoplay'); |
| 8790 |
} else if (!swiper.params.autoplay.stopOnLastSlide) { |
| 8791 |
autoplayResult = swiper.slideTo(0, swiper.params.speed, true, true); |
| 8792 |
swiper.emit('autoplay'); |
| 8793 |
} else { |
| 8794 |
swiper.autoplay.stop(); |
| 8795 |
} |
| 8796 |
|
| 8797 |
if (swiper.params.cssMode && swiper.autoplay.running) swiper.autoplay.run();else if (autoplayResult === false) { |
| 8798 |
swiper.autoplay.run(); |
| 8799 |
} |
| 8800 |
}, delay); |
| 8801 |
}, |
| 8802 |
start: function start() { |
| 8803 |
var swiper = this; |
| 8804 |
if (typeof swiper.autoplay.timeout !== 'undefined') return false; |
| 8805 |
if (swiper.autoplay.running) return false; |
| 8806 |
swiper.autoplay.running = true; |
| 8807 |
swiper.emit('autoplayStart'); |
| 8808 |
swiper.autoplay.run(); |
| 8809 |
return true; |
| 8810 |
}, |
| 8811 |
stop: function stop() { |
| 8812 |
var swiper = this; |
| 8813 |
if (!swiper.autoplay.running) return false; |
| 8814 |
if (typeof swiper.autoplay.timeout === 'undefined') return false; |
| 8815 |
|
| 8816 |
if (swiper.autoplay.timeout) { |
| 8817 |
clearTimeout(swiper.autoplay.timeout); |
| 8818 |
swiper.autoplay.timeout = undefined; |
| 8819 |
} |
| 8820 |
|
| 8821 |
swiper.autoplay.running = false; |
| 8822 |
swiper.emit('autoplayStop'); |
| 8823 |
return true; |
| 8824 |
}, |
| 8825 |
pause: function pause(speed) { |
| 8826 |
var swiper = this; |
| 8827 |
if (!swiper.autoplay.running) return; |
| 8828 |
if (swiper.autoplay.paused) return; |
| 8829 |
if (swiper.autoplay.timeout) clearTimeout(swiper.autoplay.timeout); |
| 8830 |
swiper.autoplay.paused = true; |
| 8831 |
|
| 8832 |
if (speed === 0 || !swiper.params.autoplay.waitForTransition) { |
| 8833 |
swiper.autoplay.paused = false; |
| 8834 |
swiper.autoplay.run(); |
| 8835 |
} else { |
| 8836 |
swiper.$wrapperEl[0].addEventListener('transitionend', swiper.autoplay.onTransitionEnd); |
| 8837 |
swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd); |
| 8838 |
} |
| 8839 |
}, |
| 8840 |
onVisibilityChange: function onVisibilityChange() { |
| 8841 |
var swiper = this; |
| 8842 |
var document = getDocument(); |
| 8843 |
|
| 8844 |
if (document.visibilityState === 'hidden' && swiper.autoplay.running) { |
| 8845 |
swiper.autoplay.pause(); |
| 8846 |
} |
| 8847 |
|
| 8848 |
if (document.visibilityState === 'visible' && swiper.autoplay.paused) { |
| 8849 |
swiper.autoplay.run(); |
| 8850 |
swiper.autoplay.paused = false; |
| 8851 |
} |
| 8852 |
}, |
| 8853 |
onTransitionEnd: function onTransitionEnd(e) { |
| 8854 |
var swiper = this; |
| 8855 |
if (!swiper || swiper.destroyed || !swiper.$wrapperEl) return; |
| 8856 |
if (e.target !== swiper.$wrapperEl[0]) return; |
| 8857 |
swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.autoplay.onTransitionEnd); |
| 8858 |
swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd); |
| 8859 |
swiper.autoplay.paused = false; |
| 8860 |
|
| 8861 |
if (!swiper.autoplay.running) { |
| 8862 |
swiper.autoplay.stop(); |
| 8863 |
} else { |
| 8864 |
swiper.autoplay.run(); |
| 8865 |
} |
| 8866 |
} |
| 8867 |
}; |
| 8868 |
var Autoplay$1 = { |
| 8869 |
name: 'autoplay', |
| 8870 |
params: { |
| 8871 |
autoplay: { |
| 8872 |
enabled: false, |
| 8873 |
delay: 3000, |
| 8874 |
waitForTransition: true, |
| 8875 |
disableOnInteraction: true, |
| 8876 |
stopOnLastSlide: false, |
| 8877 |
reverseDirection: false |
| 8878 |
} |
| 8879 |
}, |
| 8880 |
create: function create() { |
| 8881 |
var swiper = this; |
| 8882 |
bindModuleMethods(swiper, { |
| 8883 |
autoplay: _extends({}, Autoplay, { |
| 8884 |
running: false, |
| 8885 |
paused: false |
| 8886 |
}) |
| 8887 |
}); |
| 8888 |
}, |
| 8889 |
on: { |
| 8890 |
init: function init(swiper) { |
| 8891 |
if (swiper.params.autoplay.enabled) { |
| 8892 |
swiper.autoplay.start(); |
| 8893 |
var document = getDocument(); |
| 8894 |
document.addEventListener('visibilitychange', swiper.autoplay.onVisibilityChange); |
| 8895 |
} |
| 8896 |
}, |
| 8897 |
beforeTransitionStart: function beforeTransitionStart(swiper, speed, internal) { |
| 8898 |
if (swiper.autoplay.running) { |
| 8899 |
if (internal || !swiper.params.autoplay.disableOnInteraction) { |
| 8900 |
swiper.autoplay.pause(speed); |
| 8901 |
} else { |
| 8902 |
swiper.autoplay.stop(); |
| 8903 |
} |
| 8904 |
} |
| 8905 |
}, |
| 8906 |
sliderFirstMove: function sliderFirstMove(swiper) { |
| 8907 |
if (swiper.autoplay.running) { |
| 8908 |
if (swiper.params.autoplay.disableOnInteraction) { |
| 8909 |
swiper.autoplay.stop(); |
| 8910 |
} else { |
| 8911 |
swiper.autoplay.pause(); |
| 8912 |
} |
| 8913 |
} |
| 8914 |
}, |
| 8915 |
touchEnd: function touchEnd(swiper) { |
| 8916 |
if (swiper.params.cssMode && swiper.autoplay.paused && !swiper.params.autoplay.disableOnInteraction) { |
| 8917 |
swiper.autoplay.run(); |
| 8918 |
} |
| 8919 |
}, |
| 8920 |
destroy: function destroy(swiper) { |
| 8921 |
if (swiper.autoplay.running) { |
| 8922 |
swiper.autoplay.stop(); |
| 8923 |
} |
| 8924 |
|
| 8925 |
var document = getDocument(); |
| 8926 |
document.removeEventListener('visibilitychange', swiper.autoplay.onVisibilityChange); |
| 8927 |
} |
| 8928 |
} |
| 8929 |
}; |
| 8930 |
|
| 8931 |
var Fade = { |
| 8932 |
setTranslate: function setTranslate() { |
| 8933 |
var swiper = this; |
| 8934 |
var slides = swiper.slides; |
| 8935 |
|
| 8936 |
for (var i = 0; i < slides.length; i += 1) { |
| 8937 |
var $slideEl = swiper.slides.eq(i); |
| 8938 |
var offset = $slideEl[0].swiperSlideOffset; |
| 8939 |
var tx = -offset; |
| 8940 |
if (!swiper.params.virtualTranslate) tx -= swiper.translate; |
| 8941 |
var ty = 0; |
| 8942 |
|
| 8943 |
if (!swiper.isHorizontal()) { |
| 8944 |
ty = tx; |
| 8945 |
tx = 0; |
| 8946 |
} |
| 8947 |
|
| 8948 |
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); |
| 8949 |
$slideEl.css({ |
| 8950 |
opacity: slideOpacity |
| 8951 |
}).transform("translate3d(" + tx + "px, " + ty + "px, 0px)"); |
| 8952 |
} |
| 8953 |
}, |
| 8954 |
setTransition: function setTransition(duration) { |
| 8955 |
var swiper = this; |
| 8956 |
var slides = swiper.slides, |
| 8957 |
$wrapperEl = swiper.$wrapperEl; |
| 8958 |
slides.transition(duration); |
| 8959 |
|
| 8960 |
if (swiper.params.virtualTranslate && duration !== 0) { |
| 8961 |
var eventTriggered = false; |
| 8962 |
slides.transitionEnd(function () { |
| 8963 |
if (eventTriggered) return; |
| 8964 |
if (!swiper || swiper.destroyed) return; |
| 8965 |
eventTriggered = true; |
| 8966 |
swiper.animating = false; |
| 8967 |
var triggerEvents = ['webkitTransitionEnd', 'transitionend']; |
| 8968 |
|
| 8969 |
for (var i = 0; i < triggerEvents.length; i += 1) { |
| 8970 |
$wrapperEl.trigger(triggerEvents[i]); |
| 8971 |
} |
| 8972 |
}); |
| 8973 |
} |
| 8974 |
} |
| 8975 |
}; |
| 8976 |
var EffectFade = { |
| 8977 |
name: 'effect-fade', |
| 8978 |
params: { |
| 8979 |
fadeEffect: { |
| 8980 |
crossFade: false |
| 8981 |
} |
| 8982 |
}, |
| 8983 |
create: function create() { |
| 8984 |
var swiper = this; |
| 8985 |
bindModuleMethods(swiper, { |
| 8986 |
fadeEffect: _extends({}, Fade) |
| 8987 |
}); |
| 8988 |
}, |
| 8989 |
on: { |
| 8990 |
beforeInit: function beforeInit(swiper) { |
| 8991 |
if (swiper.params.effect !== 'fade') return; |
| 8992 |
swiper.classNames.push(swiper.params.containerModifierClass + "fade"); |
| 8993 |
var overwriteParams = { |
| 8994 |
slidesPerView: 1, |
| 8995 |
slidesPerColumn: 1, |
| 8996 |
slidesPerGroup: 1, |
| 8997 |
watchSlidesProgress: true, |
| 8998 |
spaceBetween: 0, |
| 8999 |
virtualTranslate: true |
| 9000 |
}; |
| 9001 |
extend(swiper.params, overwriteParams); |
| 9002 |
extend(swiper.originalParams, overwriteParams); |
| 9003 |
}, |
| 9004 |
setTranslate: function setTranslate(swiper) { |
| 9005 |
if (swiper.params.effect !== 'fade') return; |
| 9006 |
swiper.fadeEffect.setTranslate(); |
| 9007 |
}, |
| 9008 |
setTransition: function setTransition(swiper, duration) { |
| 9009 |
if (swiper.params.effect !== 'fade') return; |
| 9010 |
swiper.fadeEffect.setTransition(duration); |
| 9011 |
} |
| 9012 |
} |
| 9013 |
}; |
| 9014 |
|
| 9015 |
var Cube = { |
| 9016 |
setTranslate: function setTranslate() { |
| 9017 |
var swiper = this; |
| 9018 |
var $el = swiper.$el, |
| 9019 |
$wrapperEl = swiper.$wrapperEl, |
| 9020 |
slides = swiper.slides, |
| 9021 |
swiperWidth = swiper.width, |
| 9022 |
swiperHeight = swiper.height, |
| 9023 |
rtl = swiper.rtlTranslate, |
| 9024 |
swiperSize = swiper.size, |
| 9025 |
browser = swiper.browser; |
| 9026 |
var params = swiper.params.cubeEffect; |
| 9027 |
var isHorizontal = swiper.isHorizontal(); |
| 9028 |
var isVirtual = swiper.virtual && swiper.params.virtual.enabled; |
| 9029 |
var wrapperRotate = 0; |
| 9030 |
var $cubeShadowEl; |
| 9031 |
|
| 9032 |
if (params.shadow) { |
| 9033 |
if (isHorizontal) { |
| 9034 |
$cubeShadowEl = $wrapperEl.find('.swiper-cube-shadow'); |
| 9035 |
|
| 9036 |
if ($cubeShadowEl.length === 0) { |
| 9037 |
$cubeShadowEl = $('<div class="swiper-cube-shadow"></div>'); |
| 9038 |
$wrapperEl.append($cubeShadowEl); |
| 9039 |
} |
| 9040 |
|
| 9041 |
$cubeShadowEl.css({ |
| 9042 |
height: swiperWidth + "px" |
| 9043 |
}); |
| 9044 |
} else { |
| 9045 |
$cubeShadowEl = $el.find('.swiper-cube-shadow'); |
| 9046 |
|
| 9047 |
if ($cubeShadowEl.length === 0) { |
| 9048 |
$cubeShadowEl = $('<div class="swiper-cube-shadow"></div>'); |
| 9049 |
$el.append($cubeShadowEl); |
| 9050 |
} |
| 9051 |
} |
| 9052 |
} |
| 9053 |
|
| 9054 |
for (var i = 0; i < slides.length; i += 1) { |
| 9055 |
var $slideEl = slides.eq(i); |
| 9056 |
var slideIndex = i; |
| 9057 |
|
| 9058 |
if (isVirtual) { |
| 9059 |
slideIndex = parseInt($slideEl.attr('data-swiper-slide-index'), 10); |
| 9060 |
} |
| 9061 |
|
| 9062 |
var slideAngle = slideIndex * 90; |
| 9063 |
var round = Math.floor(slideAngle / 360); |
| 9064 |
|
| 9065 |
if (rtl) { |
| 9066 |
slideAngle = -slideAngle; |
| 9067 |
round = Math.floor(-slideAngle / 360); |
| 9068 |
} |
| 9069 |
|
| 9070 |
var progress = Math.max(Math.min($slideEl[0].progress, 1), -1); |
| 9071 |
var tx = 0; |
| 9072 |
var ty = 0; |
| 9073 |
var tz = 0; |
| 9074 |
|
| 9075 |
if (slideIndex % 4 === 0) { |
| 9076 |
tx = -round * 4 * swiperSize; |
| 9077 |
tz = 0; |
| 9078 |
} else if ((slideIndex - 1) % 4 === 0) { |
| 9079 |
tx = 0; |
| 9080 |
tz = -round * 4 * swiperSize; |
| 9081 |
} else if ((slideIndex - 2) % 4 === 0) { |
| 9082 |
tx = swiperSize + round * 4 * swiperSize; |
| 9083 |
tz = swiperSize; |
| 9084 |
} else if ((slideIndex - 3) % 4 === 0) { |
| 9085 |
tx = -swiperSize; |
| 9086 |
tz = 3 * swiperSize + swiperSize * 4 * round; |
| 9087 |
} |
| 9088 |
|
| 9089 |
if (rtl) { |
| 9090 |
tx = -tx; |
| 9091 |
} |
| 9092 |
|
| 9093 |
if (!isHorizontal) { |
| 9094 |
ty = tx; |
| 9095 |
tx = 0; |
| 9096 |
} |
| 9097 |
|
| 9098 |
var transform = "rotateX(" + (isHorizontal ? 0 : -slideAngle) + "deg) rotateY(" + (isHorizontal ? slideAngle : 0) + "deg) translate3d(" + tx + "px, " + ty + "px, " + tz + "px)"; |
| 9099 |
|
| 9100 |
if (progress <= 1 && progress > -1) { |
| 9101 |
wrapperRotate = slideIndex * 90 + progress * 90; |
| 9102 |
if (rtl) wrapperRotate = -slideIndex * 90 - progress * 90; |
| 9103 |
} |
| 9104 |
|
| 9105 |
$slideEl.transform(transform); |
| 9106 |
|
| 9107 |
if (params.slideShadows) { |
| 9108 |
// Set shadows |
| 9109 |
var shadowBefore = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); |
| 9110 |
var shadowAfter = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); |
| 9111 |
|
| 9112 |
if (shadowBefore.length === 0) { |
| 9113 |
shadowBefore = $("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>"); |
| 9114 |
$slideEl.append(shadowBefore); |
| 9115 |
} |
| 9116 |
|
| 9117 |
if (shadowAfter.length === 0) { |
| 9118 |
shadowAfter = $("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>"); |
| 9119 |
$slideEl.append(shadowAfter); |
| 9120 |
} |
| 9121 |
|
| 9122 |
if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0); |
| 9123 |
if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0); |
| 9124 |
} |
| 9125 |
} |
| 9126 |
|
| 9127 |
$wrapperEl.css({ |
| 9128 |
'-webkit-transform-origin': "50% 50% -" + swiperSize / 2 + "px", |
| 9129 |
'-moz-transform-origin': "50% 50% -" + swiperSize / 2 + "px", |
| 9130 |
'-ms-transform-origin': "50% 50% -" + swiperSize / 2 + "px", |
| 9131 |
'transform-origin': "50% 50% -" + swiperSize / 2 + "px" |
| 9132 |
}); |
| 9133 |
|
| 9134 |
if (params.shadow) { |
| 9135 |
if (isHorizontal) { |
| 9136 |
$cubeShadowEl.transform("translate3d(0px, " + (swiperWidth / 2 + params.shadowOffset) + "px, " + -swiperWidth / 2 + "px) rotateX(90deg) rotateZ(0deg) scale(" + params.shadowScale + ")"); |
| 9137 |
} else { |
| 9138 |
var shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90; |
| 9139 |
var multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2); |
| 9140 |
var scale1 = params.shadowScale; |
| 9141 |
var scale2 = params.shadowScale / multiplier; |
| 9142 |
var offset = params.shadowOffset; |
| 9143 |
$cubeShadowEl.transform("scale3d(" + scale1 + ", 1, " + scale2 + ") translate3d(0px, " + (swiperHeight / 2 + offset) + "px, " + -swiperHeight / 2 / scale2 + "px) rotateX(-90deg)"); |
| 9144 |
} |
| 9145 |
} |
| 9146 |
|
| 9147 |
var zFactor = browser.isSafari || browser.isWebView ? -swiperSize / 2 : 0; |
| 9148 |
$wrapperEl.transform("translate3d(0px,0," + zFactor + "px) rotateX(" + (swiper.isHorizontal() ? 0 : wrapperRotate) + "deg) rotateY(" + (swiper.isHorizontal() ? -wrapperRotate : 0) + "deg)"); |
| 9149 |
}, |
| 9150 |
setTransition: function setTransition(duration) { |
| 9151 |
var swiper = this; |
| 9152 |
var $el = swiper.$el, |
| 9153 |
slides = swiper.slides; |
| 9154 |
slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); |
| 9155 |
|
| 9156 |
if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) { |
| 9157 |
$el.find('.swiper-cube-shadow').transition(duration); |
| 9158 |
} |
| 9159 |
} |
| 9160 |
}; |
| 9161 |
var EffectCube = { |
| 9162 |
name: 'effect-cube', |
| 9163 |
params: { |
| 9164 |
cubeEffect: { |
| 9165 |
slideShadows: true, |
| 9166 |
shadow: true, |
| 9167 |
shadowOffset: 20, |
| 9168 |
shadowScale: 0.94 |
| 9169 |
} |
| 9170 |
}, |
| 9171 |
create: function create() { |
| 9172 |
var swiper = this; |
| 9173 |
bindModuleMethods(swiper, { |
| 9174 |
cubeEffect: _extends({}, Cube) |
| 9175 |
}); |
| 9176 |
}, |
| 9177 |
on: { |
| 9178 |
beforeInit: function beforeInit(swiper) { |
| 9179 |
if (swiper.params.effect !== 'cube') return; |
| 9180 |
swiper.classNames.push(swiper.params.containerModifierClass + "cube"); |
| 9181 |
swiper.classNames.push(swiper.params.containerModifierClass + "3d"); |
| 9182 |
var overwriteParams = { |
| 9183 |
slidesPerView: 1, |
| 9184 |
slidesPerColumn: 1, |
| 9185 |
slidesPerGroup: 1, |
| 9186 |
watchSlidesProgress: true, |
| 9187 |
resistanceRatio: 0, |
| 9188 |
spaceBetween: 0, |
| 9189 |
centeredSlides: false, |
| 9190 |
virtualTranslate: true |
| 9191 |
}; |
| 9192 |
extend(swiper.params, overwriteParams); |
| 9193 |
extend(swiper.originalParams, overwriteParams); |
| 9194 |
}, |
| 9195 |
setTranslate: function setTranslate(swiper) { |
| 9196 |
if (swiper.params.effect !== 'cube') return; |
| 9197 |
swiper.cubeEffect.setTranslate(); |
| 9198 |
}, |
| 9199 |
setTransition: function setTransition(swiper, duration) { |
| 9200 |
if (swiper.params.effect !== 'cube') return; |
| 9201 |
swiper.cubeEffect.setTransition(duration); |
| 9202 |
} |
| 9203 |
} |
| 9204 |
}; |
| 9205 |
|
| 9206 |
var Flip = { |
| 9207 |
setTranslate: function setTranslate() { |
| 9208 |
var swiper = this; |
| 9209 |
var slides = swiper.slides, |
| 9210 |
rtl = swiper.rtlTranslate; |
| 9211 |
|
| 9212 |
for (var i = 0; i < slides.length; i += 1) { |
| 9213 |
var $slideEl = slides.eq(i); |
| 9214 |
var progress = $slideEl[0].progress; |
| 9215 |
|
| 9216 |
if (swiper.params.flipEffect.limitRotation) { |
| 9217 |
progress = Math.max(Math.min($slideEl[0].progress, 1), -1); |
| 9218 |
} |
| 9219 |
|
| 9220 |
var offset = $slideEl[0].swiperSlideOffset; |
| 9221 |
var rotate = -180 * progress; |
| 9222 |
var rotateY = rotate; |
| 9223 |
var rotateX = 0; |
| 9224 |
var tx = -offset; |
| 9225 |
var ty = 0; |
| 9226 |
|
| 9227 |
if (!swiper.isHorizontal()) { |
| 9228 |
ty = tx; |
| 9229 |
tx = 0; |
| 9230 |
rotateX = -rotateY; |
| 9231 |
rotateY = 0; |
| 9232 |
} else if (rtl) { |
| 9233 |
rotateY = -rotateY; |
| 9234 |
} |
| 9235 |
|
| 9236 |
$slideEl[0].style.zIndex = -Math.abs(Math.round(progress)) + slides.length; |
| 9237 |
|
| 9238 |
if (swiper.params.flipEffect.slideShadows) { |
| 9239 |
// Set shadows |
| 9240 |
var shadowBefore = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); |
| 9241 |
var shadowAfter = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); |
| 9242 |
|
| 9243 |
if (shadowBefore.length === 0) { |
| 9244 |
shadowBefore = $("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'left' : 'top') + "\"></div>"); |
| 9245 |
$slideEl.append(shadowBefore); |
| 9246 |
} |
| 9247 |
|
| 9248 |
if (shadowAfter.length === 0) { |
| 9249 |
shadowAfter = $("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'right' : 'bottom') + "\"></div>"); |
| 9250 |
$slideEl.append(shadowAfter); |
| 9251 |
} |
| 9252 |
|
| 9253 |
if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0); |
| 9254 |
if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0); |
| 9255 |
} |
| 9256 |
|
| 9257 |
$slideEl.transform("translate3d(" + tx + "px, " + ty + "px, 0px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg)"); |
| 9258 |
} |
| 9259 |
}, |
| 9260 |
setTransition: function setTransition(duration) { |
| 9261 |
var swiper = this; |
| 9262 |
var slides = swiper.slides, |
| 9263 |
activeIndex = swiper.activeIndex, |
| 9264 |
$wrapperEl = swiper.$wrapperEl; |
| 9265 |
slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); |
| 9266 |
|
| 9267 |
if (swiper.params.virtualTranslate && duration !== 0) { |
| 9268 |
var eventTriggered = false; // eslint-disable-next-line |
| 9269 |
|
| 9270 |
slides.eq(activeIndex).transitionEnd(function onTransitionEnd() { |
| 9271 |
if (eventTriggered) return; |
| 9272 |
if (!swiper || swiper.destroyed) return; // if (!$(this).hasClass(swiper.params.slideActiveClass)) return; |
| 9273 |
|
| 9274 |
eventTriggered = true; |
| 9275 |
swiper.animating = false; |
| 9276 |
var triggerEvents = ['webkitTransitionEnd', 'transitionend']; |
| 9277 |
|
| 9278 |
for (var i = 0; i < triggerEvents.length; i += 1) { |
| 9279 |
$wrapperEl.trigger(triggerEvents[i]); |
| 9280 |
} |
| 9281 |
}); |
| 9282 |
} |
| 9283 |
} |
| 9284 |
}; |
| 9285 |
var EffectFlip = { |
| 9286 |
name: 'effect-flip', |
| 9287 |
params: { |
| 9288 |
flipEffect: { |
| 9289 |
slideShadows: true, |
| 9290 |
limitRotation: true |
| 9291 |
} |
| 9292 |
}, |
| 9293 |
create: function create() { |
| 9294 |
var swiper = this; |
| 9295 |
bindModuleMethods(swiper, { |
| 9296 |
flipEffect: _extends({}, Flip) |
| 9297 |
}); |
| 9298 |
}, |
| 9299 |
on: { |
| 9300 |
beforeInit: function beforeInit(swiper) { |
| 9301 |
if (swiper.params.effect !== 'flip') return; |
| 9302 |
swiper.classNames.push(swiper.params.containerModifierClass + "flip"); |
| 9303 |
swiper.classNames.push(swiper.params.containerModifierClass + "3d"); |
| 9304 |
var overwriteParams = { |
| 9305 |
slidesPerView: 1, |
| 9306 |
slidesPerColumn: 1, |
| 9307 |
slidesPerGroup: 1, |
| 9308 |
watchSlidesProgress: true, |
| 9309 |
spaceBetween: 0, |
| 9310 |
virtualTranslate: true |
| 9311 |
}; |
| 9312 |
extend(swiper.params, overwriteParams); |
| 9313 |
extend(swiper.originalParams, overwriteParams); |
| 9314 |
}, |
| 9315 |
setTranslate: function setTranslate(swiper) { |
| 9316 |
if (swiper.params.effect !== 'flip') return; |
| 9317 |
swiper.flipEffect.setTranslate(); |
| 9318 |
}, |
| 9319 |
setTransition: function setTransition(swiper, duration) { |
| 9320 |
if (swiper.params.effect !== 'flip') return; |
| 9321 |
swiper.flipEffect.setTransition(duration); |
| 9322 |
} |
| 9323 |
} |
| 9324 |
}; |
| 9325 |
|
| 9326 |
var Coverflow = { |
| 9327 |
setTranslate: function setTranslate() { |
| 9328 |
var swiper = this; |
| 9329 |
var swiperWidth = swiper.width, |
| 9330 |
swiperHeight = swiper.height, |
| 9331 |
slides = swiper.slides, |
| 9332 |
slidesSizesGrid = swiper.slidesSizesGrid; |
| 9333 |
var params = swiper.params.coverflowEffect; |
| 9334 |
var isHorizontal = swiper.isHorizontal(); |
| 9335 |
var transform = swiper.translate; |
| 9336 |
var center = isHorizontal ? -transform + swiperWidth / 2 : -transform + swiperHeight / 2; |
| 9337 |
var rotate = isHorizontal ? params.rotate : -params.rotate; |
| 9338 |
var translate = params.depth; // Each slide offset from center |
| 9339 |
|
| 9340 |
for (var i = 0, length = slides.length; i < length; i += 1) { |
| 9341 |
var $slideEl = slides.eq(i); |
| 9342 |
var slideSize = slidesSizesGrid[i]; |
| 9343 |
var slideOffset = $slideEl[0].swiperSlideOffset; |
| 9344 |
var offsetMultiplier = (center - slideOffset - slideSize / 2) / slideSize * params.modifier; |
| 9345 |
var rotateY = isHorizontal ? rotate * offsetMultiplier : 0; |
| 9346 |
var rotateX = isHorizontal ? 0 : rotate * offsetMultiplier; // var rotateZ = 0 |
| 9347 |
|
| 9348 |
var translateZ = -translate * Math.abs(offsetMultiplier); |
| 9349 |
var stretch = params.stretch; // Allow percentage to make a relative stretch for responsive sliders |
| 9350 |
|
| 9351 |
if (typeof stretch === 'string' && stretch.indexOf('%') !== -1) { |
| 9352 |
stretch = parseFloat(params.stretch) / 100 * slideSize; |
| 9353 |
} |
| 9354 |
|
| 9355 |
var translateY = isHorizontal ? 0 : stretch * offsetMultiplier; |
| 9356 |
var translateX = isHorizontal ? stretch * offsetMultiplier : 0; |
| 9357 |
var scale = 1 - (1 - params.scale) * Math.abs(offsetMultiplier); // Fix for ultra small values |
| 9358 |
|
| 9359 |
if (Math.abs(translateX) < 0.001) translateX = 0; |
| 9360 |
if (Math.abs(translateY) < 0.001) translateY = 0; |
| 9361 |
if (Math.abs(translateZ) < 0.001) translateZ = 0; |
| 9362 |
if (Math.abs(rotateY) < 0.001) rotateY = 0; |
| 9363 |
if (Math.abs(rotateX) < 0.001) rotateX = 0; |
| 9364 |
if (Math.abs(scale) < 0.001) scale = 0; |
| 9365 |
var slideTransform = "translate3d(" + translateX + "px," + translateY + "px," + translateZ + "px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg) scale(" + scale + ")"; |
| 9366 |
$slideEl.transform(slideTransform); |
| 9367 |
$slideEl[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1; |
| 9368 |
|
| 9369 |
if (params.slideShadows) { |
| 9370 |
// Set shadows |
| 9371 |
var $shadowBeforeEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); |
| 9372 |
var $shadowAfterEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); |
| 9373 |
|
| 9374 |
if ($shadowBeforeEl.length === 0) { |
| 9375 |
$shadowBeforeEl = $("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>"); |
| 9376 |
$slideEl.append($shadowBeforeEl); |
| 9377 |
} |
| 9378 |
|
| 9379 |
if ($shadowAfterEl.length === 0) { |
| 9380 |
$shadowAfterEl = $("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>"); |
| 9381 |
$slideEl.append($shadowAfterEl); |
| 9382 |
} |
| 9383 |
|
| 9384 |
if ($shadowBeforeEl.length) $shadowBeforeEl[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0; |
| 9385 |
if ($shadowAfterEl.length) $shadowAfterEl[0].style.opacity = -offsetMultiplier > 0 ? -offsetMultiplier : 0; |
| 9386 |
} |
| 9387 |
} |
| 9388 |
}, |
| 9389 |
setTransition: function setTransition(duration) { |
| 9390 |
var swiper = this; |
| 9391 |
swiper.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); |
| 9392 |
} |
| 9393 |
}; |
| 9394 |
var EffectCoverflow = { |
| 9395 |
name: 'effect-coverflow', |
| 9396 |
params: { |
| 9397 |
coverflowEffect: { |
| 9398 |
rotate: 50, |
| 9399 |
stretch: 0, |
| 9400 |
depth: 100, |
| 9401 |
scale: 1, |
| 9402 |
modifier: 1, |
| 9403 |
slideShadows: true |
| 9404 |
} |
| 9405 |
}, |
| 9406 |
create: function create() { |
| 9407 |
var swiper = this; |
| 9408 |
bindModuleMethods(swiper, { |
| 9409 |
coverflowEffect: _extends({}, Coverflow) |
| 9410 |
}); |
| 9411 |
}, |
| 9412 |
on: { |
| 9413 |
beforeInit: function beforeInit(swiper) { |
| 9414 |
if (swiper.params.effect !== 'coverflow') return; |
| 9415 |
swiper.classNames.push(swiper.params.containerModifierClass + "coverflow"); |
| 9416 |
swiper.classNames.push(swiper.params.containerModifierClass + "3d"); |
| 9417 |
swiper.params.watchSlidesProgress = true; |
| 9418 |
swiper.originalParams.watchSlidesProgress = true; |
| 9419 |
}, |
| 9420 |
setTranslate: function setTranslate(swiper) { |
| 9421 |
if (swiper.params.effect !== 'coverflow') return; |
| 9422 |
swiper.coverflowEffect.setTranslate(); |
| 9423 |
}, |
| 9424 |
setTransition: function setTransition(swiper, duration) { |
| 9425 |
if (swiper.params.effect !== 'coverflow') return; |
| 9426 |
swiper.coverflowEffect.setTransition(duration); |
| 9427 |
} |
| 9428 |
} |
| 9429 |
}; |
| 9430 |
|
| 9431 |
var Thumbs = { |
| 9432 |
init: function init() { |
| 9433 |
var swiper = this; |
| 9434 |
var thumbsParams = swiper.params.thumbs; |
| 9435 |
if (swiper.thumbs.initialized) return false; |
| 9436 |
swiper.thumbs.initialized = true; |
| 9437 |
var SwiperClass = swiper.constructor; |
| 9438 |
|
| 9439 |
if (thumbsParams.swiper instanceof SwiperClass) { |
| 9440 |
swiper.thumbs.swiper = thumbsParams.swiper; |
| 9441 |
extend(swiper.thumbs.swiper.originalParams, { |
| 9442 |
watchSlidesProgress: true, |
| 9443 |
slideToClickedSlide: false |
| 9444 |
}); |
| 9445 |
extend(swiper.thumbs.swiper.params, { |
| 9446 |
watchSlidesProgress: true, |
| 9447 |
slideToClickedSlide: false |
| 9448 |
}); |
| 9449 |
} else if (isObject(thumbsParams.swiper)) { |
| 9450 |
swiper.thumbs.swiper = new SwiperClass(extend({}, thumbsParams.swiper, { |
| 9451 |
watchSlidesVisibility: true, |
| 9452 |
watchSlidesProgress: true, |
| 9453 |
slideToClickedSlide: false |
| 9454 |
})); |
| 9455 |
swiper.thumbs.swiperCreated = true; |
| 9456 |
} |
| 9457 |
|
| 9458 |
swiper.thumbs.swiper.$el.addClass(swiper.params.thumbs.thumbsContainerClass); |
| 9459 |
swiper.thumbs.swiper.on('tap', swiper.thumbs.onThumbClick); |
| 9460 |
return true; |
| 9461 |
}, |
| 9462 |
onThumbClick: function onThumbClick() { |
| 9463 |
var swiper = this; |
| 9464 |
var thumbsSwiper = swiper.thumbs.swiper; |
| 9465 |
if (!thumbsSwiper) return; |
| 9466 |
var clickedIndex = thumbsSwiper.clickedIndex; |
| 9467 |
var clickedSlide = thumbsSwiper.clickedSlide; |
| 9468 |
if (clickedSlide && $(clickedSlide).hasClass(swiper.params.thumbs.slideThumbActiveClass)) return; |
| 9469 |
if (typeof clickedIndex === 'undefined' || clickedIndex === null) return; |
| 9470 |
var slideToIndex; |
| 9471 |
|
| 9472 |
if (thumbsSwiper.params.loop) { |
| 9473 |
slideToIndex = parseInt($(thumbsSwiper.clickedSlide).attr('data-swiper-slide-index'), 10); |
| 9474 |
} else { |
| 9475 |
slideToIndex = clickedIndex; |
| 9476 |
} |
| 9477 |
|
| 9478 |
if (swiper.params.loop) { |
| 9479 |
var currentIndex = swiper.activeIndex; |
| 9480 |
|
| 9481 |
if (swiper.slides.eq(currentIndex).hasClass(swiper.params.slideDuplicateClass)) { |
| 9482 |
swiper.loopFix(); // eslint-disable-next-line |
| 9483 |
|
| 9484 |
swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; |
| 9485 |
currentIndex = swiper.activeIndex; |
| 9486 |
} |
| 9487 |
|
| 9488 |
var prevIndex = swiper.slides.eq(currentIndex).prevAll("[data-swiper-slide-index=\"" + slideToIndex + "\"]").eq(0).index(); |
| 9489 |
var nextIndex = swiper.slides.eq(currentIndex).nextAll("[data-swiper-slide-index=\"" + slideToIndex + "\"]").eq(0).index(); |
| 9490 |
if (typeof prevIndex === 'undefined') slideToIndex = nextIndex;else if (typeof nextIndex === 'undefined') slideToIndex = prevIndex;else if (nextIndex - currentIndex < currentIndex - prevIndex) slideToIndex = nextIndex;else slideToIndex = prevIndex; |
| 9491 |
} |
| 9492 |
|
| 9493 |
swiper.slideTo(slideToIndex); |
| 9494 |
}, |
| 9495 |
update: function update(initial) { |
| 9496 |
var swiper = this; |
| 9497 |
var thumbsSwiper = swiper.thumbs.swiper; |
| 9498 |
if (!thumbsSwiper) return; |
| 9499 |
var slidesPerView = thumbsSwiper.params.slidesPerView === 'auto' ? thumbsSwiper.slidesPerViewDynamic() : thumbsSwiper.params.slidesPerView; |
| 9500 |
var autoScrollOffset = swiper.params.thumbs.autoScrollOffset; |
| 9501 |
var useOffset = autoScrollOffset && !thumbsSwiper.params.loop; |
| 9502 |
|
| 9503 |
if (swiper.realIndex !== thumbsSwiper.realIndex || useOffset) { |
| 9504 |
var currentThumbsIndex = thumbsSwiper.activeIndex; |
| 9505 |
var newThumbsIndex; |
| 9506 |
var direction; |
| 9507 |
|
| 9508 |
if (thumbsSwiper.params.loop) { |
| 9509 |
if (thumbsSwiper.slides.eq(currentThumbsIndex).hasClass(thumbsSwiper.params.slideDuplicateClass)) { |
| 9510 |
thumbsSwiper.loopFix(); // eslint-disable-next-line |
| 9511 |
|
| 9512 |
thumbsSwiper._clientLeft = thumbsSwiper.$wrapperEl[0].clientLeft; |
| 9513 |
currentThumbsIndex = thumbsSwiper.activeIndex; |
| 9514 |
} // Find actual thumbs index to slide to |
| 9515 |
|
| 9516 |
|
| 9517 |
var prevThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).prevAll("[data-swiper-slide-index=\"" + swiper.realIndex + "\"]").eq(0).index(); |
| 9518 |
var nextThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).nextAll("[data-swiper-slide-index=\"" + swiper.realIndex + "\"]").eq(0).index(); |
| 9519 |
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; |
| 9520 |
direction = swiper.activeIndex > swiper.previousIndex ? 'next' : 'prev'; |
| 9521 |
} else { |
| 9522 |
newThumbsIndex = swiper.realIndex; |
| 9523 |
direction = newThumbsIndex > swiper.previousIndex ? 'next' : 'prev'; |
| 9524 |
} |
| 9525 |
|
| 9526 |
if (useOffset) { |
| 9527 |
newThumbsIndex += direction === 'next' ? autoScrollOffset : -1 * autoScrollOffset; |
| 9528 |
} |
| 9529 |
|
| 9530 |
if (thumbsSwiper.visibleSlidesIndexes && thumbsSwiper.visibleSlidesIndexes.indexOf(newThumbsIndex) < 0) { |
| 9531 |
if (thumbsSwiper.params.centeredSlides) { |
| 9532 |
if (newThumbsIndex > currentThumbsIndex) { |
| 9533 |
newThumbsIndex = newThumbsIndex - Math.floor(slidesPerView / 2) + 1; |
| 9534 |
} else { |
| 9535 |
newThumbsIndex = newThumbsIndex + Math.floor(slidesPerView / 2) - 1; |
| 9536 |
} |
| 9537 |
} else if (newThumbsIndex > currentThumbsIndex) { |
| 9538 |
newThumbsIndex = newThumbsIndex - slidesPerView + 1; |
| 9539 |
} |
| 9540 |
|
| 9541 |
thumbsSwiper.slideTo(newThumbsIndex, initial ? 0 : undefined); |
| 9542 |
} |
| 9543 |
} // Activate thumbs |
| 9544 |
|
| 9545 |
|
| 9546 |
var thumbsToActivate = 1; |
| 9547 |
var thumbActiveClass = swiper.params.thumbs.slideThumbActiveClass; |
| 9548 |
|
| 9549 |
if (swiper.params.slidesPerView > 1 && !swiper.params.centeredSlides) { |
| 9550 |
thumbsToActivate = swiper.params.slidesPerView; |
| 9551 |
} |
| 9552 |
|
| 9553 |
if (!swiper.params.thumbs.multipleActiveThumbs) { |
| 9554 |
thumbsToActivate = 1; |
| 9555 |
} |
| 9556 |
|
| 9557 |
thumbsToActivate = Math.floor(thumbsToActivate); |
| 9558 |
thumbsSwiper.slides.removeClass(thumbActiveClass); |
| 9559 |
|
| 9560 |
if (thumbsSwiper.params.loop || thumbsSwiper.params.virtual && thumbsSwiper.params.virtual.enabled) { |
| 9561 |
for (var i = 0; i < thumbsToActivate; i += 1) { |
| 9562 |
thumbsSwiper.$wrapperEl.children("[data-swiper-slide-index=\"" + (swiper.realIndex + i) + "\"]").addClass(thumbActiveClass); |
| 9563 |
} |
| 9564 |
} else { |
| 9565 |
for (var _i = 0; _i < thumbsToActivate; _i += 1) { |
| 9566 |
thumbsSwiper.slides.eq(swiper.realIndex + _i).addClass(thumbActiveClass); |
| 9567 |
} |
| 9568 |
} |
| 9569 |
} |
| 9570 |
}; |
| 9571 |
var Thumbs$1 = { |
| 9572 |
name: 'thumbs', |
| 9573 |
params: { |
| 9574 |
thumbs: { |
| 9575 |
swiper: null, |
| 9576 |
multipleActiveThumbs: true, |
| 9577 |
autoScrollOffset: 0, |
| 9578 |
slideThumbActiveClass: 'swiper-slide-thumb-active', |
| 9579 |
thumbsContainerClass: 'swiper-container-thumbs' |
| 9580 |
} |
| 9581 |
}, |
| 9582 |
create: function create() { |
| 9583 |
var swiper = this; |
| 9584 |
bindModuleMethods(swiper, { |
| 9585 |
thumbs: _extends({ |
| 9586 |
swiper: null, |
| 9587 |
initialized: false |
| 9588 |
}, Thumbs) |
| 9589 |
}); |
| 9590 |
}, |
| 9591 |
on: { |
| 9592 |
beforeInit: function beforeInit(swiper) { |
| 9593 |
var thumbs = swiper.params.thumbs; |
| 9594 |
if (!thumbs || !thumbs.swiper) return; |
| 9595 |
swiper.thumbs.init(); |
| 9596 |
swiper.thumbs.update(true); |
| 9597 |
}, |
| 9598 |
slideChange: function slideChange(swiper) { |
| 9599 |
if (!swiper.thumbs.swiper) return; |
| 9600 |
swiper.thumbs.update(); |
| 9601 |
}, |
| 9602 |
update: function update(swiper) { |
| 9603 |
if (!swiper.thumbs.swiper) return; |
| 9604 |
swiper.thumbs.update(); |
| 9605 |
}, |
| 9606 |
resize: function resize(swiper) { |
| 9607 |
if (!swiper.thumbs.swiper) return; |
| 9608 |
swiper.thumbs.update(); |
| 9609 |
}, |
| 9610 |
observerUpdate: function observerUpdate(swiper) { |
| 9611 |
if (!swiper.thumbs.swiper) return; |
| 9612 |
swiper.thumbs.update(); |
| 9613 |
}, |
| 9614 |
setTransition: function setTransition(swiper, duration) { |
| 9615 |
var thumbsSwiper = swiper.thumbs.swiper; |
| 9616 |
if (!thumbsSwiper) return; |
| 9617 |
thumbsSwiper.setTransition(duration); |
| 9618 |
}, |
| 9619 |
beforeDestroy: function beforeDestroy(swiper) { |
| 9620 |
var thumbsSwiper = swiper.thumbs.swiper; |
| 9621 |
if (!thumbsSwiper) return; |
| 9622 |
|
| 9623 |
if (swiper.thumbs.swiperCreated && thumbsSwiper) { |
| 9624 |
thumbsSwiper.destroy(); |
| 9625 |
} |
| 9626 |
} |
| 9627 |
} |
| 9628 |
}; |
| 9629 |
|
| 9630 |
// Swiper Class |
| 9631 |
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]; |
| 9632 |
Swiper.use(components); |
| 9633 |
|
| 9634 |
return Swiper; |
| 9635 |
|
| 9636 |
}))); |
| 9637 |
|