1/** 2 * Swiper 11.0.6 3 * Most modern mobile touch slider and framework with hardware accelerated transitions 4 * https://swiperjs.com 5 * 6 * Copyright 2014-2024 Vladimir Kharlampidi 7 * 8 * Released under the MIT License 9 * 10 * Released on: February 5, 2024 11 */ 12(function () { 13 'use strict'; 14 var $; 15 /*=========================== 16 Swiper 17 ===========================*/ 18 var Swiper = function (container, params) { 19 if (!(this instanceof Swiper)) return new Swiper(container, params); 20 21 var defaults = { 22 direction: 'horizontal', 23 touchEventsTarget: 'container', 24 initialSlide: 0, 25 speed: 300, 26 // autoplay 27 autoplay: false, 28 autoplayDisableOnInteraction: true, 29 // To support iOS's swipe-to-go-back gesture (when being used in-app, with UIWebView). 30 iOSEdgeSwipeDetection: false, 31 iOSEdgeSwipeThreshold: 20, 32 // Free mode 33 freeMode: false, 34 freeModeMomentum: true, 35 freeModeMomentumRatio: 1, 36 freeModeMomentumBounce: true, 37 freeModeMomentumBounceRatio: 1, 38 freeModeSticky: false, 39 // Set wrapper width 40 setWrapperSize: false, 41 // Virtual Translate 42 virtualTranslate: false, 43 // Effects 44 effect: 'slide', // 'slide' or 'fade' or 'cube' or 'coverflow' 45 coverflow: { 46 rotate: 50, 47 stretch: 0, 48 depth: 100, 49 modifier: 1, 50 slideShadows : true 51 }, 52 cube: { 53 slideShadows: true, 54 shadow: true, 55 shadowOffset: 20, 56 shadowScale: 0.94 57 }, 58 fade: { 59 crossFade: false 60 }, 61 // Parallax 62 parallax: false, 63 // Scrollbar 64 scrollbar: null, 65 scrollbarHide: true, 66 // Keyboard Mousewheel 67 keyboardControl: false, 68 mousewheelControl: false, 69 mousewheelReleaseOnEdges: false, 70 mousewheelInvert: false,
71 mousewheelForceToAxis: false, 72 mousewheelSensitivity: 1, 73 // Hash Navigation 74 hashnav: false, 75 // Slides grid 76 spaceBetween: 0, 77 slidesPerView: 1, 78 slidesPerColumn: 1, 79 slidesPerColumnFill: 'column', 80 slidesPerGroup: 1, 81 centeredSlides: false, 82 slidesOffsetBefore: 0, // in px 83 slidesOffsetAfter: 0, // in px 84 // Round length 85 roundLengths: false, 86 // Touches 87 touchRatio: 1, 88 touchAngle: 45, 89 simulateTouch: true, 90 shortSwipes: true, 91 longSwipes: true, 92 longSwipesRatio: 0.5, 93 longSwipesMs: 300, 94 followFinger: true, 95 onlyExternal: false, 96 threshold: 0, 97 touchMoveStopPropagation: true, 98 // Pagination 99 pagination: null, 100 paginationElement: 'span', 101 paginationClickable: false, 102 paginationHide: false, 103 paginationBulletRender: null, 104 // Resistance 105 resistance: true, 106 resistanceRatio: 0.85, 107 // Next/prev buttons 108 nextButton: null, 109 prevButton: null, 110 // Progress 111 watchSlidesProgress: false, 112 watchSlidesVisibility: false, 113 // Cursor 114 grabCursor: false, 115 // Clicks 116 preventClicks: true, 117 preventClicksPropagation: true, 118 slideToClickedSlide: false, 119 // Lazy Loading 120 lazyLoading: false, 121 lazyLoadingInPrevNext: false, 122 lazyLoadingOnTransitionStart: false, 123 // Images 124 preloadImages: true, 125 updateOnImagesReady: true, 126 // loop 127 loop: false, 128 loopAdditionalSlides: 0, 129 loopedSlides: null, 130 // Control 131 control: undefined, 132 controlInverse: false, 133 controlBy: 'slide', //or 'container' 134 // Swiping/no swiping 135 allowSwipeToPrev: true, 136 allowSwipeToNext: true, 137 swipeHandler: null, //'.swipe-handler', 138 noSwiping: true, 139 noSwipingClass: 'swiper-no-swiping', 140 // NS 141 slideClass: 'swiper-slide', 142 slideActiveClass: 'swiper-slide-active', 143 slideVisibleClass: 'swiper-slide-visible', 144 slideDuplicateClass: 'swiper-slide-duplicate', 145 slideNextClass: 'swiper-slide-next', 146 slidePrevClass: 'swiper-slide-prev', 147 wrapperClass: 'swiper-wrapper', 148 bulletClass: 'swiper-pagination-bullet', 149 bulletActiveClass: 'swiper-pagination-bullet-active', 150 buttonDisabledClass: 'swiper-button-disabled', 151 paginationHiddenClass: 'swiper-pagination-hidden', 152 // Observer 153 observer: false, 154 observeParents: false, 155 // Accessibility 156 a11y: false, 157 prevSlideMessage: 'Previous slide', 158 nextSlideMessage: 'Next slide', 159 firstSlideMessage: 'This is the first slide', 160 lastSlideMessage: 'This is the last slide', 161 paginationBulletMessage: 'Go to slide {{index}}', 162 // Callbacks 163 runCallbacksOnInit: true 164 /* 165 Callbacks: 166 onInit: function (swiper) 167 onDestroy: function (swiper) 168 onClick: function (swiper, e) 169 onTap: function (swiper, e) 170 onDoubleTap: function (swiper, e) 171 onSliderMove: function (swiper, e) 172 onSlideChangeStart: function (swiper) 173 onSlideChangeEnd: function (swiper) 174 onTransitionStart: function (swiper) 175 onTransitionEnd: function (swiper) 176 onImagesReady: function (swiper) 177 onProgress: function (swiper, progress) 178 onTouchStart: function (swiper, e) 179 onTouchMove: function (swiper, e) 180 onTouchMoveOpposite: function (swiper, e) 181 onTouchEnd: function (swiper, e) 182 onReachBeginning: function (swiper) 183 onReachEnd: function (swiper) 184 onSetTransition: function (swiper, duration) 185 onSetTranslate: function (swiper, translate) 186 onAutoplayStart: function (swiper) 187 onAutoplayStop: function (swiper), 188 onLazyImageLoad: function (swiper, slide, image) 189 onLazyImageReady: function (swiper, slide, image) 190 */ 191 192 }; 193 var initialVirtualTranslate = params && params.virtualTranslate; 194 195 params = params || {}; 196 for (var def in defaults) { 197 if (typeof params[def] === 'undefined') { 198 params[def] = defaults[def]; 199 } 200 else if (typeof params[def] === 'object') { 201 for (var deepDef in defaults[def]) { 202 if (typeof params[def][deepDef] === 'undefined') { 203 params[def][deepDef] = defaults[def][deepDef]; 204 } 205 } 206 } 207 } 208 209 // Swiper 210 var s = this; 211 212 // Version 213 s.version = '3.1.0'; 214 215 // Params 216 s.params = params; 217 218 // Classname 219 s.classNames = []; 220 /*========================= 221 Dom Library and plugins 222 ===========================*/ 223 if (typeof $ !== 'undefined' && typeof Dom7 !== 'undefined'){ 224 $ = Dom7; 225 } 226 if (typeof $ === 'undefined') { 227 if (typeof Dom7 === 'undefined') { 228 $ = window.Dom7 || window.Zepto || window.jQuery; 229 } 230 else { 231 $ = Dom7; 232 } 233 if (!$) return; 234 } 235 // Export it to Swiper instance 236 s.$ = $; 237 238 /*=========================
239 Preparation - Define Container, Wrapper and Pagination 240 ===========================*/ 241 s.container = $(container); 242 if (s.container.length === 0) return; 243 if (s.container.length > 1) { 244 s.container.each(function () { 245 new Swiper(this, params); 246 }); 247 return; 248 } 249 250 // Save instance in container HTML Element and in data 251 s.container[0].swiper = s; 252 s.container.data('swiper', s); 253 254 s.classNames.push('swiper-container-' + s.params.direction); 255 256 if (s.params.freeMode) { 257 s.classNames.push('swiper-container-free-mode'); 258 } 259 if (!s.support.flexbox) { 260 s.classNames.push('swiper-container-no-flexbox'); 261 s.params.slidesPerColumn = 1; 262 } 263 // Enable slides progress when required 264 if (s.params.parallax || s.params.watchSlidesVisibility) { 265 s.params.watchSlidesProgress = true; 266 } 267 // Coverflow / 3D 268 if (['cube', 'coverflow'].indexOf(s.params.effect) >= 0) { 269 if (s.support.transforms3d) { 270 s.params.watchSlidesProgress = true; 271 s.classNames.push('swiper-container-3d'); 272 } 273 else { 274 s.params.effect = 'slide'; 275 } 276 } 277 if (s.params.effect !== 'slide') { 278 s.classNames.push('swiper-container-' + s.params.effect); 279 } 280 if (s.params.effect === 'cube') { 281 s.params.resistanceRatio = 0; 282 s.params.slidesPerView = 1; 283 s.params.slidesPerColumn = 1; 284 s.params.slidesPerGroup = 1; 285 s.params.centeredSlides = false; 286 s.params.spaceBetween = 0; 287 s.params.virtualTranslate = true; 288 s.params.setWrapperSize = false; 289 } 290 if (s.params.effect === 'fade') { 291 s.params.slidesPerView = 1; 292 s.params.slidesPerColumn = 1; 293 s.params.slidesPerGroup = 1; 294 s.params.watchSlidesProgress = true; 295 s.params.spaceBetween = 0; 296 if (typeof initialVirtualTranslate === 'undefined') { 297 s.params.virtualTranslate = true; 298 } 299 } 300 301 // Grab Cursor 302 if (s.params.grabCursor && s.support.touch) { 303 s.params.grabCursor = false; 304 } 305 306 // Wrapper 307 s.wrapper = s.container.children('.' + s.params.wrapperClass); 308 309 // Pagination 310 if (s.params.pagination) { 311 s.paginationContainer = $(s.params.pagination); 312 if (s.params.paginationClickable) { 313 s.paginationContainer.addClass('swiper-pagination-clickable'); 314 } 315 } 316 317 // Is Horizontal 318 function isH() { 319 return s.params.direction === 'horizontal'; 320 } 321 322 // RTL 323 s.rtl = isH() && (s.container[0].dir.toLowerCase() === 'rtl' || s.container.css('direction') === 'rtl'); 324 if (s.rtl) { 325 s.classNames.push('swiper-container-rtl'); 326 } 327 328 // Wrong RTL support 329 if (s.rtl) { 330 s.wrongRTL = s.wrapper.css('display') === '-webkit-box'; 331 } 332 333 // Columns 334 if (s.params.slidesPerColumn > 1) { 335 s.classNames.push('swiper-container-multirow'); 336 } 337 338 // Check for Android 339 if (s.device.android) { 340 s.classNames.push('swiper-container-android'); 341 } 342 343 // Add classes 344 s.container.addClass(s.classNames.join(' ')); 345 346 // Translate 347 s.translate = 0; 348 349 // Progress 350 s.progress = 0; 351 352 // Velocity 353 s.velocity = 0; 354 355 /*========================= 356 Locks, unlocks 357 ===========================*/ 358 s.lockSwipeToNext = function () { 359 s.params.allowSwipeToNext = false; 360 }; 361 s.lockSwipeToPrev = function () { 362 s.params.allowSwipeToPrev = false; 363 }; 364 s.lockSwipes = function () { 365 s.params.allowSwipeToNext = s.params.allowSwipeToPrev = false;
366 }; 367 s.unlockSwipeToNext = function () { 368 s.params.allowSwipeToNext = true; 369 }; 370 s.unlockSwipeToPrev = function () { 371 s.params.allowSwipeToPrev = true; 372 }; 373 s.unlockSwipes = function () { 374 s.params.allowSwipeToNext = s.params.allowSwipeToPrev = true; 375 }; 376 377 /*========================= 378 Round helper 379 ===========================*/ 380 function round(a) { 381 return Math.floor(a); 382 } 383 /*========================= 384 Set grab cursor 385 ===========================*/ 386 if (s.params.grabCursor) { 387 s.container[0].style.cursor = 'move'; 388 s.container[0].style.cursor = '-webkit-grab'; 389 s.container[0].style.cursor = '-moz-grab'; 390 s.container[0].style.cursor = 'grab'; 391 } 392 /*========================= 393 Update on Images Ready 394 ===========================*/ 395 s.imagesToLoad = []; 396 s.imagesLoaded = 0; 397 398 s.loadImage = function (imgElement, src, checkForComplete, callback) { 399 var image; 400 function onReady () { 401 if (callback) callback(); 402 } 403 if (!imgElement.complete || !checkForComplete) { 404 if (src) { 405 image = new window.Image(); 406 image.onload = onReady; 407 image.onerror = onReady; 408 image.src = src; 409 } else { 410 onReady(); 411 } 412 413 } else {//image already loaded... 414 onReady(); 415 } 416 }; 417 s.preloadImages = function () { 418 s.imagesToLoad = s.container.find('img'); 419 function _onReady() { 420 if (typeof s === 'undefined' || s === null) return; 421 if (s.imagesLoaded !== undefined) s.imagesLoaded++; 422 if (s.imagesLoaded === s.imagesToLoad.length) { 423 if (s.params.updateOnImagesReady) s.update(); 424 s.emit('onImagesReady', s); 425 } 426 } 427 for (var i = 0; i < s.imagesToLoad.length; i++) { 428 s.loadImage(s.imagesToLoad[i], (s.imagesToLoad[i].currentSrc || s.imagesToLoad[i].getAttribute('src')), true, _onReady); 429 } 430 }; 431 432 /*========================= 433 Autoplay 434 ===========================*/ 435 s.autoplayTimeoutId = undefined; 436 s.autoplaying = false; 437 s.autoplayPaused = false; 438 function autoplay() { 439 s.autoplayTimeoutId = setTimeout(function () { 440 if (s.params.loop) { 441 s.fixLoop(); 442 s._slideNext(); 443 } 444 else { 445 if (!s.isEnd) { 446 s._slideNext(); 447 } 448 else { 449 if (!params.autoplayStopOnLast) { 450 s._slideTo(0); 451 } 452 else { 453 s.stopAutoplay(); 454 } 455 } 456 } 457 }, s.params.autoplay); 458 } 459 s.startAutoplay = function () { 460 if (typeof s.autoplayTimeoutId !== 'undefined') return false; 461 if (!s.params.autoplay) return false; 462 if (s.autoplaying) return false; 463 s.autoplaying = true; 464 s.emit('onAutoplayStart', s); 465 autoplay(); 466 }; 467 s.stopAutoplay = function (internal) { 468 if (!s.autoplayTimeoutId) return; 469 if (s.autoplayTimeoutId) clearTimeout(s.autoplayTimeoutId); 470 s.autoplaying = false; 471 s.autoplayTimeoutId = undefined; 472 s.emit('onAutoplayStop', s); 473 }; 474 s.pauseAutoplay = function (speed) { 475 if (s.autoplayPaused) return; 476 if (s.autoplayTimeoutId) clearTimeout(s.autoplayTimeoutId); 477 s.autoplayPaused = true; 478 if (speed === 0) { 479 s.autoplayPaused = false;
480 autoplay(); 481 } 482 else { 483 s.wrapper.transitionEnd(function () { 484 if (!s) return; 485 s.autoplayPaused = false; 486 if (!s.autoplaying) { 487 s.stopAutoplay(); 488 } 489 else { 490 autoplay(); 491 } 492 }); 493 } 494 }; 495 /*========================= 496 Min/Max Translate 497 ===========================*/ 498 s.minTranslate = function () { 499 return (-s.snapGrid[0]); 500 }; 501 s.maxTranslate = function () { 502 return (-s.snapGrid[s.snapGrid.length - 1]); 503 }; 504 /*========================= 505 Slider/slides sizes 506 ===========================*/ 507 s.updateContainerSize = function () { 508 var width, height; 509 if (typeof s.params.width !== 'undefined') { 510 width = s.params.width; 511 } 512 else { 513 width = s.container[0].clientWidth; 514 } 515 if (typeof s.params.height !== 'undefined') { 516 height = s.params.height; 517 } 518 else { 519 height = s.container[0].clientHeight; 520 } 521 if (width === 0 && isH() || height === 0 && !isH()) { 522 return; 523 } 524 525 //Subtract paddings 526 width = width - parseInt(s.container.css('padding-left'), 10) - parseInt(s.container.css('padding-right'), 10); 527 height = height - parseInt(s.container.css('padding-top'), 10) - parseInt(s.container.css('padding-bottom'), 10); 528 529 // Store values 530 s.width = width; 531 s.height = height; 532 s.size = isH() ? s.width : s.height; 533 }; 534 535 s.updateSlidesSize = function () { 536 s.slides = s.wrapper.children('.' + s.params.slideClass); 537 s.snapGrid = []; 538 s.slidesGrid = []; 539 s.slidesSizesGrid = []; 540 541 var spaceBetween = s.params.spaceBetween, 542 slidePosition = -s.params.slidesOffsetBefore, 543 i, 544 prevSlideSize = 0, 545 index = 0; 546 if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) { 547 spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s.size; 548 } 549 550 s.virtualSize = -spaceBetween; 551 // reset margins 552 if (s.rtl) s.slides.css({marginLeft: '', marginTop: ''}); 553 else s.slides.css({marginRight: '', marginBottom: ''}); 554 555 var slidesNumberEvenToRows; 556 if (s.params.slidesPerColumn > 1) { 557 if (Math.floor(s.slides.length / s.params.slidesPerColumn) === s.slides.length / s.params.slidesPerColumn) { 558 slidesNumberEvenToRows = s.slides.length; 559 } 560 else { 561 slidesNumberEvenToRows = Math.ceil(s.slides.length / s.params.slidesPerColumn) * s.params.slidesPerColumn; 562 } 563 } 564 565 // Calc slides 566 var slideSize; 567 var slidesPerColumn = s.params.slidesPerColumn; 568 var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn; 569 var numFullColumns = slidesPerRow - (s.params.slidesPerColumn * slidesPerRow - s.slides.length); 570 for (i = 0; i < s.slides.length; i++) { 571 slideSize = 0; 572 var slide = s.slides.eq(i); 573 if (s.params.slidesPerColumn > 1) { 574 // Set slides order 575 var newSlideOrderIndex; 576 var column, row; 577 if (s.params.slidesPerColumnFill === 'column') { 578 column = Math.floor(i / slidesPerColumn); 579 row = i - column * slidesPerColumn; 580 if (column > numFullColumns || (column === numFullColumns && row === slidesPerColumn-1)) { 581 if (++row >= slidesPerColumn) { 582 row = 0; 583 column++; 584 } 585 } 586 newSlideOrderIndex = column + row * slidesNumber
586EvenToRows / slidesPerColumn; 587 slide 588 .css({ 589 '-webkit-box-ordinal-group': newSlideOrderIndex, 590 '-moz-box-ordinal-group': newSlideOrderIndex, 591 '-ms-flex-order': newSlideOrderIndex, 592 '-webkit-order': newSlideOrderIndex, 593 'order': newSlideOrderIndex 594 }); 595 } 596 else { 597 row = Math.floor(i / slidesPerRow); 598 column = i - row * slidesPerRow; 599 } 600 slide 601 .css({ 602 'margin-top': (row !== 0 && s.params.spaceBetween) && (s.params.spaceBetween + 'px') 603 }) 604 .attr('data-swiper-column', column) 605 .attr('data-swiper-row', row); 606 607 } 608 if (slide.css('display') === 'none') continue; 609 if (s.params.slidesPerView === 'auto') { 610 slideSize = isH() ? slide.outerWidth(true) : slide.outerHeight(true); 611 if (s.params.roundLengths) slideSize = round(slideSize); 612 } 613 else { 614 slideSize = (s.size - (s.params.slidesPerView - 1) * spaceBetween) / s.params.slidesPerView; 615 if (s.params.roundLengths) slideSize = round(slideSize); 616 617 if (isH()) { 618 s.slides[i].style.width = slideSize + 'px'; 619 } 620 else { 621 s.slides[i].style.height = slideSize + 'px'; 622 } 623 } 624 s.slides[i].swiperSlideSize = slideSize; 625 s.slidesSizesGrid.push(slideSize); 626 627 628 if (s.params.centeredSlides) { 629 slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween; 630 if (i === 0) slidePosition = slidePosition - s.size / 2 - spaceBetween; 631 if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0; 632 if ((index) % s.params.slidesPerGroup === 0) s.snapGrid.push(slidePosition); 633 s.slidesGrid.push(slidePosition); 634 } 635 else { 636 if ((index) % s.params.slidesPerGroup === 0) s.snapGrid.push(slidePosition); 637 s.slidesGrid.push(slidePosition); 638 slidePosition = slidePosition + slideSize + spaceBetween; 639 } 640 641 s.virtualSize += slideSize + spaceBetween; 642 643 prevSlideSize = slideSize; 644 645 index ++; 646 } 647 s.virtualSize = Math.max(s.virtualSize, s.size) + s.params.slidesOffsetAfter; 648 649 var newSlidesGrid; 650 651 if ( 652 s.rtl && s.wrongRTL && (s.params.effect === 'slide' || s.params.effect === 'coverflow')) { 653 s.wrapper.css({width: s.virtualSize + s.params.spaceBetween + 'px'}); 654 } 655 if (!s.support.flexbox || s.params.setWrapperSize) { 656 if (isH()) s.wrapper.css({width: s.virtualSize + s.params.spaceBetween + 'px'}); 657 else s.wrapper.css({height: s.virtualSize + s.params.spaceBetween + 'px'}); 658 } 659 660 if (s.params.slidesPerColumn > 1) { 661 s.virtualSize = (slideSize + s.params.spaceBetween) * slidesNumberEvenToRows; 662 s.virtualSize = Math.ceil(s.virtualSize / s.params.slidesPerColumn) - s.params.spaceBetween; 663 s.wrapper.css({width: s.virtualSize + s.params.spaceBetween + 'px'}); 664 if (s.params.centeredSlides) { 665 newSlidesGrid = []; 666 for (i = 0; i < s.snapGrid.length; i++) { 667 if (s.snapGrid[i] < s.virtualSize + s.snapGrid[0]) newSlidesGrid.push(s.snapGrid[i]); 668 } 669 s.snapGrid = newSlidesGrid; 670 } 671 } 672 673 // Remove last grid elements depending on width 674 if (!s.params.centeredSlides) { 675 newSlidesGrid = []; 676 for (i = 0; i < s.snapGrid.length; i++) { 677 if (s.snapGrid[i] <= s.virtualSize - s.size) { 678 newSlidesGrid.push(s.snapGrid[i]); 679 } 680 } 681 s.snapGrid = newSlidesGrid; 682 if (Math.floor(s.virtualSize - s.size) > Math.floor(s.snapGrid[s.snapGrid.length - 1])) { 683 s.snapGrid.push(s.virtualSize - s.size); 684 } 685 } 686 if (s.snapGrid.length === 0) s.snapGrid = [0]; 687 688 if (s.params.spaceBetween !== 0) { 689 if (isH()) { 690 if (s.rtl) s.slides.css({marginLeft: spaceBetween + 'px'}); 691 else s.slides.css({marginRight: spaceBetween + 'px'}); 692 } 693 else s.slides.css({marginBottom: spaceBetween + 'px'}); 694 } 695 if (s.params.watchSlidesProgress) { 696 s.updateSlidesOffset(); 697 } 698 }; 699 s.updateSlidesOffset = function () { 700 for (var i = 0; i < s.slides.length; i++) { 701 s.slides[i].swiperSlideOffset = isH() ? s.slides[i].offsetLeft : s.slides[i].offsetTop; 702 } 703 }; 704 705 /*========================= 706 Slider/slides progress 707 ===========================*/ 708 s.updateSlidesProgress = function (translate) { 709 if (typeof translate === 'undefined') { 710 translate = s.translate || 0; 711 } 712 if (s.slides.length === 0) return; 713 if (typeof s.slides[0].swiperSlideOffset === 'undefined') s.updateSlidesOffset(); 714 715 var offsetCenter = -translate; 716 if (s.rtl) offsetCenter = translate; 717 718 // Visible Slides 719 var containerBox = s.container[0].getBoundingClientRect(); 720 var sideBefore = isH() ? 'left' : 'top'; 721 var sideAfter = isH() ? 'right' : 'bottom'; 722 s.slides.removeClass(s.params.slideVisibleClass); 723 for (var i = 0; i < s.slides.length; i++) { 724 var slide = s.slides[i]; 725 var slideProgress = (offsetCenter - slide.swiperSlideOffset) / (slide.swiperSlideSize + s.params.spaceBetween); 726 if (s.params.watchSlidesVisibility) { 727 var slideBefore = -(offsetCenter - slide.swiperSlideOffset); 728 var slideAfter = slideBefore + s.slidesSizesGrid[i]; 729 var isVisible = 730 (slideBefore >= 0 && slideBefore < s.size) || 731 (slideAfter > 0 && slideAfter <= s.size) || 732 (slideBefore <= 0 && slideAfter >= s.size); 733 if (isVisible) { 734 s.slides.eq(i).addClass(s.params.slideVisibleClass); 735 } 736 } 737 slide.progress = s.rtl ? -slideProgress : slideProgress; 738 } 739 }; 740 s.updateProgress = function (translate) { 741 if (typeof translate === 'undefined') { 742 translate = s.translate || 0; 743 } 744 var translatesDiff = s.maxTranslate() - s.minTranslate(); 745 if (translatesDiff === 0) { 746 s.progress = 0; 747 s.isBeginning = s.isEnd = true; 748 } 749 else { 750 s.progress = (translate - s.minTranslate()) / (translatesDiff); 751 s.isBeginning = s.progress <= 0; 752 s.isEnd = s.progress >= 1; 753 } 754 if (s.isBeginning) s.emit('onReachBeginning', s); 755 if (s.isEnd) s.emit('onReachEnd', s); 756 757 if (s.params.watchSlidesProgress) s.updateSlidesProgress(translate); 758 s.emit('onProgress', s, s.progress); 759 }; 760 s.updateActiveIndex = function () { 761 var translate = s.rtl ? s.translate : -s.translate; 762 var newActiveIndex, i, snapIndex; 763 for (i = 0; i < s.slidesGrid.length; i ++) { 764 if (typeof s.slidesGrid[i + 1] !== 'undefined') { 765 if (translate >= s.slidesGrid[i] && translate < s.slidesGrid[i + 1] - (s.slidesGrid[i + 1] - s.slidesGrid[i]) / 2) { 766 newActiveIndex = i; 767 } 768 else if (translate >= s.slidesGrid[i] && translate < s.slidesGrid[i + 1]) { 769 newActiveIndex = i + 1; 770 } 771 } 772 else { 773 if (translate >= s.slidesGrid[i]) { 774 newActiveIndex = i; 775 } 776 } 777 } 778 // Normalize slideIndex 779 if (newActiveIndex < 0 || typeof newActiveIndex === 'undefined') newActiveIndex = 0; 780 // for (i = 0; i < s.slidesGrid.length; i++) { 781 // if (- translate >= s.slidesGrid[i]) { 782 // newActiveIndex = i; 783 // } 784 // } 785 snapIndex = Math.floor(newActiveIndex / s.params.slidesPerGroup); 786 if (snapIndex >= s.snapGrid.length) snapIndex = s.snapGrid.length - 1; 787 788 if (newActiveIndex === s.activeIndex) { 789 return; 790 } 791 s.snapIndex = snapIndex; 792 s.previousIndex = s.activeIndex; 793 s.activeIndex = newActiveIndex; 794 s.updateClasses(); 795 }; 796 797 /*========================= 798 Classes 799 ===========================*/ 800 s.updateClasses = function () { 801 s.slides.removeClass(s.params.slideActiveClass + ' ' + s.params.slideNextClass + ' ' + s.params.slidePrevClass); 802 var activeSlide = s.slides.eq(s.activeIndex); 803 // Active classes 804 activeSlide.addClass(s.params.slideActiveClass); 805 activeSlide.next('.' + s.params.slideClass).addClass(s.params.slideNextClass); 806 activeSlide.prev('.' + s.params.slideClass).addClass(s.params.slidePrevClass); 807 808 // Pagination 809 if (s.bullets && s.bullets.length > 0) { 810 s.bullets.removeClass(s.params.bulletActiveClass); 811 var bulletIndex; 812 if (s.params.loop) { 813 bulletIndex = Math.ceil(s.activeIndex - s.loopedSlides)/s.params.slidesPerGroup; 814 if (bulletIndex > s.slides.length - 1 - s.loopedSlides * 2) { 815 bulletIndex = bulletIndex - (s.slides.length - s.loopedSlides * 2); 816 } 817 if (bulletIndex > s.bullets.length - 1) bulletIndex = bulletIndex - s.bullets.length; 818 } 819 else { 820 if (typeof s.snapIndex !== 'undefined') { 821 bulletIndex = s.snapIndex; 822 } 823 else { 824 bulletIndex = s.activeIndex || 0; 825 } 826 } 827 if (s.paginationContainer.length > 1) { 828 s.bullets.each(function () { 829 if ($(this).index() === bulletIndex) $(this).addClass(s.params.bulletActiveClass); 830 }); 831 } 832 else { 833 s.bullets.eq(bulletIndex).addClass(s.params.bulletActiveClass); 834 } 835 } 836 837 // Next/active buttons 838 if (!s.params.loop) { 839 if (s.params.prevButton) { 840 if (s.isBeginning) { 841 $(s.params.prevButton).addClass(s.params.buttonDisabledClass); 842 if (s.params.a11y && s.a11y) s.a11y.disable($(s.params.prevButton)); 843 } 844 else { 845 $(s.params.prevButton).removeClass(s.params.buttonDisabledClass); 846 if (s.params.a11y && s.a11y) s.a11y.enable($(s.params.prevButton)); 847 } 848 } 849 if (s.params.nextButton) { 850 if (s.isEnd) { 851 $(s.params.nextButton).addClass(s.params.buttonDisabledClass); 852 if (s.params.a11y && s.a11y) s.a11y.disable($(s.params.nextButton)); 853 } 854 else { 855 $(s.params.nextButton).removeClass(s.params.buttonDisabledClass); 856 if (s.params.a11y && s.a11y) s.a11y.enable($(s.params.nextButton)); 857 } 858 } 859 } 860 }; 861 862 /*========================= 863 Pagination 864 ===========================*/ 865 s.updatePagination = function () { 866 if (!s.params.pagination) return; 867 if (s.paginationContainer && s.paginationContainer.length > 0) { 868 var bulletsHTML = ''; 869 var numberOfBullets = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length; 870 for (var i = 0; i < numberOfBullets; i++) { 871 if (s.params.paginationBulletRender) { 872 bulletsHTML += s.params.paginationBulletRender(i, s.params.bulletClass); 873 } 874 else { 875 bulletsHTML += '<' + s.params.paginationElement+' class="' + s.params.bulletClass + '"></' + s.params.paginationElement + '>'; 876 } 877 } 878 s.paginationContainer.html(bulletsHTML); 879 s.bullets = s.paginationContainer.find('.' + s.params.bulletClass); 880 if (s.params.paginationClickable && s.params.a11y && s.a11y) { 881 s.a11y.initPagination(); 882 } 883 } 884 }; 885 /*========================= 886 Common update method 887 ===========================*/ 888 s.update = function (updateTranslate) { 889 s.updateContainerSize(); 890 s.updateSlidesSize(); 891 s.updateProgress(); 892 s.updatePagination(); 893 s.updateClasses(); 894 if (s.params.scrollbar && s.scrollbar) { 895 s.scrollbar.set(); 896 } 897 function forceSetTranslate() { 898 newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate()); 899 s.setWrapperTranslate(newTranslate); 900 s.updateActiveIndex(); 901 s.updateClasses(); 902 } 903 if (updateTranslate) { 904 var translated, newTranslate; 905 if (s.controller && s.controller.spline) { 906 s.controller.spline = undefined; 907 } 908 if (s.params.freeMode) { 909 forceSetTranslate(); 910 } 911 else { 912 if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) { 913 translated = s.slideTo(s.slides.length - 1, 0, false, true); 914 } 915 else { 916 translated = s.slideTo(s.activeIndex, 0, false, true); 917 } 918 if (!translated) { 919 forceSetTranslate(); 920 } 921 } 922 923 } 924 }; 925 926 /*========================= 927 Resize Handler 928 ===========================*/ 929 s.onResize = function (forceUpdatePagination) { 930 // Disable locks on resize 931 var allowSwipeToPrev = s.params.allowSwipeToPrev; 932 var allowSwipeToNext = s.params.allowSwipeToNext; 933 s.params.allowSwipeToPrev = s.params.allowSwipeToNext = true; 934 935 s.updateContainerSize(); 936 s.updateSlidesSize(); 937 if (s.params.slidesPerView === 'auto' || s.params.freeMode || force
937UpdatePagination) s.updatePagination(); 938 if (s.params.scrollbar && s.scrollbar) { 939 s.scrollbar.set(); 940 } 941 if (s.controller && s.controller.spline) { 942 s.controller.spline = undefined; 943 } 944 if (s.params.freeMode) { 945 var newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate()); 946 s.setWrapperTranslate(newTranslate); 947 s.updateActiveIndex(); 948 s.updateClasses(); 949 } 950 else { 951 s.updateClasses(); 952 if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) { 953 s.slideTo(s.slides.length - 1, 0, false, true); 954 } 955 else { 956 s.slideTo(s.activeIndex, 0, false, true); 957 } 958 } 959 // Return locks after resize 960 s.params.allowSwipeToPrev = allowSwipeToPrev; 961 s.params.allowSwipeToNext = allowSwipeToNext; 962 }; 963 964 /*========================= 965 Events 966 ===========================*/ 967 968 //Define Touch Events 969 var desktopEvents = ['mousedown', 'mousemove', 'mouseup']; 970 if (window.navigator.pointerEnabled) desktopEvents = ['pointerdown', 'pointermove', 'pointerup']; 971 else if (window.navigator.msPointerEnabled) desktopEvents = ['MSPointerDown', 'MSPointerMove', 'MSPointerUp']; 972 s.touchEvents = { 973 start : s.support.touch || !s.params.simulateTouch ? 'touchstart' : desktopEvents[0], 974 move : s.support.touch || !s.params.simulateTouch ? 'touchmove' : desktopEvents[1], 975 end : s.support.touch || !s.params.simulateTouch ? 'touchend' : desktopEvents[2] 976 }; 977 978 979 // WP8 Touch Events Fix 980 if (window.navigator.pointerEnabled || window.navigator.msPointerEnabled) { 981 (s.params.touchEventsTarget === 'container' ? s.container : s.wrapper).addClass('swiper-wp8-' + s.params.direction); 982 } 983 984 // Attach/detach events 985 s.initEvents = function (detach) { 986 var actionDom = detach ? 'off' : 'on'; 987 var action = detach ? 'removeEventListener' : 'addEventListener'; 988 var touchEventsTarget = s.params.touchEventsTarget === 'container' ? s.container[0] : s.wrapper[0]; 989 var target = s.support.touch ? touchEventsTarget : document; 990 991 var moveCapture = s.params.nested ? true : false; 992 993 //Touch Events 994 if (s.browser.ie) { 995 touchEventsTarget[action](s.touchEvents.start, s.onTouchStart, false); 996 target[action](s.touchEvents.move, s.onTouchMove, moveCapture); 997 target[action](s.touchEvents.end, s.onTouchEnd, false); 998 } 999 else { 1000 if (s.support.touch) { 1001 touchEventsTarget[action](s.touchEvents.start, s.onTouchStart, false); 1002 touchEventsTarget[action](s.touchEvents.move, s.onTouchMove, moveCapture); 1003 touchEventsTarget[action](s.touchEvents.end, s.onTouchEnd, false); 1004 } 1005 if (params.simulateTouch && !s.device.ios && !s.device.android) { 1006 touchEventsTarget[action]('mousedown', s.onTouchStart, false); 1007 document[action]('mousemove', s.onTouchMove, moveCapture); 1008 document[action]('mouseup', s.onTouchEnd, false); 1009 } 1010 } 1011 window[action]('resize', s.onResize); 1012 1013 // Next, Prev, Index 1014 if (s.params.nextButton) { 1015 $(s.params.nextButton)[actionDom]('click', s.onClickNext); 1016 if (s.params.a11y && s.a11y) $(s.params.nextButton)[actionDom]('keydown', s.a11y.onEnterKey); 1017 } 1018 if (s.params.prevButton) { 1019 $(s.params.prevButton)[actionDom]('click', s.onClickPrev); 1020 if (s.params.a11y && s.a11y) $(s.params.prevButton)[actionDom]('keydown', s.a11y.onEnterKey); 1021 } 1022 if (s.params.pagination && s.params.paginationClickable) { 1023 $(s.paginationContainer)[actionDom]('click', '.' + s.params.bulletClass, s.onClickIndex); 1024 if (s.params.a11y && s.a11y) $(s.paginationContainer)[actionDom]('keydown', '.' + s.params.bulletClass, s.a11y.onEnterKey); 1025 } 1026 1027 // Prevent Links Clicks 1028 if (s.params.preventClicks || s.params.preventClicksPropagation) touchEventsTarget[action]('click', s.preventClicks, true); 1029 }; 1030 s.attachEvents = function (detach) { 1031 s.initEvents(); 1032 }; 1033 s.detachEvents = function () { 1034 s.initEvents(true); 1035 }; 1036 1037 /*========================= 1038 Handle Clicks 1039 ===========================*/ 1040 // Prevent Clicks 1041 s.allowClick = true; 1042 s.preventClicks = function (e) { 1043 if (!s.allowClick) { 1044 if (s.params.preventClicks) e.preventDefault(); 1045 if (s.params.preventClicksPropagation && s.animating) { 1046 e.stopPropagation(); 1047 e.stopImmediatePropagation(); 1048 } 1049 } 1050 }; 1051 // Clicks 1052 s.onClickNext = function (e) { 1053 e.preventDefault(); 1054 if (s.isEnd && !s.params.loop) return; 1055 s.slideNext(); 1056 }; 1057 s.onClickPrev = function (e) { 1058 e.preventDefault(); 1059 if (s.isBeginning && !s.params.loop) return; 1060 s.slidePrev(); 1061 }; 1062 s.onClickIndex = function (e) { 1063 e.preventDefault(); 1064 var index = $(this).index() * s.params.slidesPerGroup; 1065 if (s.params.loop) index = index + s.loopedSlides; 1066 s.slideTo(index); 1067 }; 1068 1069 /*========================= 1070 Handle Touches 1071 ===========================*/ 1072 function findElementInEvent(e, selector) { 1073 var el = $(e.target); 1074 if (!el.is(selector)) { 1075 if (typeof selector === 'string') { 1076 el = el.parents(selector); 1077 } 1078 else if (selector.nodeType) { 1079 var found; 1080 el.parents().each(function (index, _el) { 1081 if (_el === selector) found = selector; 1082 }); 1083 if (!found) return undefined; 1084 else return selector; 1085 } 1086 } 1087 if (el.length === 0) { 1088 return undefined; 1089 } 1090 return el[0]; 1091 } 1092 s.updateClickedSlide = function (e) { 1093 var slide = findElementInEvent(e, '.' + s.params.slideClass); 1094 var slideFound = false;
1095 if (slide) { 1096 for (var i = 0; i < s.slides.length; i++) { 1097 if (s.slides[i] === slide) slideFound = true; 1098 } 1099 } 1100 1101 if (slide && slideFound) { 1102 s.clickedSlide = slide; 1103 s.clickedIndex = $(slide).index(); 1104 } 1105 else { 1106 s.clickedSlide = undefined; 1107 s.clickedIndex = undefined; 1108 return; 1109 } 1110 if (s.params.slideToClickedSlide && s.clickedIndex !== undefined && s.clickedIndex !== s.activeIndex) { 1111 var slideToIndex = s.clickedIndex, 1112 realIndex; 1113 if (s.params.loop) { 1114 realIndex = $(s.clickedSlide).attr('data-swiper-slide-index'); 1115 if (slideToIndex > s.slides.length - s.params.slidesPerView) { 1116 s.fixLoop(); 1117 slideToIndex = s.wrapper.children('.' + s.params.slideClass + '[data-swiper-slide-index="' + realIndex + '"]').eq(0).index(); 1118 setTimeout(function () { 1119 s.slideTo(slideToIndex); 1120 }, 0); 1121 } 1122 else if (slideToIndex < s.params.slidesPerView - 1) { 1123 s.fixLoop(); 1124 var duplicatedSlides = s.wrapper.children('.' + s.params.slideClass + '[data-swiper-slide-index="' + realIndex + '"]'); 1125 slideToIndex = duplicatedSlides.eq(duplicatedSlides.length - 1).index(); 1126 setTimeout(function () { 1127 s.slideTo(slideToIndex); 1128 }, 0); 1129 } 1130 else { 1131 s.slideTo(slideToIndex); 1132 } 1133 } 1134 else { 1135 s.slideTo(slideToIndex); 1136 } 1137 } 1138 }; 1139 1140 var isTouched, 1141 isMoved, 1142 touchStartTime, 1143 isScrolling, 1144 currentTranslate, 1145 startTranslate, 1146 allowThresholdMove, 1147 // Form elements to match 1148 formElements = 'input, select, textarea, button', 1149 // Last click time 1150 lastClickTime = Date.now(), clickTimeout, 1151 //Velocities 1152 velocities = [], 1153 allowMomentumBounce; 1154 1155 // Animating Flag 1156 s.animating = false; 1157 1158 // Touches information 1159 s.touches = { 1160 startX: 0, 1161 startY: 0, 1162 currentX: 0, 1163 currentY: 0, 1164 diff: 0 1165 }; 1166 1167 // Touch handlers 1168 var isTouchEvent, startMoving; 1169 s.onTouchStart = function (e) { 1170 if (e.originalEvent) e = e.originalEvent; 1171 isTouchEvent = e.type === 'touchstart'; 1172 if (!isTouchEvent && 'which' in e && e.which === 3) return; 1173 if (s.params.noSwiping && findElementInEvent(e, '.' + s.params.noSwipingClass)) { 1174 s.allowClick = true; 1175 return; 1176 } 1177 if (s.params.swipeHandler) { 1178 if (!findElementInEvent(e, s.params.swipeHandler)) return; 1179 } 1180 1181 var startX = s.touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; 1182 var startY = s.touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; 1183 1184 // Do NOT start if iOS edge swipe is detected. Otherwise iOS app (UIWebView) cannot swipe-to-go-back anymore 1185 if(s.device.ios && s.params.iOSEdgeSwipeDetection && startX <= s.params.iOSEdgeSwipeThreshold) { 1186 return; 1187 } 1188 1189 isTouched = true; 1190 isMoved = false; 1191 isScrolling = undefined; 1192 startMoving = undefined; 1193 s.touches.startX = startX; 1194 s.touches.startY = startY; 1195 touchStartTime = Date.now(); 1196 s.allowClick = true; 1197 s.updateContainerSize(); 1198 s.swipeDirection = undefined; 1199 if (s.params.threshold > 0) allowThresholdMove = false;
1200 if (e.type !== 'touchstart') { 1201 var preventDefault = true; 1202 if ($(e.target).is(formElements)) preventDefault = false; 1203 if (document.activeElement && $(document.activeElement).is(formElements)) { 1204 document.activeElement.blur(); 1205 } 1206 if (preventDefault) { 1207 e.preventDefault(); 1208 } 1209 } 1210 s.emit('onTouchStart', s, e); 1211 }; 1212 1213 s.onTouchMove = function (e) { 1214 if (e.originalEvent) e = e.originalEvent; 1215 if (isTouchEvent && e.type === 'mousemove') return; 1216 if (e.preventedByNestedSwiper) return; 1217 if (s.params.onlyExternal) { 1218 // isMoved = true; 1219 s.allowClick = false; 1220 if (isTouched) { 1221 s.touches.startX = s.touches.currentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; 1222 s.touches.startY = s.touches.currentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; 1223 touchStartTime = Date.now(); 1224 } 1225 return; 1226 } 1227 if (isTouchEvent && document.activeElement) { 1228 if (e.target === document.activeElement && $(e.target).is(formElements)) { 1229 isMoved = true; 1230 s.allowClick = false; 1231 return; 1232 } 1233 } 1234 1235 s.emit('onTouchMove', s, e); 1236 1237 if (e.targetTouches && e.targetTouches.length > 1) return; 1238 1239 s.touches.currentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; 1240 s.touches.currentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; 1241 1242 if (typeof isScrolling === 'undefined') { 1243 var touchAngle = Math.atan2(Math.abs(s.touches.currentY - s.touches.startY), Math.abs(s.touches.currentX - s.touches.startX)) * 180 / Math.PI; 1244 isScrolling = isH() ? touchAngle > s.params.touchAngle : (90 - touchAngle > s.params.touchAngle); 1245 } 1246 if (isScrolling) { 1247 s.emit('onTouchMoveOpposite', s, e); 1248 } 1249 if (typeof startMoving === 'undefined' && s.browser.ieTouch) { 1250 if (s.touches.currentX !== s.touches.startX || s.touches.currentY !== s.touches.startY) { 1251 startMoving = true; 1252 } 1253 } 1254 if (!isTouched) return; 1255 if (isScrolling) { 1256 isTouched = false; 1257 return; 1258 } 1259 if (!startMoving && s.browser.ieTouch) { 1260 return; 1261 } 1262 s.allowClick = false; 1263 s.emit('onSliderMove', s, e); 1264 e.preventDefault(); 1265 if (s.params.touchMoveStopPropagation && !s.params.nested) { 1266 e.stopPropagation(); 1267 } 1268 1269 if (!isMoved) { 1270 if (params.loop) { 1271 s.fixLoop(); 1272 } 1273 startTranslate = s.getWrapperTranslate(); 1274 s.setWrapperTransition(0); 1275 if (s.animating) { 1276 s.wrapper.trigger('webkitTransitionEnd transitionend oTransitionEnd MSTransitionEnd msTransitionEnd'); 1277 } 1278 if (s.params.autoplay && s.autoplaying) { 1279 if (s.params.autoplayDisableOnInteraction) { 1280 s.stopAutoplay(); 1281 } 1282 else { 1283 s.pauseAutoplay(); 1284 } 1285 } 1286 allowMomentumBounce = false; 1287 //Grab Cursor 1288 if (s.params.grabCursor) { 1289 s.container[0].style.cursor = 'move'; 1290 s.container[0].style.cursor = '-webkit-grabbing'; 1291 s.container[0].style.cursor = '-moz-grabbin'; 1292 s.container[0].style.cursor = 'grabbing'; 1293 } 1294 } 1295 isMoved = true; 1296 1297 var diff = s.touches.diff = isH() ? s.touches.currentX - s.touches.startX : s.touches.currentY - s.touches.startY; 1298 1299 diff = diff * s.params.touchRatio; 1300 if (s.rtl) diff = -diff; 1301 1302 s.swipeDirection = diff > 0 ? 'prev' : 'next'; 1303 currentTranslate = diff + startTranslate; 1304 1305 var disableParentSwiper = true; 1306 if ((diff > 0 && currentTranslate > s.minTranslate())) { 1307 disableParentSwiper = false;
1308 if (s.params.resistance) currentTranslate = s.minTranslate() - 1 + Math.pow(-s.minTranslate() + startTranslate + diff, s.params.resistanceRatio); 1309 } 1310 else if (diff < 0 && currentTranslate < s.maxTranslate()) { 1311 disableParentSwiper = false; 1312 if (s.params.resistance) currentTranslate = s.maxTranslate() + 1 - Math.pow(s.maxTranslate() - startTranslate - diff, s.params.resistanceRatio); 1313 } 1314 1315 if (disableParentSwiper) { 1316 e.preventedByNestedSwiper = true; 1317 } 1318 1319 // Directions locks 1320 if (!s.params.allowSwipeToNext && s.swipeDirection === 'next' && currentTranslate < startTranslate) { 1321 currentTranslate = startTranslate; 1322 } 1323 if (!s.params.allowSwipeToPrev && s.swipeDirection === 'prev' && currentTranslate > startTranslate) { 1324 currentTranslate = startTranslate; 1325 } 1326 1327 if (!s.params.followFinger) return; 1328 1329 // Threshold 1330 if (s.params.threshold > 0) { 1331 if (Math.abs(diff) > s.params.threshold || allowThresholdMove) { 1332 if (!allowThresholdMove) { 1333 allowThresholdMove = true; 1334 s.touches.startX = s.touches.currentX; 1335 s.touches.startY = s.touches.currentY; 1336 currentTranslate = startTranslate; 1337 s.touches.diff = isH() ? s.touches.currentX - s.touches.startX : s.touches.currentY - s.touches.startY; 1338 return; 1339 } 1340 } 1341 else { 1342 currentTranslate = startTranslate; 1343 return; 1344 } 1345 } 1346 // Update active index in free mode 1347 if (s.params.freeMode || s.params.watchSlidesProgress) { 1348 s.updateActiveIndex(); 1349 } 1350 if (s.params.freeMode) { 1351 //Velocity 1352 if (velocities.length === 0) { 1353 velocities.push({ 1354 position: s.touches[isH() ? 'startX' : 'startY'], 1355 time: touchStartTime 1356 }); 1357 } 1358 velocities.push({ 1359 position: s.touches[isH() ? 'currentX' : 'currentY'], 1360 time: (new window.Date()).getTime() 1361 }); 1362 } 1363 // Update progress 1364 s.updateProgress(currentTranslate); 1365 // Update translate 1366 s.setWrapperTranslate(currentTranslate); 1367 }; 1368 s.onTouchEnd = function (e) { 1369 if (e.originalEvent) e = e.originalEvent; 1370 s.emit('onTouchEnd', s, e); 1371 if (!isTouched) return; 1372 //Return Grab Cursor 1373 if (s.params.grabCursor && isMoved && isTouched) { 1374 s.container[0].style.cursor = 'move'; 1375 s.container[0].style.cursor = '-webkit-grab'; 1376 s.container[0].style.cursor = '-moz-grab'; 1377 s.container[0].style.cursor = 'grab'; 1378 } 1379 1380 // Time diff 1381 var touchEndTime = Date.now(); 1382 var timeDiff = touchEndTime - touchStartTime; 1383 1384 // Tap, doubleTap, Click 1385 if (s.allowClick) { 1386 s.updateClickedSlide(e); 1387 s.emit('onTap', s, e); 1388 if (timeDiff < 300 && (touchEndTime - lastClickTime) > 300) { 1389 if (clickTimeout) clearTimeout(clickTimeout); 1390 clickTimeout = setTimeout(function () { 1391 if (!s) return; 1392 if (s.params.paginationHide && s.paginationContainer.length > 0 && !$(e.target).hasClass(s.params.bulletClass)) { 1393 s.paginationContainer.toggleClass(s.params.paginationHiddenClass); 1394 } 1395 s.emit('onClick', s, e); 1396 }, 300); 1397 1398 } 1399 if (timeDiff < 300 && (touchEndTime - lastClickTime) < 300) { 1400 if (clickTimeout) clearTimeout(clickTimeout); 1401 s.emit('onDoubleTap', s, e); 1402 } 1403 } 1404 1405 lastClickTime = Date.now(); 1406 setTimeout(function () { 1407 if (s) s.allowClick = true; 1408 }, 0); 1409 1410 if (!isTouched || !isMoved || !s.swipeDirection || s.touches.diff === 0 || currentTranslate === startTranslate) { 1411 isTouched = isMoved = false;
1412 return; 1413 } 1414 isTouched = isMoved = false; 1415 1416 var currentPos; 1417 if (s.params.followFinger) { 1418 currentPos = s.rtl ? s.translate : -s.translate; 1419 } 1420 else { 1421 currentPos = -currentTranslate; 1422 } 1423 if (s.params.freeMode) { 1424 if (currentPos < -s.minTranslate()) { 1425 s.slideTo(s.activeIndex); 1426 return; 1427 } 1428 else if (currentPos > -s.maxTranslate()) { 1429 if (s.slides.length < s.snapGrid.length) { 1430 s.slideTo(s.snapGrid.length - 1); 1431 } 1432 else { 1433 s.slideTo(s.slides.length - 1); 1434 } 1435 return; 1436 } 1437 1438 if (s.params.freeModeMomentum) { 1439 if (velocities.length > 1) { 1440 var lastMoveEvent = velocities.pop(), velocityEvent = velocities.pop(); 1441 1442 var distance = lastMoveEvent.position - velocityEvent.position; 1443 var time = lastMoveEvent.time - velocityEvent.time; 1444 s.velocity = distance / time; 1445 s.velocity = s.velocity / 2; 1446 if (Math.abs(s.velocity) < 0.02) { 1447 s.velocity = 0; 1448 } 1449 // this implies that the user stopped moving a finger then released. 1450 // There would be no events with distance zero, so the last event is stale. 1451 if (time > 150 || (new window.Date().getTime() - lastMoveEvent.time) > 300) { 1452 s.velocity = 0; 1453 } 1454 } else { 1455 s.velocity = 0; 1456 } 1457 1458 velocities.length = 0; 1459 var momentumDuration = 1000 * s.params.freeModeMomentumRatio; 1460 var momentumDistance = s.velocity * momentumDuration; 1461 1462 var newPosition = s.translate + momentumDistance; 1463 if (s.rtl) newPosition = - newPosition; 1464 var doBounce = false; 1465 var afterBouncePosition; 1466 var bounceAmount = Math.abs(s.velocity) * 20 * s.params.freeModeMomentumBounceRatio; 1467 if (newPosition < s.maxTranslate()) { 1468 if (s.params.freeModeMomentumBounce) { 1469 if (newPosition + s.maxTranslate() < -bounceAmount) { 1470 newPosition = s.maxTranslate() - bounceAmount; 1471 } 1472 afterBouncePosition = s.maxTranslate(); 1473 doBounce = true; 1474 allowMomentumBounce = true; 1475 } 1476 else { 1477 newPosition = s.maxTranslate(); 1478 } 1479 } 1480 else if (newPosition > s.minTranslate()) { 1481 if (s.params.freeModeMomentumBounce) { 1482 if (newPosition - s.minTranslate() > bounceAmount) { 1483 newPosition = s.minTranslate() + bounceAmount; 1484 } 1485 afterBouncePosition = s.minTranslate(); 1486 doBounce = true; 1487 allowMomentumBounce = true; 1488 } 1489 else { 1490 newPosition = s.minTranslate(); 1491 } 1492 } 1493 else if (s.params.freeModeSticky) { 1494 var j = 0, 1495 nextSlide; 1496 for (j = 0; j < s.snapGrid.length; j += 1) { 1497 if (s.snapGrid[j] > -newPosition) { 1498 nextSlide = j; 1499 break; 1500 } 1501 1502 } 1503 if (Math.abs(s.snapGrid[nextSlide] - newPosition) < Math.abs(s.snapGrid[nextSlide - 1] - newPosition) || s.swipeDirection === 'next') { 1504 newPosition = s.snapGrid[nextSlide]; 1505 } else { 1506 newPosition = s.snapGrid[nextSlide - 1]; 1507 } 1508 if (!s.rtl) newPosition = - newPosition; 1509 } 1510 //Fix duration 1511 if (s.velocity !== 0) { 1512 if (s.rtl) { 1513 momentumDuration = Math.abs((-newPosition - s.translate) / s.velocity); 1514 } 1515 else { 1516 momentumDuration = Math.abs((newPosition - s.translate) / s.velocity); 1517 } 1518 } 1519 else if (s.params.freeModeSticky) { 1520 s.slideReset(); 1521 return; 1522 } 1523 1524 if (s.params.freeModeMomentumBounce && doBounce) { 1525 s.updateProgress(afterBouncePosition); 1526 s.setWrapperTransition(momentumDuration); 1527 s.setWrapperTranslate(newPosition); 1528 s.onTransitionStart(); 1529 s.animating = true; 1530 s.wrapper.transitionEnd(function () { 1531 if (!s || !allowMomentumBounce) return; 1532 s.emit('onMomentumBounce', s); 1533 1534 s.setWrapperTransition(s.params.speed); 1535 s.setWrapperTranslate(afterBouncePosition); 1536 s.wrapper.transitionEnd(function () { 1537 if (!s) return; 1538 s.onTransitionEnd(); 1539 }); 1540 }); 1541 } else if (s.velocity) { 1542 s.updateProgress(newPosition); 1543 s.setWrapperTransition(momentumDuration); 1544 s.setWrapperTranslate(newPosition); 1545 s.onTransitionStart(); 1546 if (!s.animating) { 1547 s.animating = true; 1548 s.wrapper.transitionEnd(function () { 1549 if (!s) return; 1550 s.onTransitionEnd(); 1551 }); 1552 } 1553 1554 } else { 1555 s.updateProgress(newPosition); 1556 } 1557 1558 s.updateActiveIndex(); 1559 } 1560 if (!s.params.freeModeMomentum || timeDiff >= s.params.longSwipesMs) { 1561 s.updateProgress(); 1562 s.updateActiveIndex(); 1563 } 1564 return; 1565 } 1566 1567 // Find current slide 1568 var i, stopIndex = 0, groupSize = s.slidesSizesGrid[0]; 1569 for (i = 0; i < s.slidesGrid.length; i += s.params.slidesPerGroup) { 1570 if (typeof s.slidesGrid[i + s.params.slidesPerGroup] !== 'undefined') { 1571 if (currentPos >= s.slidesGrid[i] && currentPos < s.slidesGrid[i + s.params.slidesPerGroup]) { 1572 stopIndex = i; 1573 groupSize = s.slidesGrid[i + s.params.slidesPerGroup] - s.slidesGrid[i]; 1574 } 1575 } 1576 else { 1577 if (currentPos >= s.slidesGrid[i]) { 1578 stopIndex = i; 1579 groupSize = s.slidesGrid[s.slidesGrid.length - 1] - s.slidesGrid[s.slidesGrid.length - 2]; 1580 } 1581 } 1582 } 1583 1584 // Find current slide size 1585 var ratio = (currentPos - s.slidesGrid[stopIndex]) / groupSize; 1586 1587 if (timeDiff > s.params.longSwipesMs) { 1588 // Long touches 1589 if (!s.params.longSwipes) { 1590 s.slideTo(s.activeIndex); 1591 return; 1592 } 1593 if (s.swipeDirection === 'next') { 1594 if (ratio >= s.params.longSwipesRatio) s.slideTo(stopIndex + s.params.slidesPerGroup); 1595 else s.slideTo(stopIndex); 1596 1597 } 1598 if (s.swipeDirection === 'prev') { 1599 if (ratio > (1 - s.params.longSwipesRatio)) s.slideTo(stopIndex + s.params.slidesPerGroup); 1600 else s.slideTo(stopIndex); 1601 } 1602 } 1603 else { 1604 // Short swipes 1605 if (!s.params.shortSwipes) { 1606 s.slideTo(s.activeIndex); 1607 return; 1608 } 1609 if (s.swipeDirection === 'next') { 1610 s.slideTo(stopIndex + s.params.slidesPerGroup); 1611 1612 } 1613 if (s.swipeDirection === 'prev') { 1614 s.slideTo(stopIndex); 1615 } 1616 } 1617 }; 1618 /*========================= 1619 Transitions 1620 ===========================*/ 1621 s._slideTo = function (slideIndex, speed) { 1622 return s.slideTo(slideIndex, speed, true, true); 1623 }; 1624 s.slideTo = function (slideIndex, speed, runCallbacks, internal) { 1625 if (typeof runCallbacks === 'undefined') runCallbacks = true; 1626 if (typeof slideIndex === 'undefined') slideIndex = 0; 1627 if (slideIndex < 0) slideIndex = 0; 1628 s.snapIndex = Math.floor(slideIndex / s.params.slidesPerGroup); 1629 if (s.snapIndex >= s.snapGrid.length) s.snapIndex = s.snapGrid.length - 1; 1630 1631 var translate = - s.snapGrid[s.snapIndex]; 1632 1633 // Stop autoplay 1634 if (s.params.autoplay && s.autoplaying) { 1635 if (internal || !s.params.autoplayDisableOnInteraction) { 1636 s.pauseAutoplay(speed); 1637 } 1638 else { 1639 s.stopAutoplay(); 1640 } 1641 } 1642 // Update progress 1643 s.updateProgress(translate); 1644 1645 // Normalize slideIndex 1646 for (var i = 0; i < s.slidesGrid.length; i++) { 1647 if (- Math.floor(translate * 100) >= Math.floor(s.slidesGrid[i] * 100)) { 1648 slideIndex = i; 1649 } 1650 } 1651 1652 // Directions locks 1653 if (!s.params.allowSwipeToNext && translate < s.translate && translate < s.minTranslate()) { 1654 return false;
1655 } 1656 if (!s.params.allowSwipeToPrev && translate > s.translate && translate > s.maxTranslate()) { 1657 if ((s.activeIndex || 0) !== slideIndex ) return false; 1658 } 1659 1660 // Update Index 1661 if (typeof speed === 'undefined') speed = s.params.speed; 1662 s.previousIndex = s.activeIndex || 0; 1663 s.activeIndex = slideIndex; 1664 1665 if (translate === s.translate) { 1666 s.updateClasses(); 1667 return false; 1668 } 1669 s.updateClasses(); 1670 s.onTransitionStart(runCallbacks); 1671 var translateX = isH() ? translate : 0, translateY = isH() ? 0 : translate; 1672 if (speed === 0) { 1673 s.setWrapperTransition(0); 1674 s.setWrapperTranslate(translate); 1675 s.onTransitionEnd(runCallbacks); 1676 } 1677 else { 1678 s.setWrapperTransition(speed); 1679 s.setWrapperTranslate(translate); 1680 if (!s.animating) { 1681 s.animating = true; 1682 s.wrapper.transitionEnd(function () { 1683 if (!s) return; 1684 s.onTransitionEnd(runCallbacks); 1685 }); 1686 } 1687 1688 } 1689 1690 return true; 1691 }; 1692 1693 s.onTransitionStart = function (runCallbacks) { 1694 if (typeof runCallbacks === 'undefined') runCallbacks = true; 1695 if (s.lazy) s.lazy.onTransitionStart(); 1696 if (runCallbacks) { 1697 s.emit('onTransitionStart', s); 1698 if (s.activeIndex !== s.previousIndex) { 1699 s.emit('onSlideChangeStart', s); 1700 } 1701 } 1702 }; 1703 s.onTransitionEnd = function (runCallbacks) { 1704 s.animating = false; 1705 s.setWrapperTransition(0); 1706 if (typeof runCallbacks === 'undefined') runCallbacks = true; 1707 if (s.lazy) s.lazy.onTransitionEnd(); 1708 if (runCallbacks) { 1709 s.emit('onTransitionEnd', s); 1710 if (s.activeIndex !== s.previousIndex) { 1711 s.emit('onSlideChangeEnd', s); 1712 } 1713 } 1714 if (s.params.hashnav && s.hashnav) { 1715 s.hashnav.setHash(); 1716 } 1717 1718 }; 1719 s.slideNext = function (runCallbacks, speed, internal) { 1720 if (s.params.loop) { 1721 if (s.animating) return false; 1722 s.fixLoop(); 1723 var clientLeft = s.container[0].clientLeft; 1724 return s.slideTo(s.activeIndex + s.params.slidesPerGroup, speed, runCallbacks, internal); 1725 } 1726 else return s.slideTo(s.activeIndex + s.params.slidesPerGroup, speed, runCallbacks, internal); 1727 }; 1728 s._slideNext = function (speed) { 1729 return s.slideNext(true, speed, true); 1730 }; 1731 s.slidePrev = function (runCallbacks, speed, internal) { 1732 if (s.params.loop) { 1733 if (s.animating) return false; 1734 s.fixLoop(); 1735 var clientLeft = s.container[0].clientLeft; 1736 return s.slideTo(s.activeIndex - 1, speed, runCallbacks, internal); 1737 } 1738 else return s.slideTo(s.activeIndex - 1, speed, runCallbacks, internal); 1739 }; 1740 s._slidePrev = function (speed) { 1741 return s.slidePrev(true, speed, true); 1742 }; 1743 s.slideReset = function (runCallbacks, speed, internal) { 1744 return s.slideTo(s.activeIndex, speed, runCallbacks); 1745 }; 1746 1747 /*========================= 1748 Translate/transition helpers 1749 ===========================*/ 1750 s.setWrapperTransition = function (duration, byController) { 1751 s.wrapper.transition(duration); 1752 if (s.params.effect !== 'slide' && s.effects[s.params.effect]) { 1753 s.effects[s.params.effect].setTransition(duration); 1754 } 1755 if (s.params.parallax && s.parallax) { 1756 s.parallax.setTransition(duration); 1757 } 1758 if (s.params.scrollbar && s.scrollbar) { 1759 s.scrollbar.setTransition(duration); 1760 } 1761 if (s.params.control && s.controller) { 1762 s.controller.setTransition(duration, byController); 1763 } 1764 s.emit('onSetTransition', s, duration); 1765 }; 1766 s.setWrapperTranslate = function (translate, updateActiveIndex, byController) { 1767 var x = 0, y = 0, z = 0; 1768 if (isH()) { 1769 x = s.rtl ? -translate : translate; 1770 } 1771 else { 1772 y = translate; 1773 } 1774 if (!s.params.virtualTranslate) { 1775 if (s.support.transforms3d) s.wrapper.transform('translate3d(' + x + 'px, ' + y + 'px, ' + z + 'px)'); 1776 else s.wrapper.transform('translate(' + x + 'px, ' + y + 'px)'); 1777 } 1778 1779 s.translate = isH() ? x : y; 1780 1781 if (updateActiveIndex) s.updateActiveIndex(); 1782 if (s.params.effect !== 'slide' && s.effects[s.params.effect]) { 1783 s.effects[s.params.effect].setTranslate(s.translate); 1784 } 1785 if (s.params.parallax && s.parallax) { 1786 s.parallax.setTranslate(s.translate); 1787 } 1788 if (s.params.scrollbar && s.scrollbar) { 1789 s.scrollbar.setTranslate(s.translate); 1790 } 1791 if (s.params.control && s.controller) { 1792 s.controller.setTranslate(s.translate, byController); 1793 } 1794 s.emit('onSetTranslate', s, s.translate); 1795 }; 1796 1797 s.getTranslate = function (el, axis) { 1798 var matrix, curTransform, curStyle, transformMatrix; 1799 1800 // automatic axis detection 1801 if (typeof axis === 'undefined') { 1802 axis = 'x'; 1803 } 1804 1805 if (s.params.virtualTranslate) { 1806 return s.rtl ? -s.translate : s.translate; 1807 } 1808 1809 curStyle = window.getComputedStyle(el, null); 1810 if (window.WebKitCSSMatrix) { 1811 // Some old versions of Webkit choke when 'none' is passed; pass 1812 // empty string instead in this case 1813 transformMatrix = new window.WebKitCSSMatrix(curStyle.webkitTransform === 'none' ? '' : curStyle.webkitTransform); 1814 } 1815 else { 1816 transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,'); 1817 matrix = transformMatrix.toString().split(','); 1818 } 1819 1820 if (axis === 'x') { 1821 //Latest Chrome and webkits Fix 1822 if (window.WebKitCSSMatrix) 1823 curTransform = transformMatrix.m41; 1824 //Crazy IE10 Matrix 1825 else if (matrix.length === 16) 1826 curTransform = parseFloat(matrix[12]); 1827 //Normal Browsers 1828 else 1829 curTransform = parseFloat(matrix[4]); 1830 } 1831 if (axis === 'y') { 1832 //Latest Chrome and webkits Fix 1833 if (window.WebKitCSSMatrix) 1834 curTransform = transformMatrix.m42; 1835 //Crazy IE10 Matrix 1836 else if (matrix.length === 16) 1837 curTransform = parseFloat(matrix[13]); 1838 //Normal Browsers 1839 else 1840 curTransform = parseFloat(matrix[5]); 1841 } 1842 if (s.rtl && curTransform) curTransform = -curTransform; 1843 return curTransform || 0; 1844 }; 1845 s.getWrapperTranslate = function (axis) { 1846 if (typeof axis === 'undefined') { 1847 axis = isH() ? 'x' : 'y'; 1848 } 1849 return s.getTranslate(s.wrapper[0], axis); 1850 }; 1851 1852 /*========================= 1853 Observer 1854 ===========================*/ 1855 s.observers = []; 1856 function initObserver(target, options) { 1857 options = options || {}; 1858 // create an observer instance 1859 var ObserverFunc = window.MutationObserver || window.WebkitMutationObserver; 1860 var observer = new ObserverFunc(function (mutations) { 1861 mutations.forEach(function (mutation) { 1862 s.onResize(true); 1863 s.emit('onObserverUpdate', s, mutation); 1864 }); 1865 }); 1866 1867 observer.observe(target, { 1868 attributes: typeof options.attributes === 'undefined' ? true : options.attributes, 1869 childList: typeof options.childList === 'undefined' ? true : options.childList, 1870 characterData: typeof options.characterData === 'undefined' ? true : options.characterData 1871 }); 1872 1873 s.observers.push(observer); 1874 }
1875 s.initObservers = function () { 1876 if (s.params.observeParents) { 1877 var containerParents = s.container.parents(); 1878 for (var i = 0; i < containerParents.length; i++) { 1879 initObserver(containerParents[i]); 1880 } 1881 } 1882 1883 // Observe container 1884 initObserver(s.container[0], {childList: false}); 1885 1886 // Observe wrapper 1887 initObserver(s.wrapper[0], {attributes: false}); 1888 }; 1889 s.disconnectObservers = function () { 1890 for (var i = 0; i < s.observers.length; i++) { 1891 s.observers[i].disconnect(); 1892 } 1893 s.observers = []; 1894 }; 1895 /*========================= 1896 Loop 1897 ===========================*/ 1898 // Create looped slides 1899 s.createLoop = function () { 1900 // Remove duplicated slides 1901 s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove(); 1902 1903 var slides = s.wrapper.children('.' + s.params.slideClass); 1904 1905 if(s.params.slidesPerView === 'auto' && !s.params.loopedSlides) s.params.loopedSlides = slides.length; 1906 1907 s.loopedSlides = parseInt(s.params.loopedSlides || s.params.slidesPerView, 10); 1908 s.loopedSlides = s.loopedSlides + s.params.loopAdditionalSlides; 1909 if (s.loopedSlides > slides.length) { 1910 s.loopedSlides = slides.length; 1911 } 1912 1913 var prependSlides = [], appendSlides = [], i; 1914 slides.each(function (index, el) { 1915 var slide = $(this); 1916 if (index < s.loopedSlides) appendSlides.push(el); 1917 if (index < slides.length && index >= slides.length - s.loopedSlides) prependSlides.push(el); 1918 slide.attr('data-swiper-slide-index', index); 1919 }); 1920 for (i = 0; i < appendSlides.length; i++) { 1921 s.wrapper.append($(appendSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass)); 1922 } 1923 for (i = prependSlides.length - 1; i >= 0; i--) { 1924 s.wrapper.prepend($(prependSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass)); 1925 } 1926 }; 1927 s.destroyLoop = function () { 1928 s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove(); 1929 s.slides.removeAttr('data-swiper-slide-index'); 1930 }; 1931 s.fixLoop = function () { 1932 var newIndex; 1933 //Fix For Negative Oversliding 1934 if (s.activeIndex < s.loopedSlides) { 1935 newIndex = s.slides.length - s.loopedSlides * 3 + s.activeIndex; 1936 newIndex = newIndex + s.loopedSlides; 1937 s.slideTo(newIndex, 0, false, true); 1938 } 1939 //Fix For Positive Oversliding 1940 else if ((s.params.slidesPerView === 'auto' && s.activeIndex >= s.loopedSlides * 2) || (s.activeIndex > s.slides.length - s.params.slidesPerView * 2)) { 1941 newIndex = -s.slides.length + s.activeIndex + s.loopedSlides; 1942 newIndex = newIndex + s.loopedSlides; 1943 s.slideTo(newIndex, 0, false, true); 1944 } 1945 }; 1946 /*========================= 1947 Append/Prepend/Remove Slides 1948 ===========================*/ 1949 s.appendSlide = function (slides) { 1950 if (s.params.loop) { 1951 s.destroyLoop(); 1952 } 1953 if (typeof slides === 'object' && slides.length) { 1954 for (var i = 0; i < slides.length; i++) { 1955 if (slides[i]) s.wrapper.append(slides[i]); 1956 } 1957 } 1958 else { 1959 s.wrapper.append(slides); 1960 } 1961 if (s.params.loop) { 1962 s.createLoop(); 1963 } 1964 if (!(s.params.observer && s.support.observer)) { 1965 s.update(true); 1966 } 1967 }; 1968 s.prependSlide = function (slides) { 1969 if (s.params.loop) { 1970 s.destroyLoop(); 1971 } 1972 var newActiveIndex = s.activeIndex + 1; 1973 if (typeof slides === 'object' && slides.length) { 1974 for (var i = 0; i < slides.length; i++) {
1975 if (slides[i]) s.wrapper.prepend(slides[i]); 1976 } 1977 newActiveIndex = s.activeIndex + slides.length; 1978 } 1979 else { 1980 s.wrapper.prepend(slides); 1981 } 1982 if (s.params.loop) { 1983 s.createLoop(); 1984 } 1985 if (!(s.params.observer && s.support.observer)) { 1986 s.update(true); 1987 } 1988 s.slideTo(newActiveIndex, 0, false); 1989 }; 1990 s.removeSlide = function (slidesIndexes) { 1991 if (s.params.loop) { 1992 s.destroyLoop(); 1993 s.slides = s.wrapper.children('.' + s.params.slideClass); 1994 } 1995 var newActiveIndex = s.activeIndex, 1996 indexToRemove; 1997 if (typeof slidesIndexes === 'object' && slidesIndexes.length) { 1998 for (var i = 0; i < slidesIndexes.length; i++) { 1999 indexToRemove = slidesIndexes[i]; 2000 if (s.slides[indexToRemove]) s.slides.eq(indexToRemove).remove(); 2001 if (indexToRemove < newActiveIndex) newActiveIndex--; 2002 } 2003 newActiveIndex = Math.max(newActiveIndex, 0); 2004 } 2005 else { 2006 indexToRemove = slidesIndexes; 2007 if (s.slides[indexToRemove]) s.slides.eq(indexToRemove).remove(); 2008 if (indexToRemove < newActiveIndex) newActiveIndex--; 2009 newActiveIndex = Math.max(newActiveIndex, 0); 2010 } 2011 2012 if (s.params.loop) { 2013 s.createLoop(); 2014 } 2015 2016 if (!(s.params.observer && s.support.observer)) { 2017 s.update(true); 2018 } 2019 if (s.params.loop) { 2020 s.slideTo(newActiveIndex + s.loopedSlides, 0, false); 2021 } 2022 else { 2023 s.slideTo(newActiveIndex, 0, false); 2024 } 2025 2026 }; 2027 s.removeAllSlides = function () { 2028 var slidesIndexes = []; 2029 for (var i = 0; i < s.slides.length; i++) { 2030 slidesIndexes.push(i); 2031 } 2032 s.removeSlide(slidesIndexes); 2033 }; 2034 2035 2036 /*=========================
2037 Effects 2038 ===========================*/ 2039 s.effects = { 2040 fade: { 2041 setTranslate: function () { 2042 for (var i = 0; i < s.slides.length; i++) { 2043 var slide = s.slides.eq(i); 2044 var offset = slide[0].swiperSlideOffset; 2045 var tx = -offset; 2046 if (!s.params.virtualTranslate) tx = tx - s.translate; 2047 var ty = 0; 2048 if (!isH()) { 2049 ty = tx; 2050 tx = 0; 2051 } 2052 var slideOpacity = s.params.fade.crossFade ? 2053 Math.max(1 - Math.abs(slide[0].progress), 0) : 2054 1 + Math.min(Math.max(slide[0].progress, -1), 0); 2055 slide 2056 .css({ 2057 opacity: slideOpacity 2058 }) 2059 .transform('translate3d(' + tx + 'px, ' + ty + 'px, 0px)'); 2060 2061 } 2062 2063 }, 2064 setTransition: function (duration) { 2065 s.slides.transition(duration); 2066 if (s.params.virtualTranslate && duration !== 0) { 2067 var eventTriggered = false; 2068 s.slides.transitionEnd(function () { 2069 if (eventTriggered) return; 2070 if (!s) return; 2071 eventTriggered = true; 2072 s.animating = false; 2073 var triggerEvents = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd']; 2074 for (var i = 0; i < triggerEvents.length; i++) { 2075 s.wrapper.trigger(triggerEvents[i]); 2076 } 2077 }); 2078 } 2079 } 2080 }, 2081 cube: { 2082 setTranslate: function () { 2083 var wrapperRotate = 0, cubeShadow; 2084 if (s.params.cube.shadow) { 2085 if (isH()) { 2086 cubeShadow = s.wrapper.find('.swiper-cube-shadow'); 2087 if (cubeShadow.length === 0) { 2088 cubeShadow = $('<div class="swiper-cube-shadow"></div>'); 2089 s.wrapper.append(cubeShadow); 2090 } 2091 cubeShadow.css({height: s.width + 'px'}); 2092 } 2093 else { 2094 cubeShadow = s.container.find('.swiper-cube-shadow'); 2095 if (cubeShadow.length === 0) { 2096 cubeShadow = $('<div class="swiper-cube-shadow"></div>'); 2097 s.container.append(cubeShadow); 2098 } 2099 } 2100 } 2101 for (var i = 0; i < s.slides.length; i++) { 2102 var slide = s.slides.eq(i); 2103 var slideAngle = i * 90; 2104 var round = Math.floor(slideAngle / 360); 2105 if (s.rtl) { 2106 slideAngle = -slideAngle; 2107 round = Math.floor(-slideAngle / 360); 2108 } 2109 var progress = Math.max(Math.min(slide[0].progress, 1), -1); 2110 var tx = 0, ty = 0, tz = 0; 2111 if (i % 4 === 0) { 2112 tx = - round * 4 * s.size; 2113 tz = 0; 2114 } 2115 else if ((i - 1) % 4 === 0) { 2116 tx = 0; 2117 tz = - round * 4 * s.size; 2118 } 2119 else if ((i - 2) % 4 === 0) { 2120 tx = s.size + round * 4 * s.size; 2121 tz = s.size; 2122 } 2123 else if ((i - 3) % 4 === 0) { 2124 tx = - s.size; 2125 tz = 3 * s.size + s.size * 4 * round; 2126 } 2127 if (s.rtl) { 2128 tx = -tx; 2129 } 2130 2131 if (!isH()) { 2132 ty = tx; 2133 tx = 0; 2134 } 2135 2136 var transform = 'rotateX(' + (isH() ? 0 : -slideAngle) + 'deg) rotateY(' + (isH() ? slideAngle : 0) + 'deg) translate3d(' + tx + 'px, ' + ty + 'px, ' + tz + 'px)'; 2137 if (progress <= 1 && progress > -1) { 2138 wrapperRotate = i * 90 + progress * 90; 2139 if (s.rtl) wrapperRotate = -i * 90 - progress * 90; 2140 } 2141 slide.transform(transform); 2142 if (s.params.cube.slideShadows) { 2143 //Set shadows 2144 var shadowBefore = isH() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top'); 2145 var shadowAfter = isH() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom'); 2146 if (shadowBefore.length === 0) { 2147 shadowBefore = $('<div class="swiper-slide-shadow-' + (isH() ? 'left' : 'top') + '"></div>'); 2148 slide.append(shadowBefore); 2149 } 2150 if (shadowAfter.length === 0) {
2151 shadowAfter = $('<div class="swiper-slide-shadow-' + (isH() ? 'right' : 'bottom') + '"></div>'); 2152 slide.append(shadowAfter); 2153 } 2154 var shadowOpacity = slide[0].progress; 2155 if (shadowBefore.length) shadowBefore[0].style.opacity = -slide[0].progress; 2156 if (shadowAfter.length) shadowAfter[0].style.opacity = slide[0].progress; 2157 } 2158 } 2159 s.wrapper.css({ 2160 '-webkit-transform-origin': '50% 50% -' + (s.size / 2) + 'px', 2161 '-moz-transform-origin': '50% 50% -' + (s.size / 2) + 'px', 2162 '-ms-transform-origin': '50% 50% -' + (s.size / 2) + 'px', 2163 'transform-origin': '50% 50% -' + (s.size / 2) + 'px' 2164 }); 2165 2166 if (s.params.cube.shadow) { 2167 if (isH()) { 2168 cubeShadow.transform('translate3d(0px, ' + (s.width / 2 + s.params.cube.shadowOffset) + 'px, ' + (-s.width / 2) + 'px) rotateX(90deg) rotateZ(0deg) scale(' + (s.params.cube.shadowScale) + ')'); 2169 } 2170 else { 2171 var shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90; 2172 var multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2); 2173 var scale1 = s.params.cube.shadowScale, 2174 scale2 = s.params.cube.shadowScale / multiplier, 2175 offset = s.params.cube.shadowOffset; 2176 cubeShadow.transform('scale3d(' + scale1 + ', 1, ' + scale2 + ') translate3d(0px, ' + (s.height / 2 + offset) + 'px, ' + (-s.height / 2 / scale2) + 'px) rotateX(-90deg)'); 2177 } 2178 } 2179 var zFactor = (s.isSafari || s.isUiWebView) ? (-s.size / 2) : 0; 2180 s.wrapper.transform('translate3d(0px,0,' + zFactor + 'px) rotateX(' + (isH() ? 0 : wrapperRotate) + 'deg) rotateY(' + (isH() ? -wrapperRotate : 0) + 'deg)'); 2181 }, 2182 setTransition: function (duration) { 2183 s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); 2184 if (s.params.cube.shadow && !isH()) { 2185 s.container.find('.swiper-cube-shadow').transition(duration); 2186 } 2187 } 2188 }, 2189 coverflow: { 2190 setTranslate: function () { 2191 var transform = s.translate; 2192 var center = isH() ? -transform + s.width / 2 : -transform + s.height / 2; 2193 var rotate = isH() ? s.params.coverflow.rotate: -s.params.coverflow.rotate; 2194 var translate = s.params.coverflow.depth; 2195 //Each slide offset from center 2196 for (var i = 0, length = s.slides.length; i < length; i++) { 2197 var slide = s.slides.eq(i); 2198 var slideSize = s.slidesSizesGrid[i]; 2199 var slideOffset = slide[0].swiperSlideOffset; 2200 var offsetMultiplier = (center - slideOffset - slideSize / 2) / slideSize * s.params.coverflow.modifier; 2201 2202 var rotateY = isH() ? rotate * offsetMultiplier : 0; 2203 var rotateX = isH() ? 0 : rotate * offsetMultiplier; 2204 // var rotateZ = 0 2205 var translateZ = -translate * Math.abs(offsetMultiplier); 2206 2207 var translateY = isH() ? 0 : s.params.coverflow.stretch * (offsetMultiplier); 2208 var translateX = isH() ? s.params.coverflow.stretch * (offsetMultiplier) : 0; 2209 2210 //Fix for ultra small values 2211 if (Math.abs(translateX) < 0.001) translateX = 0; 2212 if (Math.abs(translateY) < 0.001) translateY = 0; 2213 if (Math.abs(translateZ) < 0.001) translateZ = 0; 2214 if (Math.abs(rotateY) < 0.001) rotateY = 0; 2215 if (Math.abs(rotateX) < 0.001) rotateX = 0; 2216 2217 var slideTransform = 'translate3d(' + translateX + 'px,' + translateY + 'px,' + translateZ + 'px) rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)'; 2218 2219 slide.transform(slideTransform); 2220 slide[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1; 2221 if (s.params.coverflow.slideShadows) { 2222 //Set shadows 2223 var shadowBefore = isH() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top'); 2224 var shadowAfter = isH() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom'); 2225 if (shadowBefore.length === 0) { 2226 shadowBefore = $('<div class="swiper-slide-shadow-' + (isH() ? 'left' : 'top') + '"></div>'); 2227 slide.append(shadowBefore); 2228 } 2229 if (shadowAfter.length === 0) {
2230 shadowAfter = $('<div class="swiper-slide-shadow-' + (isH() ? 'right' : 'bottom') + '"></div>'); 2231 slide.append(shadowAfter); 2232 } 2233 if (shadowBefore.length) shadowBefore[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0; 2234 if (shadowAfter.length) shadowAfter[0].style.opacity = (-offsetMultiplier) > 0 ? -offsetMultiplier : 0; 2235 } 2236 } 2237 2238 //Set correct perspective for IE10 2239 if (s.browser.ie) { 2240 var ws = s.wrapper[0].style; 2241 ws.perspectiveOrigin = center + 'px 50%'; 2242 } 2243 }, 2244 setTransition: function (duration) { 2245 s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); 2246 } 2247 } 2248 }; 2249 2250 /*========================= 2251 Images Lazy Loading 2252 ===========================*/ 2253 s.lazy = { 2254 initialImageLoaded: false, 2255 loadImageInSlide: function (index, loadInDuplicate) { 2256 if (typeof index === 'undefined') return; 2257 if (typeof loadInDuplicate === 'undefined') loadInDuplicate = true; 2258 if (s.slides.length === 0) return; 2259 2260 var slide = s.slides.eq(index); 2261 var img = slide.find('.swiper-lazy:not(.swiper-lazy-loaded):not(.swiper-lazy-loading)'); 2262 if (slide.hasClass('swiper-lazy') && !slide.hasClass('swiper-lazy-loaded') && !slide.hasClass('swiper-lazy-loading')) { 2263 img.add(slide[0]); 2264 } 2265 if (img.length === 0) return; 2266 2267 img.each(function () { 2268 var _img = $(this); 2269 _img.addClass('swiper-lazy-loading'); 2270 var background = _img.attr('data-background'); 2271 var src = _img.attr('data-src'); 2272 s.loadImage(_img[0], (src || background), false, function () { 2273 if (background) { 2274 _img.css('background-image', 'url(' + background + ')'); 2275 _img.removeAttr('data-background'); 2276 } 2277 else { 2278 _img.attr('src', src); 2279 _img.removeAttr('data-src'); 2280 } 2281 2282 _img.addClass('swiper-lazy-loaded').removeClass('swiper-lazy-loading'); 2283 slide.find('.swiper-lazy-preloader, .preloader').remove(); 2284 if (s.params.loop && loadInDuplicate) { 2285 var slideOriginalIndex = slide.attr('data-swiper-slide-index'); 2286 if (slide.hasClass(s.params.slideDuplicateClass)) { 2287 var originalSlide = s.wrapper.children('[data-swiper-slide-index="' + slideOriginalIndex + '"]:not(.' + s.params.slideDuplicateClass + ')'); 2288 s.lazy.loadImageInSlide(originalSlide.index(), false); 2289 } 2290 else { 2291 var duplicatedSlide = s.wrapper.children('.' + s.params.slideDuplicateClass + '[data-swiper-slide-index="' + slideOriginalIndex + '"]'); 2292 s.lazy.loadImageInSlide(duplicatedSlide.index(), false); 2293 } 2294 } 2295 s.emit('onLazyImageReady', s, slide[0], _img[0]); 2296 }); 2297 2298 s.emit('onLazyImageLoad', s, slide[0], _img[0]); 2299 }); 2300 2301 }, 2302 load: function () { 2303 var i; 2304 if (s.params.watchSlidesVisibility) { 2305 s.wrapper.children('.' + s.params.slideVisibleClass).each(function () { 2306 s.lazy.loadImageInSlide($(this).index()); 2307 }); 2308 } 2309 else { 2310 if (s.params.slidesPerView > 1) { 2311 for (i = s.activeIndex; i < s.activeIndex + s.params.slidesPerView ; i++) { 2312 if (s.slides[i]) s.lazy.loadImageInSlide(i); 2313 } 2314 } 2315 else { 2316 s.lazy.loadImageInSlide(s.activeIndex); 2317 } 2318 } 2319 if (s.params.lazyLoadingInPrevNext) { 2320 if (s.params.slidesPerView > 1) { 2321 // Next Slides 2322 for (i = s.activeIndex + s.params.slidesPerView; i < s.activeIndex + s.params.slidesPerView + s.params.slidesPerView; i++) { 2323 if (s.slides[i]) s.lazy.loadImageInSlide(i); 2324 } 2325 // Prev Slides 2326 for (i = s.activeIndex - s.params.slidesPerView; i < s.activeIndex ; i++) { 2327 if (s.slides[i]) s.lazy.loadImageInSlide(i); 2328 } 2329 } 2330 else { 2331 var nextSlide = s.wrapper.children('.' + s.params.slideNextClass); 2332 if (nextSlide.length > 0) s.lazy.loadImageInSlide(nextSlide.index()); 2333 2334 var prevSlide = s.wrapper.children('.' + s.params.slidePrevClass); 2335 if (prevSlide.length > 0) s.lazy.loadImageInSlide(prevSlide.index()); 2336 } 2337 } 2338 }, 2339 onTransitionStart: function () { 2340 if (s.params.lazyLoading) { 2341 if (s.params.lazyLoadingOnTransitionStart || (!s.params.lazyLoadingOnTransitionStart && !s.lazy.initialImageLoaded)) { 2342 s.lazy.load(); 2343 } 2344 } 2345 }, 2346 onTransitionEnd: function () { 2347 if (s.params.lazyLoading && !s.params.lazyLoadingOnTransitionStart) { 2348 s.lazy.load(); 2349 } 2350 } 2351 }; 2352 2353 2354 /*========================= 2355 Scrollbar 2356 ===========================*/ 2357 s.scrollbar = { 2358 set: function () { 2359 if (!s.params.scrollbar) return; 2360 var sb = s.scrollbar; 2361 sb.track = $(s.params.scrollbar); 2362 sb.drag = sb.track.find('.swiper-scrollbar-drag'); 2363 if (sb.drag.length === 0) { 2364 sb.drag = $('<div class="swiper-scrollbar-drag"></div>'); 2365 sb.track.append(sb.drag); 2366 } 2367 sb.drag[0].style.width = ''; 2368 sb.drag[0].style.height = ''; 2369 sb.trackSize = isH() ? sb.track[0].offsetWidth : sb.track[0].offsetHeight; 2370 2371 sb.divider = s.size / s.virtualSize; 2372 sb.moveDivider = sb.divider * (sb.trackSize / s.size); 2373 sb.dragSize = sb.trackSize * sb.divider; 2374 2375 if (isH()) { 2376 sb.drag[0].style.width = sb.dragSize + 'px'; 2377 } 2378 else { 2379 sb.drag[0].style.height = sb.dragSize + 'px'; 2380 } 2381 2382 if (sb.divider >= 1) { 2383 sb.track[0].style.display = 'none'; 2384 } 2385 else { 2386 sb.track[0].style.display = ''; 2387 } 2388 if (s.params.scrollbarHide) { 2389 sb.track[0].style.opacity = 0; 2390 } 2391 }, 2392 setTranslate: function () { 2393 if (!s.params.scrollbar) return; 2394 var diff; 2395 var sb = s.scrollbar; 2396 var translate = s.translate || 0; 2397 var newPos; 2398 2399 var newSize = sb.dragSize; 2400 newPos = (sb.trackSize - sb.dragSize) * s.progress; 2401 if (s.rtl && isH()) { 2402 newPos = -newPos; 2403 if (newPos > 0) { 2404 newSize = sb.dragSize - newPos; 2405 newPos = 0; 2406 } 2407 else if (-newPos + sb.dragSize > sb.trackSize) { 2408 newSize = sb.trackSize + newPos; 2409 } 2410 } 2411 else { 2412 if (newPos < 0) { 2413 newSize = sb.dragSize + newPos; 2414 newPos = 0; 2415 } 2416 else if (newPos + sb.dragSize > sb.trackSize) { 2417 newSize = sb.trackSize - newPos; 2418 } 2419 } 2420 if (isH()) { 2421 if (s.support.transforms3d) { 2422 sb.drag.transform('translate3d(' + (newPos) + 'px, 0, 0)'); 2423 } 2424 else { 2425 sb.drag.transform('translateX(' + (newPos) + 'px)'); 2426 } 2427 sb.drag[0].style.width = newSize + 'px'; 2428 } 2429 else { 2430 if (s.support.transforms3d) { 2431 sb.drag.transform('translate3d(0px, ' + (newPos) + 'px, 0)'); 2432 } 2433 else { 2434 sb.drag.transform('translateY(' + (newPos) + 'px)'); 2435 } 2436 sb.drag[0].style.height = newSize + 'px'; 2437 } 2438 if (s.params.scrollbarHide) { 2439 clearTimeout(sb.timeout); 2440 sb.track[0].style.opacity = 1; 2441 sb.timeout = setTimeout(function () { 2442 sb.track[0].style.opacity = 0; 2443 sb.track.transition(400); 2444 }, 1000); 2445 } 2446 }, 2447 setTransition: function (duration) { 2448 if (!s.params.scrollbar) return; 2449 s.scrollbar.drag.transition(duration); 2450 } 2451 }; 2452 2453 /*========================= 2454 Controller 2455 ===========================*/ 2456 s.controller = { 2457 LinearSpline: function (x, y) { 2458 this.x = x; 2459 this.y = y; 2460 this.lastIndex = x.length - 1; 2461 // Given an x value (x2), return the expected y2 value: 2462 // (x1,y1) is the known point before given value,
2463 // (x3,y3) is the known point after given value. 2464 var i1, i3; 2465 var l = this.x.length; 2466 2467 this.interpolate = function (x2) { 2468 if (!x2) return 0; 2469 2470 // Get the indexes of x1 and x3 (the array indexes before and after given x2): 2471 i3 = binarySearch(this.x, x2); 2472 i1 = i3 - 1; 2473 2474 // We have our indexes i1 & i3, so we can calculate already: 2475 // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1 2476 return ((x2 - this.x[i1]) * (this.y[i3] - this.y[i1])) / (this.x[i3] - this.x[i1]) + this.y[i1]; 2477 }; 2478 2479 var binarySearch = (function() { 2480 var maxIndex, minIndex, guess; 2481 return function(array, val) { 2482 minIndex = -1; 2483 maxIndex = array.length; 2484 while (maxIndex - minIndex > 1) 2485 if (array[guess = maxIndex + minIndex >> 1] <= val) { 2486 minIndex = guess; 2487 } else { 2488 maxIndex = guess; 2489 } 2490 return maxIndex; 2491 }; 2492 })(); 2493 }, 2494 //xxx: for now i will just save one spline function to to 2495 getInterpolateFunction: function(c){ 2496 if(!s.controller.spline) s.controller.spline = s.params.loop ? 2497 new s.controller.LinearSpline(s.slidesGrid, c.slidesGrid) : 2498 new s.controller.LinearSpline(s.snapGrid, c.snapGrid); 2499 }, 2500 setTranslate: function (translate, byController) { 2501 var controlled = s.params.control; 2502 var multiplier, controlledTranslate; 2503 function setControlledTranslate(c) { 2504 // this will create an Interpolate function based on the snapGrids 2505 // x is the Grid of the scrolled scroller and y will be the controlled scroller 2506 // it makes sense to create this only once and recall it for the interpolation 2507 // the function does a lot of value caching for performance 2508 translate = c.rtl && c.params.direction === 'horizontal' ? -s.translate : s.translate; 2509 if (s.params.controlBy === 'slide') { 2510 s.controller.getInterpolateFunction(c); 2511 // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid 2512 // but it did not work out 2513 controlledTranslate = -s.controller.spline.interpolate(-translate); 2514 } 2515 2516 if(!controlledTranslate || s.params.controlBy === 'container'){ 2517 multiplier = (c.maxTranslate() - c.minTranslate()) / (s.maxTranslate() - s.minTranslate()); 2518 controlledTranslate = (translate - s.minTranslate()) * multiplier + c.minTranslate(); 2519 } 2520 2521 if (s.params.controlInverse) { 2522 controlledTranslate = c.maxTranslate() - controlledTranslate; 2523 } 2524 c.updateProgress(controlledTranslate); 2525 c.setWrapperTranslate(controlledTranslate, false, s); 2526 c.updateActiveIndex(); 2527 } 2528 if (s.isArray(controlled)) { 2529 for (var i = 0; i < controlled.length; i++) { 2530 if (controlled[i] !== byController && controlled[i] instanceof Swiper) { 2531 setControlledTranslate(controlled[i]); 2532 } 2533 } 2534 } 2535 else if (controlled instanceof Swiper && byController !== controlled) { 2536 2537 setControlledTranslate(controlled); 2538 } 2539 }, 2540 setTransition: function (duration, byController) { 2541 var controlled = s.params.control; 2542 var i; 2543 function setControlledTransition(c) { 2544 c.setWrapperTransition(duration, s); 2545 if (duration !== 0) { 2546 c.onTransitionStart(); 2547 c.wrapper.transitionEnd(function(){ 2548 if (!controlled) return; 2549 if (c.params.loop && s.params.controlBy === 'slide') { 2550 c.fixLoop(); 2551 } 2552 c.onTransitionEnd(); 2553 2554 }); 2555 } 2556 } 2557 if (s.isArray(controlled)) { 2558 for (i = 0; i < controlled.length; i++) { 2559 if (controlled[i] !== byController && controlled[i] instanceof Swiper) { 2560 setControlledTransition(controlled[i]); 2561 } 2562 } 2563 } 2564 else if (controlled instanceof Swiper && byController !== controlled) { 2565 setControlledTransition(controlled); 2566 } 2567 } 2568 }; 2569 2570 /*========================= 2571 Hash Navigation 2572 ===========================*/ 2573 s.hashnav = { 2574 init: function () { 2575 if (!s.params.hashnav) return; 2576 s.hashnav.initialized = true; 2577 var hash = document.location.hash.replace('#', ''); 2578 if (!hash) return; 2579 var speed = 0; 2580 for (var i = 0, length = s.slides.length; i < length; i++) { 2581 var slide = s.slides.eq(i); 2582 var slideHash = slide.attr('data-hash'); 2583 if (slideHash === hash && !slide.hasClass(s.params.slideDuplicateClass)) { 2584 var index = slide.index(); 2585 s.slideTo(index, speed, s.params.runCallbacksOnInit, true); 2586 } 2587 } 2588 }, 2589 setHash: function () { 2590 if (!s.hashnav.initialized || !s.params.hashnav) return; 2591 document.location.hash = s.slides.eq(s.activeIndex).attr('data-hash') || ''; 2592 } 2593 }; 2594 2595 /*========================= 2596 Keyboard Control 2597 ===========================*/ 2598 function handleKeyboard(e) { 2599 if (e.originalEvent) e = e.originalEvent; //jquery fix 2600 var kc = e.keyCode || e.charCode; 2601 // Directions locks 2602 if (!s.params.allowSwipeToNext && (isH() && kc === 39 || !isH() && kc === 40)) { 2603 return false;
2604 } 2605 if (!s.params.allowSwipeToPrev && (isH() && kc === 37 || !isH() && kc === 38)) { 2606 return false; 2607 } 2608 if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) { 2609 return; 2610 } 2611 if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) { 2612 return; 2613 } 2614 if (kc === 37 || kc === 39 || kc === 38 || kc === 40) { 2615 var inView = false; 2616 //Check that swiper should be inside of visible area of window 2617 if (s.container.parents('.swiper-slide').length > 0 && s.container.parents('.swiper-slide-active').length === 0) { 2618 return; 2619 } 2620 var windowScroll = { 2621 left: window.pageXOffset, 2622 top: window.pageYOffset 2623 }; 2624 var windowWidth = window.innerWidth; 2625 var windowHeight = window.innerHeight; 2626 var swiperOffset = s.container.offset(); 2627 if (s.rtl) swiperOffset.left = swiperOffset.left - s.container[0].scrollLeft; 2628 var swiperCoord = [ 2629 [swiperOffset.left, swiperOffset.top], 2630 [swiperOffset.left + s.width, swiperOffset.top], 2631 [swiperOffset.left, swiperOffset.top + s.height], 2632 [swiperOffset.left + s.width, swiperOffset.top + s.height] 2633 ]; 2634 for (var i = 0; i < swiperCoord.length; i++) { 2635 var point = swiperCoord[i]; 2636 if ( 2637 point[0] >= windowScroll.left && point[0] <= windowScroll.left + windowWidth && 2638 point[1] >= windowScroll.top && point[1] <= windowScroll.top + windowHeight 2639 ) { 2640 inView = true; 2641 } 2642 2643 } 2644 if (!inView) return; 2645 } 2646 if (isH()) { 2647 if (kc === 37 || kc === 39) { 2648 if (e.preventDefault) e.preventDefault(); 2649 else e.returnValue = false; 2650 } 2651 if ((kc === 39 && !s.rtl) || (kc === 37 && s.rtl)) s.slideNext(); 2652 if ((kc === 37 && !s.rtl) || (kc === 39 && s.rtl)) s.slidePrev(); 2653 } 2654 else { 2655 if (kc === 38 || kc === 40) { 2656 if (e.preventDefault) e.preventDefault(); 2657 else e.returnValue = false; 2658 } 2659 if (kc === 40) s.slideNext(); 2660 if (kc === 38) s.slidePrev(); 2661 } 2662 } 2663 s.disableKeyboardControl = function () { 2664 $(document).off('keydown', handleKeyboard); 2665 }; 2666 s.enableKeyboardControl = function () { 2667 $(document).on('keydown', handleKeyboard); 2668 }; 2669 2670 2671 /*========================= 2672 Mousewheel Control 2673 ===========================*/ 2674 s.mousewheel = { 2675 event: false, 2676 lastScrollTime: (new window.Date()).getTime() 2677 }; 2678 if (s.params.mousewheelControl) { 2679 try { 2680 new window.WheelEvent('wheel'); 2681 s.mousewheel.event = 'wheel'; 2682 } catch (e) {} 2683 2684 if (!s.mousewheel.event && document.onmousewheel !== undefined) { 2685 s.mousewheel.event = 'mousewheel'; 2686 } 2687 if (!s.mousewheel.event) { 2688 s.mousewheel.event = 'DOMMouseScroll'; 2689 } 2690 } 2691 function handleMousewheel(e) { 2692 if (e.originalEvent) e = e.originalEvent; //jquery fix 2693 var we = s.mousewheel.event; 2694 var delta = 0; 2695 //Opera & IE 2696 if (e.detail) delta = -e.detail; 2697 //WebKits 2698 else if (we === 'mousewheel') { 2699 if (s.params.mousewheelForceToAxis) { 2700 if (isH()) { 2701 if (Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX; 2702 else return; 2703 } 2704 else { 2705 if (Math.abs(e.wheelDeltaY) > Math.abs(e.wheelDeltaX)) delta = e.wheelDeltaY; 2706 else return; 2707 } 2708 } 2709 else { 2710 delta = e.wheelDelta; 2711 } 2712 } 2713 //Old FireFox 2714 else if (we === 'DOMMouseScroll') delta = -e.detail; 2715 //New FireFox 2716 else if (we === 'wheel') { 2717 if (s.params.mousewheelForceToAxis) { 2718 if (isH()) { 2719 if (Math.abs(e.deltaX) > Math.abs(e.deltaY)) delta = -e.deltaX; 2720 else return; 2721 } 2722 else { 2723 if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) delta = -e.deltaY; 2724 else return; 2725 } 2726 } 2727 else { 2728 delta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? - e.deltaX : - e.deltaY; 2729 } 2730 } 2731 2732 if (s.params.mousewheelInvert) delta = -delta; 2733 2734 if (!s.params.freeMode) { 2735 if ((new window.Date()).getTime() - s.mousewheel.lastScrollTime > 60) { 2736 if (delta < 0) { 2737 if ((!s.isEnd || s.params.loop) && !s.animating) s.slideNext(); 2738 else if (s.params.mousewheelReleaseOnEdges) return true; 2739 } 2740 else {
2741 if ((!s.isBeginning || s.params.loop) && !s.animating) s.slidePrev(); 2742 else if (s.params.mousewheelReleaseOnEdges) return true; 2743 } 2744 } 2745 s.mousewheel.lastScrollTime = (new window.Date()).getTime(); 2746 2747 } 2748 else { 2749 //Freemode or scrollContainer: 2750 2751 var position = s.getWrapperTranslate() + delta * s.params.mousewheelSensitivity; 2752 2753 if (position > 0) position = 0; 2754 if (position < s.maxTranslate()) position = s.maxTranslate(); 2755 2756 s.setWrapperTransition(0); 2757 s.setWrapperTranslate(position); 2758 s.updateProgress(); 2759 s.updateActiveIndex(); 2760 2761 if (s.params.freeModeSticky) { 2762 clearTimeout(s.mousewheel.timeout); 2763 s.mousewheel.timeout = setTimeout(function () { 2764 s.slideReset(); 2765 }, 300); 2766 } 2767 2768 // Return page scroll on edge positions 2769 if (position === 0 || position === s.maxTranslate()) return; 2770 } 2771 if (s.params.autoplay) s.stopAutoplay(); 2772 2773 if (e.preventDefault) e.preventDefault(); 2774 else e.returnValue = false; 2775 return false; 2776 } 2777 s.disableMousewheelControl = function () { 2778 if (!s.mousewheel.event) return false; 2779 s.container.off(s.mousewheel.event, handleMousewheel); 2780 return true; 2781 }; 2782 2783 s.enableMousewheelControl = function () { 2784 if (!s.mousewheel.event) return false; 2785 s.container.on(s.mousewheel.event, handleMousewheel); 2786 return true; 2787 }; 2788 2789 /*========================= 2790 Parallax 2791 ===========================*/ 2792 function setParallaxTransform(el, progress) { 2793 el = $(el); 2794 var p, pX, pY; 2795 2796 p = el.attr('data-swiper-parallax') || '0'; 2797 pX = el.attr('data-swiper-parallax-x'); 2798 pY = el.attr('data-swiper-parallax-y'); 2799 if (pX || pY) { 2800 pX = pX || '0'; 2801 pY = pY || '0'; 2802 } 2803 else { 2804 if (isH()) { 2805 pX = p; 2806 pY = '0'; 2807 } 2808 else { 2809 pY = p; 2810 pX = '0'; 2811 } 2812 } 2813 if ((pX).indexOf('%') >= 0) { 2814 pX = parseInt(pX, 10) * progress + '%'; 2815 } 2816 else { 2817 pX = pX * progress + 'px' ; 2818 } 2819 if ((pY).indexOf('%') >= 0) { 2820 pY = parseInt(pY, 10) * progress + '%'; 2821 } 2822 else { 2823 pY = pY * progress + 'px' ; 2824 } 2825 el.transform('translate3d(' + pX + ', ' + pY + ',0px)'); 2826 } 2827 s.parallax = { 2828 setTranslate: function () { 2829 s.container.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function(){ 2830 setParallaxTransform(this, s.progress); 2831 2832 }); 2833 s.slides.each(function () { 2834 var slide = $(this); 2835 slide.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function () { 2836 var progress = Math.min(Math.max(slide[0].progress, -1), 1); 2837 setParallaxTransform(this, progress); 2838 }); 2839 }); 2840 }, 2841 setTransition: function (duration) { 2842 if (typeof duration === 'undefined') duration = s.params.speed; 2843 s.container.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function(){ 2844 var el = $(this); 2845 var parallaxDuration = parseInt(el.attr('data-swiper-parallax-duration'), 10) || duration; 2846 if (duration === 0) parallaxDuration = 0; 2847 el.transition(parallaxDuration); 2848 }); 2849 } 2850 }; 2851 2852 2853 /*========================= 2854 Plugins API. Collect all and init all plugins 2855 ===========================*/ 2856 s._plugins = []; 2857 for (var plugin in s.plugins) { 2858 var p = s.plugins[plugin](s, s.params[plugin]); 2859 if (p) s._plugins.push(p); 2860 } 2861 // Method to call all plugins event/method 2862 s.callPlugins = function (eventName) { 2863 for (var i = 0; i < s._plugins.length; i++) { 2864 if (eventName in s._plugins[i]) { 2865 s._plugins[i][eventName](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); 2866 } 2867 } 2868 }; 2869 2870 /*========================= 2871 Events/Callbacks/Plugins Emitter 2872 ===========================*/ 2873 function normalizeEventName (eventName) { 2874 if (eventName.indexOf('on') !== 0) { 2875 if (eventName[0] !== eventName[0].toUpperCase()) { 2876 eventName = 'on' + eventName[0].toUpperCase() + eventName.substring(1); 2877 } 2878 else { 2879 eventName = 'on' + eventName; 2880 } 2881 } 2882 return eventName; 2883 } 2884 s.emitterEventListeners = { 2885 2886 }; 2887 s.emit = function (eventName) { 2888 // Trigger callbacks 2889 if (s.params[eventName]) { 2890 s.params[eventName](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); 2891 } 2892 var i; 2893 // Trigger events 2894 if (s.emitterEventListeners[eventName]) { 2895 for (i = 0; i < s.emitterEventListeners[eventName].length; i++) { 2896 s.emitterEventListeners[eventName][i](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); 2897 } 2898 } 2899 // Trigger plugins 2900 if (s.callPlugins) s.callPlugins(eventName, arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); 2901 }; 2902 s.on = function (eventName, handler) { 2903 eventName = normalizeEventName(eventName); 2904 if (!s.emitterEventListeners[eventName]) s.emitterEventListeners[eventName] = []; 2905 s.emitterEventListeners[eventName].push(handler); 2906 return s; 2907 }; 2908 s.off = function (eventName, handler) { 2909 var i; 2910 eventName = normalizeEventName(eventName); 2911 if (typeof handler === 'undefined') { 2912 // Remove all handlers for such event 2913 s.emitterEventListeners[eventName] = []; 2914 return s; 2915 } 2916 if (!s.emitterEventListeners[eventName] || s.emitterEventListeners[eventName].length === 0) return; 2917 for (i = 0; i < s.emitterEventListeners[eventName].length; i++) { 2918 if(s.emitterEventListeners[eventName][i] === handler) s.emitterEventListeners[eventName].splice(i, 1); 2919 } 2920 return s; 2921 }; 2922 s.once = function (eventName, handler) { 2923 eventName = normalizeEventName(eventName); 2924 var _handler = function () { 2925 handler(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); 2926 s.off(eventName, _handler); 2927 }; 2928 s.on(eventName, _handler); 2929 return s; 2930 }; 2931 2932 // Accessibility tools 2933 s.a11y = { 2934 makeFocusable: function ($el) { 2935 $el.attr('tabIndex', '0'); 2936 return $el; 2937 }, 2938 addRole: function ($el, role) { 2939 $el.attr('role', role); 2940 return $el; 2941 }, 2942 2943 addLabel: function ($el, label) { 2944 $el.attr('aria-label', label); 2945 return $el; 2946 }, 2947 2948 disable: function ($el) { 2949 $el.attr('aria-disabled', true); 2950 return $el; 2951 }, 2952 2953 enable: function ($el) { 2954 $el.attr('aria-disabled', false); 2955 return $el; 2956 }, 2957 2958 onEnterKey: function (event) { 2959 if (event.keyCode !== 13) return; 2960 if ($(event.target).is(s.params.nextButton)) { 2961 s.onClickNext(event); 2962 if (s.isEnd) { 2963 s.a11y.notify(s.params.lastSlideMessage); 2964 } 2965 else { 2966 s.a11y.notify(s.params.nextSlideMessage); 2967 } 2968 } 2969 else if ($(event.target).is(s.params.prevButton)) { 2970 s.onClickPrev(event); 2971 if (s.isBeginning) { 2972 s.a11y.notify(s.params.firstSlideMessage); 2973 } 2974 else { 2975 s.a11y.notify(s.params.prevSlideMessage); 2976 } 2977 } 2978 if ($(event.target).is('.' + s.params.bulletClass)) { 2979 $(event.target)[0].click(); 2980 } 2981 }, 2982 2983 liveRegion: $('<span class="swiper-notification" aria-l
2983ive="assertive" aria-atomic="true"></span>'), 2984 2985 notify: function (message) { 2986 var notification = s.a11y.liveRegion; 2987 if (notification.length === 0) return; 2988 notification.html(''); 2989 notification.html(message); 2990 }, 2991 init: function () { 2992 // Setup accessibility 2993 if (s.params.nextButton) { 2994 var nextButton = $(s.params.nextButton); 2995 s.a11y.makeFocusable(nextButton); 2996 s.a11y.addRole(nextButton, 'button'); 2997 s.a11y.addLabel(nextButton, s.params.nextSlideMessage); 2998 } 2999 if (s.params.prevButton) { 3000 var prevButton = $(s.params.prevButton); 3001 s.a11y.makeFocusable(prevButton); 3002 s.a11y.addRole(prevButton, 'button'); 3003 s.a11y.addLabel(prevButton, s.params.prevSlideMessage); 3004 } 3005 3006 $(s.container).append(s.a11y.liveRegion); 3007 }, 3008 initPagination: function () { 3009 if (s.params.pagination && s.params.paginationClickable && s.bullets && s.bullets.length) { 3010 s.bullets.each(function () { 3011 var bullet = $(this); 3012 s.a11y.makeFocusable(bullet); 3013 s.a11y.addRole(bullet, 'button'); 3014 s.a11y.addLabel(bullet, s.params.paginationBulletMessage.replace(/{{index}}/, bullet.index() + 1)); 3015 }); 3016 } 3017 }, 3018 destroy: function () { 3019 if (s.a11y.liveRegion && s.a11y.liveRegion.length > 0) s.a11y.liveRegion.remove(); 3020 } 3021 }; 3022 3023 3024 /*========================= 3025 Init/Destroy 3026 ===========================*/ 3027 s.init = function () { 3028 if (s.params.loop) s.createLoop(); 3029 s.updateContainerSize(); 3030 s.updateSlidesSize(); 3031 s.updatePagination(); 3032 if (s.params.scrollbar && s.scrollbar) { 3033 s.scrollbar.set(); 3034 } 3035 if (s.params.effect !== 'slide' && s.effects[s.params.effect]) { 3036 if (!s.params.loop) s.updateProgress(); 3037 s.effects[s.params.effect].setTranslate(); 3038 } 3039 if (s.params.loop) { 3040 s.slideTo(s.params.initialSlide + s.loopedSlides, 0, s.params.runCallbacksOnInit); 3041 } 3042 else { 3043 s.slideTo(s.params.initialSlide, 0, s.params.runCallbacksOnInit); 3044 if (s.params.initialSlide === 0) { 3045 if (s.parallax && s.params.parallax) s.parallax.setTranslate(); 3046 if (s.lazy && s.params.lazyLoading) { 3047 s.lazy.load(); 3048 s.lazy.initialImageLoaded = true; 3049 } 3050 } 3051 } 3052 s.attachEvents(); 3053 if (s.params.observer && s.support.observer) { 3054 s.initObservers(); 3055 } 3056 if (s.params.preloadImages && !s.params.lazyLoading) { 3057 s.preloadImages(); 3058 } 3059 if (s.params.autoplay) { 3060 s.startAutoplay(); 3061 } 3062 if (s.params.keyboardControl) { 3063 if (s.enableKeyboardControl) s.enableKeyboardControl(); 3064 } 3065 if (s.params.mousewheelControl) { 3066 if (s.enableMousewheelControl) s.enableMousewheelControl(); 3067 } 3068 if (s.params.hashnav) { 3069 if (s.hashnav) s.hashnav.init(); 3070 } 3071 if (s.params.a11y && s.a11y) s.a11y.init(); 3072 s.emit('onInit', s); 3073 }; 3074 3075 // Cleanup dynamic styles 3076 s.cleanupStyles = function () { 3077 // Container 3078 s.container.removeClass(s.classNames.join(' ')).removeAttr('style'); 3079 3080 // Wrapper 3081 s.wrapper.removeAttr('style'); 3082 3083 // Slides 3084 if (s.slides && s.slides.length) { 3085 s.slides 3086 .removeClass([ 3087 s.params.slideVisibleClass, 3088 s.params.slideActiveClass, 3089 s.params.slideNextClass, 3090 s.params.slidePrevClass 3091 ].join(' ')) 3092 .removeAttr('style') 3093 .removeAttr('data-swiper-column') 3094 .removeAttr('data-swiper-row'); 3095 } 3096 3097 // Pagination/Bullets 3098 if (s.paginationContainer && s.paginationContainer.length) { 3099 s.paginationContainer.removeClass(s.params.paginationHiddenClass); 3100 } 3101 if (s.bullets && s.bullets.length) { 3102 s.bullets.removeClass(s.params.bulletActiveClass); 3103 } 3104 3105 // Buttons 3106 if (s.params.prevButton) $(s.params.prevButton).removeClass(s.params.buttonDisabledClass); 3107 if (s.params.nextButton) $(s.params.nextButton).removeClass(s.params.buttonDisabledClass); 3108 3109 // Scrollbar 3110 if (s.params.scrollbar && s.scrollbar) { 3111 if (s.scrollbar.track && s.scrollbar.track.length) s.scrollbar.track.removeAttr('style'); 3112 if (s.scrollbar.drag && s.scrollbar.drag.length) s.scrollbar.drag.removeAttr('style'); 3113 } 3114 }; 3115 3116 // Destroy 3117 s.destroy = function (deleteInstance, cleanupStyles) {
3118 // Detach evebts 3119 s.detachEvents(); 3120 // Stop autoplay 3121 s.stopAutoplay(); 3122 // Destroy loop 3123 if (s.params.loop) { 3124 s.destroyLoop(); 3125 } 3126 // Cleanup styles 3127 if (cleanupStyles) { 3128 s.cleanupStyles(); 3129 } 3130 // Disconnect observer 3131 s.disconnectObservers(); 3132 // Disable keyboard/mousewheel 3133 if (s.params.keyboardControl) { 3134 if (s.disableKeyboardControl) s.disableKeyboardControl(); 3135 } 3136 if (s.params.mousewheelControl) { 3137 if (s.disableMousewheelControl) s.disableMousewheelControl(); 3138 } 3139 // Disable a11y 3140 if (s.params.a11y && s.a11y) s.a11y.destroy(); 3141 // Destroy callback 3142 s.emit('onDestroy'); 3143 // Delete instance 3144 if (deleteInstance !== false) s = null; 3145 }; 3146 3147 s.init(); 3148 3149 3150 3151 // Return swiper instance 3152 return s; 3153 }; 3154 3155 3156 /*================================================== 3157 Prototype 3158 ====================================================*/ 3159 Swiper.prototype = { 3160 isSafari: (function () { 3161 var ua = navigator.userAgent.toLowerCase(); 3162 return (ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0); 3163 })(), 3164 isUiWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent), 3165 isArray: function (arr) { 3166 return Object.prototype.toString.apply(arr) === '[object Array]'; 3167 }, 3168 /*================================================== 3169 Browser 3170 ====================================================*/ 3171 browser: { 3172 ie: window.navigator.pointerEnabled || window.navigator.msPointerEnabled, 3173 ieTouch: (window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints > 1) || (window.navigator.pointerEnabled && window.navigator.maxTouchPoints > 1), 3174 }, 3175 /*================================================== 3176 Devices 3177 ====================================================*/ 3178 device: (function () { 3179 var ua = navigator.userAgent; 3180 var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); 3181 var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); 3182 var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); 3183 var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/); 3184 return { 3185 ios: ipad || iphone || ipod, 3186 android: android 3187 }; 3188 })(), 3189 /*================================================== 3190 Feature Detection 3191 ====================================================*/ 3192 support: { 3193 touch : (window.Modernizr && Modernizr.touch === true) || (function () { 3194 return !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch); 3195 })(), 3196 3197 transforms3d : (window.Modernizr && Modernizr.csstransforms3d === true) || (function () { 3198 var div = document.createElement('div').style; 3199 return ('webkitPerspective' in div || 'MozPerspective' in div || 'OPerspective' in div || 'MsPerspective' in div || 'perspective' in div); 3200 })(), 3201 3202 flexbox: (function () { 3203 var div = document.createElement('div').style; 3204 var styles = ('alignItems webkitAlignItems webkitBoxAlign msFlexAlign mozBoxAlign webkitFlexDirection msFlexDirection mozBoxDirection mozBoxOrient webkitBoxDirection webkitBoxOrient').split(' '); 3205 for (var i = 0; i < styles.length; i++) { 3206 if (styles[i] in div) return true; 3207 } 3208 })(), 3209 3210 observer: (function () { 3211 return ('MutationObserver' in window || 'WebkitMutationObserver' in window); 3212 })() 3213 }, 3214 /*================================================== 3215 Plugins 3216 ====================================================*/ 3217 plugins: {} 3218 }; 3219 3220 3221 /*=========================== 3222 Dom7 Library 3223 ===========================*/ 3224 var Dom7 = (function () { 3225 var Dom7 = function (arr) { 3226 var _this = this, i = 0; 3227 // Create array-like object 3228 for (i = 0; i < arr.length; i++) { 3229 _this[i] = arr[i]; 3230 } 3231 _this.length = arr.length; 3232 // Return collection with methods 3233 return this; 3234 }; 3235 var $ = function (selector, context) { 3236 var arr = [], i = 0; 3237 if (selector && !context) { 3238 if (selector instanceof Dom7) { 3239 return selector; 3240 } 3241 } 3242 if (selector) { 3243 // String 3244 if (typeof selector === 'string') { 3245 var els, tempParent, html = selector.trim(); 3246 if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) { 3247 var toCreate = 'div'; 3248 if (html.indexOf('<li') === 0) toCreate = 'ul'; 3249 if (html.indexOf('<tr') === 0) toCreate = 'tbody'; 3250 if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr'; 3251 if (html.indexOf('<tbody') === 0) toCreate = 'table'; 3252 if (html.indexOf('<option') === 0) toCreate = 'select'; 3253 tempParent = document.createElement(toCreate); 3254 tempParent.innerHTML = selector; 3255 for (i = 0; i < tempParent.childNodes.length; i++) { 3256 arr.push(tempParent.childNodes[i]); 3257 } 3258 } 3259 else { 3260 if (!context && selector[0] === '#' && !selector.match(/[ .<>:~]/)) { 3261 // Pure ID selector 3262 els = [document.getElementById(selector.split('#')[1])]; 3263 } 3264 else { 3265 // Other selectors 3266 els = (context || document).querySelectorAll(selector); 3267 } 3268 for (i = 0; i < els.length; i++) { 3269 if (els[i]) arr.push(els[i]); 3270 } 3271 } 3272 } 3273 // Node/element 3274 else if (selector.nodeType || selector === window || selector === document) { 3275 arr.push(selector); 3276 } 3277 //Array of elements or instance of Dom 3278 else if (selector.length > 0 && selector[0].nodeType) { 3279 for (i = 0; i < selector.length; i++) { 3280 arr.push(selector[i]); 3281 } 3282 } 3283 } 3284 return new Dom7(arr); 3285 }; 3286 Dom7.prototype = { 3287 // Classes and attriutes 3288 addClass: function (className) { 3289 if (typeof className === 'undefined') { 3290 return this; 3291 } 3292 var classes = className.split(' '); 3293 for (var i = 0; i < classes.length; i++) { 3294 for (var j = 0; j < this.length; j++) { 3295 this[j].classList.add(classes[i]); 3296 } 3297 } 3298 return this; 3299 }, 3300 removeClass: function (className) { 3301 var classes = className.split(' '); 3302 for (var i = 0; i < classes.length; i++) { 3303 for (var j = 0; j < this.length; j++) { 3304 this[j].classList.remove(classes[i]); 3305 } 3306 } 3307 return this; 3308 }, 3309 hasClass: function (className) { 3310 if (!this[0]) return false;
3311 else return this[0].classList.contains(className); 3312 }, 3313 toggleClass: function (className) { 3314 var classes = className.split(' '); 3315 for (var i = 0; i < classes.length; i++) { 3316 for (var j = 0; j < this.length; j++) { 3317 this[j].classList.toggle(classes[i]); 3318 } 3319 } 3320 return this; 3321 }, 3322 attr: function (attrs, value) { 3323 if (arguments.length === 1 && typeof attrs === 'string') { 3324 // Get attr 3325 if (this[0]) return this[0].getAttribute(attrs); 3326 else return undefined; 3327 } 3328 else { 3329 // Set attrs 3330 for (var i = 0; i < this.length; i++) { 3331 if (arguments.length === 2) { 3332 // String 3333 this[i].setAttribute(attrs, value); 3334 } 3335 else { 3336 // Object 3337 for (var attrName in attrs) { 3338 this[i][attrName] = attrs[attrName]; 3339 this[i].setAttribute(attrName, attrs[attrName]); 3340 } 3341 } 3342 } 3343 return this; 3344 } 3345 }, 3346 removeAttr: function (attr) { 3347 for (var i = 0; i < this.length; i++) { 3348 this[i].removeAttribute(attr); 3349 } 3350 return this; 3351 }, 3352 data: function (key, value) { 3353 if (typeof value === 'undefined') { 3354 // Get value 3355 if (this[0]) { 3356 var dataKey = this[0].getAttribute('data-' + key); 3357 if (dataKey) return dataKey; 3358 else if (this[0].dom7ElementDataStorage && (key in this[0].dom7ElementDataStorage)) return this[0].dom7ElementDataStorage[key]; 3359 else return undefined; 3360 } 3361 else return undefined; 3362 } 3363 else { 3364 // Set value 3365 for (var i = 0; i < this.length; i++) { 3366 var el = this[i]; 3367 if (!el.dom7ElementDataStorage) el.dom7ElementDataStorage = {}; 3368 el.dom7ElementDataStorage[key] = value; 3369 } 3370 return this; 3371 } 3372 }, 3373 // Transforms 3374 transform : function (transform) { 3375 for (var i = 0; i < this.length; i++) { 3376 var elStyle = this[i].style; 3377 elStyle.webkitTransform = elStyle.MsTransform = elStyle.msTransform = elStyle.MozTransform = elStyle.OTransform = elStyle.transform = transform; 3378 } 3379 return this; 3380 }, 3381 transition: function (duration) { 3382 if (typeof duration !== 'string') { 3383 duration = duration + 'ms'; 3384 } 3385 for (var i = 0; i < this.length; i++) { 3386 var elStyle = this[i].style; 3387 elStyle.webkitTransitionDuration = elStyle.MsTransitionDuration = elStyle.msTransitionDuration = elStyle.MozTransitionDuration = elStyle.OTransitionDuration = elStyle.transitionDuration = duration; 3388 } 3389 return this; 3390 }, 3391 //Events 3392 on: function (eventName, targetSelector, listener, capture) { 3393 function handleLiveEvent(e) { 3394 var target = e.target; 3395 if ($(target).is(targetSelector)) listener.call(target, e); 3396 else { 3397 var parents = $(target).parents(); 3398 for (var k = 0; k < parents.length; k++) { 3399 if ($(parents[k]).is(targetSelector)) listener.call(parents[k], e); 3400 } 3401 } 3402 } 3403 var events = eventName.split(' '); 3404 var i, j; 3405 for (i = 0; i < this.length; i++) { 3406 if (typeof targetSelector === 'function' || targetSelector === false) { 3407 // Usual events 3408 if (typeof targetSelector === 'function') { 3409 listener = arguments[1]; 3410 capture = arguments[2] || false; 3411 } 3412 for (j = 0; j < events.length; j++) { 3413 this[i].addEventListener(events[j], listener, capture); 3414 } 3415 } 3416 else { 3417 //Live events 3418 for (j = 0; j < events.length; j++) { 3419 if (!this[i].dom7LiveListeners) this[i].dom7LiveListeners = []; 3420 this[i].dom7LiveListeners.push({listener: listener, liveListener: handleLiveEvent}); 3421 this[i].addEventListener(events[j], handleLiveEvent, capture); 3422 } 3423 } 3424 } 3425 3426 return this; 3427 }, 3428 off: function (eventName, targetSelector, listener, capture) { 3429 var events = eventName.split(' '); 3430 for (var i = 0; i < events.length; i++) { 3431 for (var j = 0; j < this.length; j++) { 3432 if (typeof targetSelector === 'function' || targetSelector === false) { 3433 // Usual events 3434 if (typeof targetSelector === 'function') { 3435 listener = arguments[1]; 3436 capture = arguments[2] || false; 3437 } 3438 this[j].removeEventListener(events[i], listener, capture); 3439 } 3440 else { 3441 // Live event 3442 if (this[j].dom7LiveListeners) { 3443 for (var k = 0; k < this[j].dom7LiveListeners.length; k++) { 3444 if (this[j].dom7LiveListeners[k].listener === listener) { 3445 this[j].removeEventListener(events[i], this[j].dom7LiveListeners[k].liveListener, capture); 3446 } 3447 } 3448 } 3449 } 3450 } 3451 } 3452 return this; 3453 }, 3454 once: function (eventName, targetSelector, listener, capture) { 3455 var dom = this; 3456 if (typeof targetSelector === 'function') { 3457 targetSelector = false;
3458 listener = arguments[1]; 3459 capture = arguments[2]; 3460 } 3461 function proxy(e) { 3462 listener(e); 3463 dom.off(eventName, targetSelector, proxy, capture); 3464 } 3465 dom.on(eventName, targetSelector, proxy, capture); 3466 }, 3467 trigger: function (eventName, eventData) { 3468 for (var i = 0; i < this.length; i++) { 3469 var evt; 3470 try { 3471 evt = new window.CustomEvent(eventName, {detail: eventData, bubbles: true, cancelable: true}); 3472 } 3473 catch (e) { 3474 evt = document.createEvent('Event'); 3475 evt.initEvent(eventName, true, true); 3476 evt.detail = eventData; 3477 } 3478 this[i].dispatchEvent(evt); 3479 } 3480 return this; 3481 }, 3482 transitionEnd: function (callback) { 3483 var events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'], 3484 i, j, dom = this; 3485 function fireCallBack(e) { 3486 /*jshint validthis:true */ 3487 if (e.target !== this) return; 3488 callback.call(this, e); 3489 for (i = 0; i < events.length; i++) { 3490 dom.off(events[i], fireCallBack); 3491 } 3492 } 3493 if (callback) { 3494 for (i = 0; i < events.length; i++) { 3495 dom.on(events[i], fireCallBack); 3496 } 3497 } 3498 return this; 3499 }, 3500 // Sizing/Styles 3501 width: function () { 3502 if (this[0] === window) { 3503 return window.innerWidth; 3504 } 3505 else { 3506 if (this.length > 0) { 3507 return parseFloat(this.css('width')); 3508 } 3509 else { 3510 return null; 3511 } 3512 } 3513 }, 3514 outerWidth: function (includeMargins) { 3515 if (this.length > 0) { 3516 if (includeMargins) 3517 return this[0].offsetWidth + parseFloat(this.css('margin-right')) + parseFloat(this.css('margin-left')); 3518 else 3519 return this[0].offsetWidth; 3520 } 3521 else return null; 3522 }, 3523 height: function () { 3524 if (this[0] === window) { 3525 return window.innerHeight; 3526 } 3527 else { 3528 if (this.length > 0) { 3529 return parseFloat(this.css('height')); 3530 } 3531 else { 3532 return null; 3533 } 3534 } 3535 }, 3536 outerHeight: function (includeMargins) { 3537 if (this.length > 0) { 3538 if (includeMargins) 3539 return this[0].offsetHeight + parseFloat(this.css('margin-top')) + parseFloat(this.css('margin-bottom')); 3540 else 3541 return this[0].offsetHeight; 3542 } 3543 else return null; 3544 }, 3545 offset: function () { 3546 if (this.length > 0) { 3547 var el = this[0]; 3548 var box = el.getBoundingClientRect(); 3549 var body = document.body; 3550 var clientTop = el.clientTop || body.clientTop || 0; 3551 var clientLeft = el.clientLeft || body.clientLeft || 0; 3552 var scrollTop = window.pageYOffset || el.scrollTop; 3553 var scrollLeft = window.pageXOffset || el.scrollLeft; 3554 return { 3555 top: box.top + scrollTop - clientTop, 3556 left: box.left + scrollLeft - clientLeft 3557 }; 3558 } 3559 else { 3560 return null; 3561 } 3562 }, 3563 css: function (props, value) { 3564 var i; 3565 if (arguments.length === 1) { 3566 if (typeof props === 'string') { 3567 if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props); 3568 } 3569 else { 3570 for (i = 0; i < this.length; i++) { 3571 for (var prop in props) { 3572 this[i].style[prop] = props[prop]; 3573 } 3574 } 3575 return this; 3576 } 3577 } 3578 if (arguments.length === 2 && typeof props === 'string') { 3579 for (i = 0; i < this.length; i++) { 3580 this[i].style[props] = value; 3581 } 3582 return this; 3583 } 3584 return this; 3585 }, 3586 3587 //Dom manipulation 3588 each: function (callback) { 3589 for (var i = 0; i < this.length; i++) { 3590 callback.call(this[i], i, this[i]); 3591 } 3592 return this; 3593 }, 3594 html: function (html) { 3595 if (typeof html === 'undefined') { 3596 return this[0] ? this[0].innerHTML : undefined; 3597 } 3598 else { 3599 for (var i = 0; i < this.length; i++) { 3600 this[i].innerHTML = html; 3601 } 3602 return this; 3603 } 3604 }, 3605 is: function (selector) { 3606 if (!this[0]) return false;
3607 var compareWith, i; 3608 if (typeof selector === 'string') { 3609 var el = this[0]; 3610 if (el === document) return selector === document; 3611 if (el === window) return selector === window; 3612 3613 if (el.matches) return el.matches(selector); 3614 else if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector); 3615 else if (el.mozMatchesSelector) return el.mozMatchesSelector(selector); 3616 else if (el.msMatchesSelector) return el.msMatchesSelector(selector); 3617 else { 3618 compareWith = $(selector); 3619 for (i = 0; i < compareWith.length; i++) { 3620 if (compareWith[i] === this[0]) return true; 3621 } 3622 return false; 3623 } 3624 } 3625 else if (selector === document) return this[0] === document; 3626 else if (selector === window) return this[0] === window; 3627 else { 3628 if (selector.nodeType || selector instanceof Dom7) { 3629 compareWith = selector.nodeType ? [selector] : selector; 3630 for (i = 0; i < compareWith.length; i++) { 3631 if (compareWith[i] === this[0]) return true; 3632 } 3633 return false; 3634 } 3635 return false; 3636 } 3637 3638 }, 3639 index: function () { 3640 if (this[0]) { 3641 var child = this[0]; 3642 var i = 0; 3643 while ((child = child.previousSibling) !== null) { 3644 if (child.nodeType === 1) i++; 3645 } 3646 return i; 3647 } 3648 else return undefined; 3649 }, 3650 eq: function (index) { 3651 if (typeof index === 'undefined') return this; 3652 var length = this.length; 3653 var returnIndex; 3654 if (index > length - 1) { 3655 return new Dom7([]); 3656 } 3657 if (index < 0) { 3658 returnIndex = length + index; 3659 if (returnIndex < 0) return new Dom7([]); 3660 else return new Dom7([this[returnIndex]]); 3661 } 3662 return new Dom7([this[index]]); 3663 }, 3664 append: function (newChild) { 3665 var i, j; 3666 for (i = 0; i < this.length; i++) { 3667 if (typeof newChild === 'string') { 3668 var tempDiv = document.createElement('div'); 3669 tempDiv.innerHTML = newChild; 3670 while (tempDiv.firstChild) { 3671 this[i].appendChild(tempDiv.firstChild); 3672 } 3673 } 3674 else if (newChild instanceof Dom7) { 3675 for (j = 0; j < newChild.length; j++) { 3676 this[i].appendChild(newChild[j]); 3677 } 3678 } 3679 else { 3680 this[i].appendChild(newChild); 3681 } 3682 } 3683 return this; 3684 }, 3685 prepend: function (newChild) { 3686 var i, j; 3687 for (i = 0; i < this.length; i++) { 3688 if (typeof newChild === 'string') { 3689 var tempDiv = document.createElement('div'); 3690 tempDiv.innerHTML = newChild; 3691 for (j = tempDiv.childNodes.length - 1; j >= 0; j--) { 3692 this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]); 3693 } 3694 // this[i].insertAdjacentHTML('afterbegin', newChild); 3695 } 3696 else if (newChild instanceof Dom7) { 3697 for (j = 0; j < newChild.length; j++) { 3698 this[i].insertBefore(newChild[j], this[i].childNodes[0]); 3699 } 3700 } 3701 else { 3702 this[i].insertBefore(newChild, this[i].childNodes[0]); 3703 } 3704 } 3705 return this; 3706 }, 3707 insertBefore: function (selector) { 3708 var before = $(selector); 3709 for (var i = 0; i < this.length; i++) { 3710 if (before.length === 1) { 3711 before[0].parentNode.insertBefore(this[i], before[0]); 3712 } 3713 else if (before.length > 1) { 3714 for (var j = 0; j < before.length; j++) { 3715 before[j].parentNode.insertBefore(this[i].cloneNode(true), before[j]); 3716 } 3717 } 3718 } 3719 }, 3720 insertAfter: function (selector) { 3721 var after = $(selector); 3722 for (var i = 0; i < this.length; i++) { 3723 if (after.length === 1) { 3724 after[0].parentNode.insertBefore(this[i], after[0].nextSibling); 3725 } 3726 else if (after.length > 1) { 3727 for (var j = 0; j < after.length; j++) { 3728 after[j].parentNode.insertBefore(this[i].cloneNode(true), after[j].nextSibling); 3729 } 3730 } 3731 } 3732 }, 3733 next: function (selector) { 3734 if (this.length > 0) { 3735 if (selector) { 3736 if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) return new Dom7([this[0].nextElementSibling]); 3737 else return new Dom7([]); 3738 } 3739 else { 3740 if (this[0].nextElementSibling) return new Dom7([this[0].nextElementSibling]); 3741 else return new Dom7([]); 3742 } 3743 } 3744 else return new Dom7([]); 3745 }, 3746 nextAll: function (selector) { 3747 var nextEls = []; 3748 var el = this[0]; 3749 if (!el) return new Dom7([]); 3750 while (el.nextElementSibling) { 3751 var next = el.nextElementSibling; 3752 if (selector) { 3753 if($(next).is(selector)) nextEls.push(next); 3754 } 3755 else nextEls.push(next); 3756 el = next; 3757 } 3758 return new Dom7(nextEls); 3759 }, 3760 prev: function (selector) { 3761 if (this.length > 0) { 3762 if (selector) { 3763 if (this[0].previousElementSibling && $(this[0].previousElementSibling).is(selector)) return new Dom7([this[0].previousElementSibling]); 3764 else return new Dom7([]); 3765 } 3766 else { 3767 if (this[0].previousElementSibling) return new Dom7([this[0].previousElementSibling]); 3768 else return new Dom7([]); 3769 } 3770 } 3771 else return new Dom7([]); 3772 }, 3773 prevAll: function (selector) { 3774 var prevEls = []; 3775 var el = this[0]; 3776 if (!el) return new Dom7([]); 3777 while (el.previousElementSibling) { 3778 var prev = el.previousElementSibling; 3779 if (selector) { 3780 if($(prev).is(selector)) prevEls.push(prev); 3781 } 3782 else prevEls.push(prev); 3783 el = prev; 3784 } 3785 return new Dom7(prevEls); 3786 }, 3787 parent: function (selector) { 3788 var parents = []; 3789 for (var i = 0; i < this.length; i++) { 3790 if (selector) { 3791 if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode); 3792 } 3793 else { 3794 parents.push(this[i].parentNode); 3795 } 3796 } 3797 return $($.unique(parents)); 3798 }, 3799 parents: function (selector) { 3800 var parents = []; 3801 for (var i = 0; i < this.length; i++) { 3802 var parent = this[i].parentNode; 3803 while (parent) { 3804 if (selector) { 3805 if ($(parent).is(selector)) parents.push(parent); 3806 } 3807 else { 3808 parents.push(parent); 3809 } 3810 parent = parent.parentNode; 3811 } 3812 } 3813 return $($.unique(parents)); 3814 }, 3815 find : function (selector) { 3816 var foundElements = []; 3817 for (var i = 0; i < this.length; i++) { 3818 var found = this[i].querySelectorAll(selector); 3819 for (var j = 0; j < found.length; j++) { 3820 foundElements.push(found[j]); 3821 } 3822 } 3823 return new Dom7(foundElements); 3824 }, 3825 children: function (selector) { 3826 var children = []; 3827 for (var i = 0; i < this.length; i++) { 3828 var childNodes = this[i].childNodes; 3829 3830 for (var j = 0; j < childNodes.length; j++) { 3831 if (!selector) { 3832 if (childNodes[j].nodeType === 1) children.push(childNodes[j]); 3833 } 3834 else { 3835 if (childNodes[j].nodeType === 1 && $(childNodes[j]).is(selector)) children.push(childNodes[j]); 3836 } 3837 } 3838 } 3839 return new Dom7($.unique(children)); 3840 }, 3841 remove: function () { 3842 for (var i = 0; i < this.length; i++) { 3843 if (this[i].parentNode) this[i].parentNode.removeChild(this[i]); 3844 } 3845 return this; 3846 }, 3847 add: function () { 3848 var dom = this; 3849 var i, j; 3850 for (i = 0; i < arguments.length; i++) { 3851 var toAdd = $(arguments[i]); 3852 for (j = 0; j < toAdd.length; j++) { 3853 dom[dom.length] = toAdd[j]; 3854 dom.length++; 3855 } 3856 } 3857 return dom; 3858 } 3859 }; 3860 $.fn = Dom7.prototype; 3861 $.unique = function (arr) { 3862 var unique = []; 3863 for (var i = 0; i < arr.length; i++) {
3864 if (unique.indexOf(arr[i]) === -1) unique.push(arr[i]); 3865 } 3866 return unique; 3867 }; 3868 3869 return $; 3870 })(); 3871 3872 3873 /*=========================== 3874 Get Dom libraries 3875 ===========================*/ 3876 var swiperDomPlugins = ['jQuery', 'Zepto', 'Dom7']; 3877 for (var i = 0; i < swiperDomPlugins.length; i++) { 3878 if (window[swiperDomPlugins[i]]) { 3879 addLibraryPlugin(window[swiperDomPlugins[i]]); 3880 } 3881 } 3882 // Required DOM Plugins 3883 var domLib; 3884 if (typeof Dom7 === 'undefined') { 3885 domLib = window.Dom7 || window.Zepto || window.jQuery; 3886 } 3887 else { 3888 domLib = Dom7; 3889 } 3890 3891 /*=========================== 3892 Add .swiper plugin from Dom libraries 3893 ===========================*/ 3894 function addLibraryPlugin(lib) { 3895 lib.fn.swiper = function (params) { 3896 var firstInstance; 3897 lib(this).each(function () { 3898 var s = new Swiper(this, params); 3899 if (!firstInstance) firstInstance = s; 3900 }); 3901 return firstInstance; 3902 }; 3903 } 3904 3905 if (domLib) { 3906 if (!('transitionEnd' in domLib.fn)) { 3907 domLib.fn.transitionEnd = function (callback) { 3908 var events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'], 3909 i, j, dom = this; 3910 function fireCallBack(e) { 3911 /*jshint validthis:true */ 3912 if (e.target !== this) return; 3913 callback.call(this, e); 3914 for (i = 0; i < events.length; i++) { 3915 dom.off(events[i], fireCallBack); 3916 } 3917 } 3918 if (callback) { 3919 for (i = 0; i < events.length; i++) { 3920 dom.on(events[i], fireCallBack); 3921 } 3922 } 3923 return this; 3924 }; 3925 } 3926 if (!('transform' in domLib.fn)) { 3927 domLib.fn.transform = function (transform) { 3928 for (var i = 0; i < this.length; i++) { 3929 var elStyle = this[i].style; 3930 elStyle.webkitTransform = elStyle.MsTransform = elStyle.msTransform = elStyle.MozTransform = elStyle.OTransform = elStyle.transform = transform; 3931 } 3932 return this; 3933 }; 3934 } 3935 if (!('transition' in domLib.fn)) { 3936 domLib.fn.transition = function (duration) { 3937 if (typeof duration !== 'string') { 3938 duration = duration + 'ms'; 3939 } 3940 for (var i = 0; i < this.length; i++) { 3941 var elStyle = this[i].style; 3942 elStyle.webkitTransitionDuration = elStyle.MsTransitionDuration = elStyle.msTransitionDuration = elStyle.MozTransitionDuration = elStyle.OTransitionDuration = elStyle.transitionDuration = duration; 3943 } 3944 return this; 3945 }; 3946 } 3947 } 3948 3949 window.Swiper = Swiper; 3950})(); 3951/*=========================== 3952Swiper AMD Export 3953===========================*/ 3954if (typeof(module) !== 'undefined') 3955{ 3956 module.exports = window.Swiper; 3957} 3958else if (typeof define === 'function' && define.amd) { 3959 define([], function () { 3960 'use strict'; 3961 return window.Swiper; 3962 }); 3963}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.