diff --git a/.jshintrc b/.jshintrc index 34403f4a9..0f0342a49 100644 --- a/.jshintrc +++ b/.jshintrc @@ -18,6 +18,7 @@ "white" : true, "globals":{ "document": true, + "define": true, "Swiper": true, "window": true, "HTMLElement": true, diff --git a/bower.json b/bower.json index cb9abb209..11ab9c1fc 100644 --- a/bower.json +++ b/bower.json @@ -5,7 +5,7 @@ "url": "https://github.com/nolimits4web/Swiper.git" }, "description": "Mobile touch slider and framework with hardware accelerated transitions", - "version": "2.4.3", + "version": "2.5.0", "author": "Vladimir Kharlampidi", "homepage": "http://www.idangero.us/sliders/swiper/", "keywords": ["swiper", "swipe", "slider"], diff --git a/dist/idangerous.swiper.css b/dist/idangerous.swiper.css index f0d81eff1..190fde7cb 100644 --- a/dist/idangerous.swiper.css +++ b/dist/idangerous.swiper.css @@ -1,5 +1,5 @@ /* - * swiper 2.4.3 + * swiper 2.5.0 * Mobile touch slider and framework with hardware accelerated transitions * * http://www.idangero.us/sliders/swiper/ @@ -10,7 +10,7 @@ * * Licensed under GPL & MIT * - * Released on: January 29, 2014 + * Released on: March 6, 2014 */ .swiper-container { margin:0 auto; diff --git a/dist/idangerous.swiper.js b/dist/idangerous.swiper.js index d536bb2e3..cb1f6ab40 100644 --- a/dist/idangerous.swiper.js +++ b/dist/idangerous.swiper.js @@ -1,5 +1,5 @@ /* - * swiper 2.4.3 + * swiper 2.5.0 * Mobile touch slider and framework with hardware accelerated transitions * * http://www.idangero.us/sliders/swiper/ @@ -10,9 +10,11 @@ * * Licensed under GPL & MIT * - * Released on: January 29, 2014 + * Released on: March 6, 2014 */ var Swiper = function (selector, params) { + 'use strict'; + /*========================= A little bit dirty but required part for IE8 and old FF support ===========================*/ @@ -20,7 +22,7 @@ var Swiper = function (selector, params) { if (HTMLElement) { var element = HTMLElement.prototype; if (element.__defineGetter__) { - element.__defineGetter__("outerHTML", function () { return new XMLSerializer().serializeToString(this); } ); + element.__defineGetter__('outerHTML', function () { return new XMLSerializer().serializeToString(this); }); } } } @@ -37,17 +39,17 @@ var Swiper = function (selector, params) { }); } return el.currentStyle[prop] ? el.currentStyle[prop] : null; - } + }; return this; - } + }; } if (!Array.prototype.indexOf) { - Array.prototype.indexOf = function(obj, start) { + Array.prototype.indexOf = function (obj, start) { for (var i = (start || 0), j = this.length; i < j; i++) { if (this[i] === obj) { return i; } } return -1; - } + }; } if (!document.querySelectorAll) { if (!window.jQuery) return; @@ -62,9 +64,9 @@ var Swiper = function (selector, params) { /*========================= Check for correct selector ===========================*/ - if(typeof selector === 'undefined') return; + if (typeof selector === 'undefined') return; - if(!(selector.nodeType)){ + if (!(selector.nodeType)) { if ($$(selector).length === 0) return; } @@ -77,24 +79,24 @@ var Swiper = function (selector, params) { Default Flags and vars ===========================*/ _this.touches = { - start:0, - startX:0, - startY:0, - current:0, - currentX:0, - currentY:0, - diff:0, - abs:0 + start: 0, + startX: 0, + startY: 0, + current: 0, + currentX: 0, + currentY: 0, + diff: 0, + abs: 0 }; _this.positions = { - start:0, - abs:0, - diff:0, - current:0 + start: 0, + abs: 0, + diff: 0, + current: 0 }; _this.times = { - start:0, - end:0 + start: 0, + end: 0 }; _this.id = (new Date()).getTime(); @@ -111,11 +113,11 @@ var Swiper = function (selector, params) { _this.slidesGrid = []; _this.imagesToLoad = []; _this.imagesLoaded = 0; - _this.wrapperLeft=0; - _this.wrapperRight=0; - _this.wrapperTop=0; - _this.wrapperBottom=0; - _this.isAndroid = navigator.userAgent.toLowerCase().indexOf('android')>=0; + _this.wrapperLeft = 0; + _this.wrapperRight = 0; + _this.wrapperTop = 0; + _this.wrapperBottom = 0; + _this.isAndroid = navigator.userAgent.toLowerCase().indexOf('android') >= 0; var wrapper, slideSize, wrapperSize, direction, isScrolling, containerSize; /*========================= @@ -133,11 +135,12 @@ var Swiper = function (selector, params) { momentumBounceRatio: 1, slidesPerView : 1, slidesPerGroup : 1, + slidesPerViewFit: true, //Fit to slide when spv "auto" and slides larger than container simulateTouch : true, followFinger : true, shortSwipes : true, longSwipesRatio: 0.5, - moveStartThreshold:false, + moveStartThreshold: false, onlyExternal : false, createPagination : true, pagination : false, @@ -160,8 +163,8 @@ var Swiper = function (selector, params) { autoplayDisableOnInteraction: true, autoplayStopOnLast: false, //Loop mode - loop:false, - loopAdditionalSlides:0, + loop: false, + loopAdditionalSlides: 0, //Auto Height calculateHeight: false, cssWidthAndHeight: false, @@ -189,26 +192,26 @@ var Swiper = function (selector, params) { DOMAnimation : true, //Slides Loader loader: { - slides:[], //array with slides - slidesHTMLType:'inner', // or 'outer' + slides: [], //array with slides + slidesHTMLType: 'inner', // or 'outer' surroundGroups: 1, //keep preloaded slides groups around view logic: 'reload', //or 'change' loadAllSlides: false }, //Namespace - slideElement : 'div', - slideClass : 'swiper-slide', - slideActiveClass : 'swiper-slide-active', - slideVisibleClass : 'swiper-slide-visible', + slideElement: 'div', + slideClass: 'swiper-slide', + slideActiveClass: 'swiper-slide-active', + slideVisibleClass: 'swiper-slide-visible', slideDuplicateClass: 'swiper-slide-duplicate', - wrapperClass : 'swiper-wrapper', + wrapperClass: 'swiper-wrapper', paginationElementClass: 'swiper-pagination-switch', - paginationActiveClass : 'swiper-active-switch', - paginationVisibleClass : 'swiper-visible-switch' - } + paginationActiveClass: 'swiper-active-switch', + paginationVisibleClass: 'swiper-visible-switch' + }; params = params || {}; for (var prop in defaults) { - if (prop in params && typeof params[prop]==='object') { + if (prop in params && typeof params[prop] === 'object') { for (var subProp in defaults[prop]) { if (! (subProp in params[prop])) { params[prop][subProp] = defaults[prop][subProp]; @@ -216,7 +219,7 @@ var Swiper = function (selector, params) { } } else if (! (prop in params)) { - params[prop] = defaults[prop] + params[prop] = defaults[prop]; } } _this.params = params; @@ -227,12 +230,12 @@ var Swiper = function (selector, params) { if (params.loop) { params.resistance = '100%'; } - var isH = params.mode==='horizontal'; + var isH = params.mode === 'horizontal'; /*========================= Define Touch Events ===========================*/ - var desktopEvents = ['mousedown','mousemove', 'mouseup']; + var desktopEvents = ['mousedown', 'mousemove', 'mouseup']; if (_this.browser.ie10) desktopEvents = ['MSPointerDown', 'MSPointerMove', 'MSPointerUp']; if (_this.browser.ie11) desktopEvents = ['pointerdown', 'pointermove', 'pointerup']; @@ -247,14 +250,14 @@ var Swiper = function (selector, params) { ===========================*/ for (var i = _this.container.childNodes.length - 1; i >= 0; i--) { if (_this.container.childNodes[i].className) { - var _wrapperClasses = _this.container.childNodes[i].className.split(' ') + var _wrapperClasses = _this.container.childNodes[i].className.split(/\s+/); for (var j = 0; j < _wrapperClasses.length; j++) { - if (_wrapperClasses[j]===params.wrapperClass) { + if (_wrapperClasses[j] === params.wrapperClass) { wrapper = _this.container.childNodes[i]; } - }; + } } - }; + } _this.wrapper = wrapper; /*========================= @@ -263,7 +266,7 @@ var Swiper = function (selector, params) { _this._extendSwiperSlide = function (el) { el.append = function () { if (params.loop) { - el.insertAfter(_this.slides.length-_this.loopedSlides); + el.insertAfter(_this.slides.length - _this.loopedSlides); } else { _this.wrapper.appendChild(el); @@ -271,7 +274,7 @@ var Swiper = function (selector, params) { } return el; - } + }; el.prepend = function () { if (params.loop) { _this.wrapper.insertBefore(el, _this.slides[_this.loopedSlides]); @@ -284,9 +287,9 @@ var Swiper = function (selector, params) { } _this.reInit(); return el; - } + }; el.insertAfter = function (index) { - if(typeof index === 'undefined') return false; + if (typeof index === 'undefined') return false; var beforeSlide; if (params.loop) { @@ -303,18 +306,18 @@ var Swiper = function (selector, params) { } else { beforeSlide = _this.slides[index + 1]; - _this.wrapper.insertBefore(el, beforeSlide) + _this.wrapper.insertBefore(el, beforeSlide); } _this.reInit(); return el; - } + }; el.clone = function () { - return _this._extendSwiperSlide(el.cloneNode(true)) - } + return _this._extendSwiperSlide(el.cloneNode(true)); + }; el.remove = function () { _this.wrapper.removeChild(el); _this.reInit(); - } + }; el.html = function (html) { if (typeof html === 'undefined') { return el.innerHTML; @@ -323,46 +326,46 @@ var Swiper = function (selector, params) { el.innerHTML = html; return el; } - } + }; el.index = function () { var index; for (var i = _this.slides.length - 1; i >= 0; i--) { - if(el === _this.slides[i]) index = i; + if (el === _this.slides[i]) index = i; } return index; - } + }; el.isActive = function () { if (el.index() === _this.activeIndex) return true; else return false; - } - if (!el.swiperSlideDataStorage) el.swiperSlideDataStorage={}; + }; + if (!el.swiperSlideDataStorage) el.swiperSlideDataStorage = {}; el.getData = function (name) { return el.swiperSlideDataStorage[name]; - } + }; el.setData = function (name, value) { el.swiperSlideDataStorage[name] = value; return el; - } + }; el.data = function (name, value) { - if (!value) { - return el.getAttribute('data-'+name); + if (typeof value === 'undefined') { + return el.getAttribute('data-' + name); } else { - el.setAttribute('data-'+name,value); + el.setAttribute('data-' + name, value); return el; } - } + }; el.getWidth = function (outer) { return _this.h.getWidth(el, outer); - } + }; el.getHeight = function (outer) { return _this.h.getHeight(el, outer); - } - el.getOffset = function() { + }; + el.getOffset = function () { return _this.h.getOffset(el); - } + }; return el; - } + }; //Calculate information about number of slides _this.calcSlides = function (forceCalcSlides) { @@ -372,9 +375,9 @@ var Swiper = function (selector, params) { for (var i = 0; i < _this.wrapper.childNodes.length; i++) { if (_this.wrapper.childNodes[i].className) { var _className = _this.wrapper.childNodes[i].className; - var _slideClasses = _className.split(' '); + var _slideClasses = _className.split(/\s+/); for (var j = 0; j < _slideClasses.length; j++) { - if(_slideClasses[j]===params.slideClass) { + if (_slideClasses[j] === params.slideClass) { _this.slides.push(_this.wrapper.childNodes[i]); } } @@ -383,8 +386,8 @@ var Swiper = function (selector, params) { for (i = _this.slides.length - 1; i >= 0; i--) { _this._extendSwiperSlide(_this.slides[i]); } - if (oldNumber===false) return; - if(oldNumber!==_this.slides.length || forceCalcSlides) { + if (oldNumber === false) return; + if (oldNumber !== _this.slides.length || forceCalcSlides) { // Number of slides has been changed removeSlideEvents(); @@ -393,37 +396,37 @@ var Swiper = function (selector, params) { if (_this.params.pagination) _this.createPagination(); _this.callPlugins('numberOfSlidesChanged'); } - } + }; //Create Slide _this.createSlide = function (html, slideClassList, el) { - var slideClassList = slideClassList || _this.params.slideClass; - var el = el||params.slideElement; + slideClassList = slideClassList || _this.params.slideClass; + el = el || params.slideElement; var newSlide = document.createElement(el); - newSlide.innerHTML = html||''; + newSlide.innerHTML = html || ''; newSlide.className = slideClassList; return _this._extendSwiperSlide(newSlide); - } + }; //Append Slide _this.appendSlide = function (html, slideClassList, el) { if (!html) return; if (html.nodeType) { - return _this._extendSwiperSlide(html).append() + return _this._extendSwiperSlide(html).append(); } else { - return _this.createSlide(html, slideClassList, el).append() + return _this.createSlide(html, slideClassList, el).append(); } - } + }; _this.prependSlide = function (html, slideClassList, el) { if (!html) return; if (html.nodeType) { - return _this._extendSwiperSlide(html).prepend() + return _this._extendSwiperSlide(html).prepend(); } else { - return _this.createSlide(html, slideClassList, el).prepend() + return _this.createSlide(html, slideClassList, el).prepend(); } - } + }; _this.insertSlideAfter = function (index, html, slideClassList, el) { if (typeof index === 'undefined') return false; if (html.nodeType) { @@ -432,12 +435,12 @@ var Swiper = function (selector, params) { else { return _this.createSlide(html, slideClassList, el).insertAfter(index); } - } + }; _this.removeSlide = function (index) { if (_this.slides[index]) { if (params.loop) { - if (!_this.slides[index+_this.loopedSlides]) return false; - _this.slides[index+_this.loopedSlides].remove(); + if (!_this.slides[index + _this.loopedSlides]) return false; + _this.slides[index + _this.loopedSlides].remove(); _this.removeLoopedSlides(); _this.calcSlides(); _this.createLoop(); @@ -446,62 +449,61 @@ var Swiper = function (selector, params) { return true; } else return false; - } + }; _this.removeLastSlide = function () { - if (_this.slides.length>0) { + if (_this.slides.length > 0) { if (params.loop) { _this.slides[_this.slides.length - 1 - _this.loopedSlides].remove(); _this.removeLoopedSlides(); _this.calcSlides(); _this.createLoop(); } - else _this.slides[ (_this.slides.length-1) ].remove(); + else _this.slides[_this.slides.length - 1].remove(); return true; } else { return false; } - } + }; _this.removeAllSlides = function () { for (var i = _this.slides.length - 1; i >= 0; i--) { - _this.slides[i].remove() + _this.slides[i].remove(); } - } + }; _this.getSlide = function (index) { - return _this.slides[index] - } + return _this.slides[index]; + }; _this.getLastSlide = function () { - return _this.slides[ _this.slides.length-1 ] - } + return _this.slides[_this.slides.length - 1]; + }; _this.getFirstSlide = function () { - return _this.slides[0] - } + return _this.slides[0]; + }; //Currently Active Slide _this.activeSlide = function () { - return _this.slides[_this.activeIndex] - } + return _this.slides[_this.activeIndex]; + }; /*========================= Wrapper for Callbacks : Allows additive callbacks via function arrays ===========================*/ - _this.fireCallback = function() { + _this.fireCallback = function () { var callback = arguments[0]; - if( Object.prototype.toString.call( callback ) === '[object Array]' ) { + if (Object.prototype.toString.call(callback) === '[object Array]') { for (var i = 0; i < callback.length; i++) { if (typeof callback[i] === 'function') { - callback[i](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]) + callback[i](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); } } - } else if (Object.prototype.toString.call( callback ) === '[object String]') { - if (params['on'+callback]) _this.fireCallback(params['on'+callback]); + } else if (Object.prototype.toString.call(callback) === '[object String]') { + if (params['on' + callback]) _this.fireCallback(params['on' + callback]); } else { callback(arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); } - } - function isArray (obj) { - "use strict"; - if (Object.prototype.toString.apply( obj ) === '[object Array]') return true; + }; + function isArray(obj) { + if (Object.prototype.toString.apply(obj) === '[object Array]') return true; return false; } @@ -512,7 +514,6 @@ var Swiper = function (selector, params) { * @return {*} */ _this.addCallback = function (callback, func) { - "use strict"; var _this = this, tempFunc; if (_this.params['on' + callback]) { if (isArray(this.params['on' + callback])) { @@ -527,12 +528,12 @@ var Swiper = function (selector, params) { this.params['on' + callback] = []; return this.params['on' + callback].push(func); } - } + }; _this.removeCallbacks = function (callback) { if (_this.params['on' + callback]) { - return _this.params['on' + callback] = null; + _this.params['on' + callback] = null; } - } + }; /*========================= Plugins API @@ -541,22 +542,22 @@ var Swiper = function (selector, params) { for (var plugin in _this.plugins) { if (params[plugin]) { var p = _this.plugins[plugin](_this, params[plugin]); - if (p) _plugins.push( p ); + if (p) _plugins.push(p); } } - _this.callPlugins = function(method, args) { - if (!args) args = {} - for (var i=0; i<_plugins.length; i++) { + _this.callPlugins = function (method, args) { + if (!args) args = {}; + for (var i = 0; i < _plugins.length; i++) { if (method in _plugins[i]) { _plugins[i][method](args); } } - } + }; /*========================= Windows Phone 8 Fix ===========================*/ - if ( (_this.browser.ie10 || _this.browser.ie11) && !params.onlyExternal) { + if ((_this.browser.ie10 || _this.browser.ie11) && !params.onlyExternal) { _this.wrapper.classList.add('swiper-wp8-' + (isH ? 'horizontal' : 'vertical')); } @@ -564,20 +565,23 @@ var Swiper = function (selector, params) { Free Mode Class ===========================*/ if (params.freeMode) { - _this.container.className+=' swiper-free-mode'; + _this.container.className += ' swiper-free-mode'; } /*================================================== Init/Re-init/Resize Fix ====================================================*/ _this.initialized = false; - _this.init = function(force, forceCalcSlides) { + _this.init = function (force, forceCalcSlides) { var _width = _this.h.getWidth(_this.container); var _height = _this.h.getHeight(_this.container); - if (_width===_this.width && _height===_this.height && !force) return; + if (_width === _this.width && _height === _this.height && !force) return; + if (_width === 0 || _height === 0) return; _this.width = _width; _this.height = _height; + var slideWidth, slideHeight, slideMaxHeight, wrapperWidth, wrapperHeight, slideLeft; + var i; // loop index variable to avoid JSHint W004 / W038 containerSize = isH ? _width : _height; var wrapper = _this.wrapper; @@ -585,13 +589,13 @@ var Swiper = function (selector, params) { _this.calcSlides(forceCalcSlides); } - if (params.slidesPerView==='auto') { + if (params.slidesPerView === 'auto') { //Auto mode var slidesWidth = 0; var slidesHeight = 0; //Unset Styles - if (params.slidesOffset>0) { + if (params.slidesOffset > 0) { wrapper.style.paddingLeft = ''; wrapper.style.paddingRight = ''; wrapper.style.paddingTop = ''; @@ -599,71 +603,82 @@ var Swiper = function (selector, params) { } wrapper.style.width = ''; wrapper.style.height = ''; - if (params.offsetPxBefore>0) { + if (params.offsetPxBefore > 0) { if (isH) _this.wrapperLeft = params.offsetPxBefore; else _this.wrapperTop = params.offsetPxBefore; } - if (params.offsetPxAfter>0) { + if (params.offsetPxAfter > 0) { if (isH) _this.wrapperRight = params.offsetPxAfter; else _this.wrapperBottom = params.offsetPxAfter; } if (params.centeredSlides) { if (isH) { - _this.wrapperLeft = (containerSize - this.slides[0].getWidth(true) )/2; - _this.wrapperRight = (containerSize - _this.slides[ _this.slides.length-1 ].getWidth(true))/2; + _this.wrapperLeft = (containerSize - this.slides[0].getWidth(true)) / 2; + _this.wrapperRight = (containerSize - _this.slides[_this.slides.length - 1].getWidth(true)) / 2; } else { - _this.wrapperTop = (containerSize - _this.slides[0].getHeight(true))/2; - _this.wrapperBottom = (containerSize - _this.slides[ _this.slides.length-1 ].getHeight(true))/2; + _this.wrapperTop = (containerSize - _this.slides[0].getHeight(true)) / 2; + _this.wrapperBottom = (containerSize - _this.slides[_this.slides.length - 1].getHeight(true)) / 2; } } if (isH) { - if (_this.wrapperLeft>=0) wrapper.style.paddingLeft = _this.wrapperLeft+'px'; - if (_this.wrapperRight>=0) wrapper.style.paddingRight = _this.wrapperRight+'px'; + if (_this.wrapperLeft >= 0) wrapper.style.paddingLeft = _this.wrapperLeft + 'px'; + if (_this.wrapperRight >= 0) wrapper.style.paddingRight = _this.wrapperRight + 'px'; } else { - if (_this.wrapperTop>=0) wrapper.style.paddingTop = _this.wrapperTop+'px'; - if (_this.wrapperBottom>=0) wrapper.style.paddingBottom = _this.wrapperBottom+'px'; + if (_this.wrapperTop >= 0) wrapper.style.paddingTop = _this.wrapperTop + 'px'; + if (_this.wrapperBottom >= 0) wrapper.style.paddingBottom = _this.wrapperBottom + 'px'; } - var slideLeft = 0; - var centeredSlideLeft=0; + slideLeft = 0; + var centeredSlideLeft = 0; _this.snapGrid = []; _this.slidesGrid = []; - var slideMaxHeight = 0; - for(var i = 0; i<_this.slides.length; i++) { - var slideWidth = _this.slides[i].getWidth(true); - var slideHeight = _this.slides[i].getHeight(true); + slideMaxHeight = 0; + for (i = 0; i < _this.slides.length; i++) { + slideWidth = _this.slides[i].getWidth(true); + slideHeight = _this.slides[i].getHeight(true); if (params.calculateHeight) { - slideMaxHeight = Math.max(slideMaxHeight, slideHeight) + slideMaxHeight = Math.max(slideMaxHeight, slideHeight); } var _slideSize = isH ? slideWidth : slideHeight; if (params.centeredSlides) { - var nextSlideWidth = i === _this.slides.length-1 ? 0 : _this.slides[i+1].getWidth(true); - var nextSlideHeight = i === _this.slides.length-1 ? 0 : _this.slides[i+1].getHeight(true); + var nextSlideWidth = i === _this.slides.length - 1 ? 0 : _this.slides[i + 1].getWidth(true); + var nextSlideHeight = i === _this.slides.length - 1 ? 0 : _this.slides[i + 1].getHeight(true); var nextSlideSize = isH ? nextSlideWidth : nextSlideHeight; - if (_slideSize>containerSize) { - for (var j=0; j<=Math.floor(_slideSize/(containerSize+_this.wrapperLeft)); j++) { - if (j === 0) _this.snapGrid.push(slideLeft+_this.wrapperLeft); - else _this.snapGrid.push(slideLeft+_this.wrapperLeft+containerSize*j); + if (_slideSize > containerSize) { + if (params.slidesPerViewFit) { + _this.snapGrid.push(slideLeft + _this.wrapperLeft); + _this.snapGrid.push(slideLeft + _slideSize - containerSize + _this.wrapperLeft); } - _this.slidesGrid.push(slideLeft+_this.wrapperLeft); + else { + for (var j = 0; j <= Math.floor(_slideSize / (containerSize + _this.wrapperLeft)); j++) { + if (j === 0) _this.snapGrid.push(slideLeft + _this.wrapperLeft); + else _this.snapGrid.push(slideLeft + _this.wrapperLeft + containerSize * j); + } + } + _this.slidesGrid.push(slideLeft + _this.wrapperLeft); } else { _this.snapGrid.push(centeredSlideLeft); _this.slidesGrid.push(centeredSlideLeft); } - - centeredSlideLeft += _slideSize/2 + nextSlideSize/2; - + centeredSlideLeft += _slideSize / 2 + nextSlideSize / 2; } else { - if (_slideSize>containerSize) { - for (var j=0; j<=Math.floor(_slideSize/containerSize); j++) { - _this.snapGrid.push(slideLeft+containerSize*j); + if (_slideSize > containerSize) { + if (params.slidesPerViewFit) { + _this.snapGrid.push(slideLeft); + _this.snapGrid.push(slideLeft + _slideSize - containerSize); + } + else { + for (var k = 0; k <= Math.floor(_slideSize / containerSize); k++) { + _this.snapGrid.push(slideLeft + containerSize * k); + } } + } else { _this.snapGrid.push(slideLeft); @@ -677,15 +692,15 @@ var Swiper = function (selector, params) { slidesHeight += slideHeight; } if (params.calculateHeight) _this.height = slideMaxHeight; - if(isH) { + if (isH) { wrapperSize = slidesWidth + _this.wrapperRight + _this.wrapperLeft; - wrapper.style.width = (slidesWidth)+'px'; - wrapper.style.height = (_this.height)+'px'; + wrapper.style.width = (slidesWidth) + 'px'; + wrapper.style.height = (_this.height) + 'px'; } else { wrapperSize = slidesHeight + _this.wrapperTop + _this.wrapperBottom; - wrapper.style.width = (_this.width)+'px'; - wrapper.style.height = (slidesHeight)+'px'; + wrapper.style.width = (_this.width) + 'px'; + wrapper.style.height = (slidesHeight) + 'px'; } } @@ -693,100 +708,103 @@ var Swiper = function (selector, params) { //Scroll Container wrapper.style.width = ''; wrapper.style.height = ''; - var wrapperWidth = _this.slides[0].getWidth(true); - var wrapperHeight = _this.slides[0].getHeight(true); + wrapperWidth = _this.slides[0].getWidth(true); + wrapperHeight = _this.slides[0].getHeight(true); wrapperSize = isH ? wrapperWidth : wrapperHeight; - wrapper.style.width = wrapperWidth+'px'; - wrapper.style.height = wrapperHeight+'px'; + wrapper.style.width = wrapperWidth + 'px'; + wrapper.style.height = wrapperHeight + 'px'; slideSize = isH ? wrapperWidth : wrapperHeight; } else { //For usual slides if (params.calculateHeight) { - var slideMaxHeight = 0; - var wrapperHeight = 0; + slideMaxHeight = 0; + wrapperHeight = 0; //ResetWrapperSize - if (!isH) _this.container.style.height= ''; - wrapper.style.height=''; + if (!isH) _this.container.style.height = ''; + wrapper.style.height = ''; - for (var i=0; i<_this.slides.length; i++) { + for (i = 0; i < _this.slides.length; i++) { //ResetSlideSize - _this.slides[i].style.height=''; - slideMaxHeight = Math.max( _this.slides[i].getHeight(true), slideMaxHeight ); - if (!isH) wrapperHeight+=_this.slides[i].getHeight(true); + _this.slides[i].style.height = ''; + slideMaxHeight = Math.max(_this.slides[i].getHeight(true), slideMaxHeight); + if (!isH) wrapperHeight += _this.slides[i].getHeight(true); } - var slideHeight = slideMaxHeight; + slideHeight = slideMaxHeight; _this.height = slideHeight; if (isH) wrapperHeight = slideHeight; - else containerSize = slideHeight, _this.container.style.height= containerSize+'px'; + else { + containerSize = slideHeight; + _this.container.style.height = containerSize + 'px'; + } } else { - var slideHeight = isH ? _this.height : _this.height/params.slidesPerView; - var wrapperHeight = isH ? _this.height : _this.slides.length*slideHeight; + slideHeight = isH ? _this.height : _this.height / params.slidesPerView; + wrapperHeight = isH ? _this.height : _this.slides.length * slideHeight; } - var slideWidth = isH ? _this.width/params.slidesPerView : _this.width; - var wrapperWidth = isH ? _this.slides.length*slideWidth : _this.width; + slideWidth = isH ? _this.width / params.slidesPerView : _this.width; + wrapperWidth = isH ? _this.slides.length * slideWidth : _this.width; slideSize = isH ? slideWidth : slideHeight; - if (params.offsetSlidesBefore>0) { - if (isH) _this.wrapperLeft = slideSize*params.offsetSlidesBefore; - else _this.wrapperTop = slideSize*params.offsetSlidesBefore; + if (params.offsetSlidesBefore > 0) { + if (isH) _this.wrapperLeft = slideSize * params.offsetSlidesBefore; + else _this.wrapperTop = slideSize * params.offsetSlidesBefore; } - if (params.offsetSlidesAfter>0) { - if (isH) _this.wrapperRight = slideSize*params.offsetSlidesAfter; - else _this.wrapperBottom = slideSize*params.offsetSlidesAfter; + if (params.offsetSlidesAfter > 0) { + if (isH) _this.wrapperRight = slideSize * params.offsetSlidesAfter; + else _this.wrapperBottom = slideSize * params.offsetSlidesAfter; } - if (params.offsetPxBefore>0) { + if (params.offsetPxBefore > 0) { if (isH) _this.wrapperLeft = params.offsetPxBefore; else _this.wrapperTop = params.offsetPxBefore; } - if (params.offsetPxAfter>0) { + if (params.offsetPxAfter > 0) { if (isH) _this.wrapperRight = params.offsetPxAfter; else _this.wrapperBottom = params.offsetPxAfter; } if (params.centeredSlides) { if (isH) { - _this.wrapperLeft = (containerSize - slideSize)/2; - _this.wrapperRight = (containerSize - slideSize)/2; + _this.wrapperLeft = (containerSize - slideSize) / 2; + _this.wrapperRight = (containerSize - slideSize) / 2; } else { - _this.wrapperTop = (containerSize - slideSize)/2; - _this.wrapperBottom = (containerSize - slideSize)/2; + _this.wrapperTop = (containerSize - slideSize) / 2; + _this.wrapperBottom = (containerSize - slideSize) / 2; } } if (isH) { - if (_this.wrapperLeft>0) wrapper.style.paddingLeft = _this.wrapperLeft+'px'; - if (_this.wrapperRight>0) wrapper.style.paddingRight = _this.wrapperRight+'px'; + if (_this.wrapperLeft > 0) wrapper.style.paddingLeft = _this.wrapperLeft + 'px'; + if (_this.wrapperRight > 0) wrapper.style.paddingRight = _this.wrapperRight + 'px'; } else { - if (_this.wrapperTop>0) wrapper.style.paddingTop = _this.wrapperTop+'px'; - if (_this.wrapperBottom>0) wrapper.style.paddingBottom = _this.wrapperBottom+'px'; + if (_this.wrapperTop > 0) wrapper.style.paddingTop = _this.wrapperTop + 'px'; + if (_this.wrapperBottom > 0) wrapper.style.paddingBottom = _this.wrapperBottom + 'px'; } wrapperSize = isH ? wrapperWidth + _this.wrapperRight + _this.wrapperLeft : wrapperHeight + _this.wrapperTop + _this.wrapperBottom; if (!params.cssWidthAndHeight) { if (parseFloat(wrapperWidth) > 0) { - wrapper.style.width = wrapperWidth+'px'; + wrapper.style.width = wrapperWidth + 'px'; } if (parseFloat(wrapperHeight) > 0) { - wrapper.style.height = wrapperHeight+'px'; + wrapper.style.height = wrapperHeight + 'px'; } } - var slideLeft = 0; + slideLeft = 0; _this.snapGrid = []; _this.slidesGrid = []; - for (var i=0; i<_this.slides.length; i++) { + for (i = 0; i < _this.slides.length; i++) { _this.snapGrid.push(slideLeft); _this.slidesGrid.push(slideLeft); - slideLeft+=slideSize; + slideLeft += slideSize; if (!params.cssWidthAndHeight) { if (parseFloat(slideWidth) > 0) { - _this.slides[i].style.width = slideWidth+'px'; + _this.slides[i].style.width = slideWidth + 'px'; } if (parseFloat(slideHeight) > 0) { - _this.slides[i].style.height = slideHeight+'px'; + _this.slides[i].style.height = slideHeight + 'px'; } } } @@ -795,24 +813,24 @@ var Swiper = function (selector, params) { if (!_this.initialized) { _this.callPlugins('onFirstInit'); - if (params.onFirstInit) _this.fireCallback(params.onFirstInit,_this); + if (params.onFirstInit) _this.fireCallback(params.onFirstInit, _this); } else { _this.callPlugins('onInit'); - if (params.onInit) _this.fireCallback(params.onInit,_this); + if (params.onInit) _this.fireCallback(params.onInit, _this); } _this.initialized = true; - } - + }; + _this.reInit = function (forceCalcSlides) { _this.init(true, forceCalcSlides); - } - + }; + _this.resizeFix = function (reInit) { _this.callPlugins('beforeResizeFix'); - + _this.init(params.resizeReInit || reInit); - + // swipe to active slide in fixed mode if (!params.freeMode) { _this.swipeTo((params.loop ? _this.activeLoopIndex : _this.activeIndex), 0, false); @@ -827,22 +845,21 @@ var Swiper = function (selector, params) { } else { if (typeof autoplayIntervalId !== 'undefined') { - clearInterval(autoplayIntervalId) + clearInterval(autoplayIntervalId); autoplayIntervalId = undefined; - _this.startAutoplay(); + _this.startAutoplay(); } } } } - // move wrapper to the beginning in free mode else if (_this.getWrapperTranslate() < -maxWrapperPosition()) { _this.setWrapperTransition(0); _this.setWrapperTranslate(-maxWrapperPosition()); } - + _this.callPlugins('afterResizeFix'); - } + }; /*========================================== Max and Min Positions @@ -853,13 +870,10 @@ var Swiper = function (selector, params) { a = wrapperSize - containerSize; } // if (params.loop) a -= containerSize; - if (params.slidesPerView > _this.slides.length) a = 0; - if (a<0) a = 0; - return a; - } - function minWrapperPosition() { - var a = 0; - // if (params.loop) a = containerSize; + if (params.slidesPerView > _this.slides.length && !params.centeredSlides) { + a = 0; + } + if (a < 0) a = 0; return a; } @@ -868,9 +882,9 @@ var Swiper = function (selector, params) { ============================================*/ function initEvents() { var bind = _this.h.addEventListener; - var eventTarget = params.eventTarget=='wrapper' ? _this.wrapper : _this.container; + var eventTarget = params.eventTarget === 'wrapper' ? _this.wrapper : _this.container; //Touch Events - if (! (_this.browser.ie10 || _this.browser.ie11) ) { + if (! (_this.browser.ie10 || _this.browser.ie11)) { if (_this.support.touch) { bind(eventTarget, 'touchstart', onTouchStart); bind(eventTarget, 'touchmove', onTouchMove); @@ -897,15 +911,15 @@ var Swiper = function (selector, params) { //Mousewheel _this._wheelEvent = false; if (params.mousewheelControl) { - if ( document.onmousewheel !== undefined ) { - _this._wheelEvent = "mousewheel"; + if (document.onmousewheel !== undefined) { + _this._wheelEvent = 'mousewheel'; } try { - WheelEvent("wheel"); - _this._wheelEvent = "wheel"; + new WheelEvent('wheel'); + _this._wheelEvent = 'wheel'; } catch (e) {} - if ( !_this._wheelEvent ) { - _this._wheelEvent = "DOMMouseScroll"; + if (!_this._wheelEvent) { + _this._wheelEvent = 'DOMMouseScroll'; } if (_this._wheelEvent) { @@ -914,35 +928,36 @@ var Swiper = function (selector, params) { } //Keyboard + function _loadImage(src) { + var image = new Image(); + image.onload = function () { + if (_this && _this.imagesLoaded) _this.imagesLoaded++; + if (_this.imagesLoaded === _this.imagesToLoad.length) { + _this.reInit(); + if (params.onImagesReady) _this.fireCallback(params.onImagesReady, _this); + } + }; + image.src = src; + } + if (params.keyboardControl) { bind(document, 'keydown', handleKeyboardKeys); } if (params.updateOnImagesReady) { _this.imagesToLoad = $$('img', _this.container); - for (var i=0; i<_this.imagesToLoad.length; i++) { - _loadImage(_this.imagesToLoad[i].getAttribute('src')) + for (var i = 0; i < _this.imagesToLoad.length; i++) { + _loadImage(_this.imagesToLoad[i].getAttribute('src')); } } - function _loadImage(src) { - var image = new Image(); - image.onload = function(){ - _this.imagesLoaded++; - if (_this.imagesLoaded==_this.imagesToLoad.length) { - _this.reInit(); - if (params.onImagesReady) _this.fireCallback(params.onImagesReady, _this); - } - } - image.src = src; - } } //Remove Event Listeners - _this.destroy = function(){ + _this.destroy = function () { var unbind = _this.h.removeEventListener; - var eventTarget = params.eventTarget=='wrapper' ? _this.wrapper : _this.container; + var eventTarget = params.eventTarget === 'wrapper' ? _this.wrapper : _this.container; //Touch Events - if (! (_this.browser.ie10 || _this.browser.ie11) ) { + if (! (_this.browser.ie10 || _this.browser.ie11)) { if (_this.support.touch) { unbind(eventTarget, 'touchstart', onTouchStart); unbind(eventTarget, 'touchmove', onTouchMove); @@ -964,7 +979,7 @@ var Swiper = function (selector, params) { if (params.autoResize) { unbind(window, 'resize', _this.resizeFix); } - + //Init Slide Events removeSlideEvents(); @@ -975,7 +990,7 @@ var Swiper = function (selector, params) { //Mousewheel if (params.mousewheelControl && _this._wheelEvent) { - unbind(_this.container, _this._wheelEvent, handleMousewheel); + unbind(_this.container, _this._wheelEvent, handleMousewheel); } //Keyboard @@ -991,7 +1006,8 @@ var Swiper = function (selector, params) { //Destroy variable _this = null; - } + }; + function addSlideEvents() { var bind = _this.h.addEventListener, i; @@ -999,26 +1015,26 @@ var Swiper = function (selector, params) { //Prevent Links Events if (params.preventLinks) { var links = $$('a', _this.container); - for (i=0; i=scrollLeft && point[0]<=scrollLeft+windowWidth && - point[1]>=scrollTop && point[1]<=scrollTop+windowHeight + point[0] >= scrollLeft && point[0] <= scrollLeft + windowWidth && + point[1] >= scrollTop && point[1] <= scrollTop + windowHeight ) { inView = true; } @@ -1085,42 +1102,52 @@ var Swiper = function (selector, params) { if (!inView) return; } if (isH) { - if (kc==37 || kc==39) { + if (kc === 37 || kc === 39) { if (e.preventDefault) e.preventDefault(); else e.returnValue = false; } - if (kc == 39) _this.swipeNext(); - if (kc == 37) _this.swipePrev(); + if (kc === 39) _this.swipeNext(); + if (kc === 37) _this.swipePrev(); } else { - if (kc==38 || kc==40) { + if (kc === 38 || kc === 40) { if (e.preventDefault) e.preventDefault(); else e.returnValue = false; } - if (kc == 40) _this.swipeNext(); - if (kc == 38) _this.swipePrev(); + if (kc === 40) _this.swipeNext(); + if (kc === 38) _this.swipePrev(); } } + _this.disableKeyboardControl = function () { + params.keyboardControl = false; + _this.h.removeEventListener(document, 'keydown', handleKeyboardKeys); + }; + + _this.enableKeyboardControl = function () { + params.keyboardControl = true; + _this.h.addEventListener(document, 'keydown', handleKeyboardKeys); + }; + /*========================================== Mousewheel Control ============================================*/ var lastScrollTime = (new Date()).getTime(); - function handleMousewheel (e) { + function handleMousewheel(e) { var we = _this._wheelEvent; var delta = 0; - + //Opera & IE if (e.detail) delta = -e.detail; //WebKits - else if (we == 'mousewheel') { + else if (we === 'mousewheel') { if (params.mousewheelControlForceToAxis) { if (isH) { - if (Math.abs(e.wheelDeltaX)>Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX; + if (Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX; else return; } else { - if (Math.abs(e.wheelDeltaY)>Math.abs(e.wheelDeltaX)) delta = e.wheelDeltaY; + if (Math.abs(e.wheelDeltaY) > Math.abs(e.wheelDeltaX)) delta = e.wheelDeltaY; else return; } } @@ -1129,49 +1156,49 @@ var Swiper = function (selector, params) { } } //Old FireFox - else if (we == 'DOMMouseScroll') delta = -e.detail; + else if (we === 'DOMMouseScroll') delta = -e.detail; //New FireFox - else if (we == 'wheel') { + else if (we === 'wheel') { if (params.mousewheelControlForceToAxis) { if (isH) { - if (Math.abs(e.deltaX)>Math.abs(e.deltaY)) delta = -e.deltaX; + if (Math.abs(e.deltaX) > Math.abs(e.deltaY)) delta = -e.deltaX; else return; } else { - if (Math.abs(e.deltaY)>Math.abs(e.deltaX)) delta = -e.deltaY; + if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) delta = -e.deltaY; else return; } } else { - delta = Math.abs(e.deltaX)>Math.abs(e.deltaY) ? - e.deltaX : - e.deltaY; + delta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? - e.deltaX : - e.deltaY; } } if (!params.freeMode) { if ((new Date()).getTime() - lastScrollTime > 60) { - if(delta<0) _this.swipeNext(); + if (delta < 0) _this.swipeNext(); else _this.swipePrev(); } - lastScrollTime = (new Date()).getTime(); - + lastScrollTime = (new Date()).getTime(); + } else { //Freemode or scrollContainer: var position = _this.getWrapperTranslate() + delta; - + if (position > 0) position = 0; if (position < -maxWrapperPosition()) position = -maxWrapperPosition(); - + _this.setWrapperTransition(0); _this.setWrapperTranslate(position); _this.updateActiveSlide(position); // Return page scroll on edge positions - if (position == 0 || position == -maxWrapperPosition()) return; + if (position === 0 || position === -maxWrapperPosition()) return; } if (params.autoplay) _this.stopAutoplay(true); - if(e.preventDefault) e.preventDefault(); + if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; } @@ -1190,7 +1217,7 @@ var Swiper = function (selector, params) { /*========================= Slides Events Handlers ===========================*/ - + _this.allowSlideClick = true; function slideClick(event) { if (_this.allowSlideClick) { @@ -1198,14 +1225,14 @@ var Swiper = function (selector, params) { _this.fireCallback(params.onSlideClick, _this, event); } } - + function slideTouch(event) { setClickedSlide(event); _this.fireCallback(params.onSlideTouch, _this, event); } - + function setClickedSlide(event) { - + // IE 6-8 support if (!event.currentTarget) { var element = event.srcElement; @@ -1213,22 +1240,22 @@ var Swiper = function (selector, params) { if (element.className.indexOf(params.slideClass) > -1) { break; } - } - while (element = element.parentNode); + element = element.parentNode; + } while (element); _this.clickedSlide = element; } else { _this.clickedSlide = event.currentTarget; } - + _this.clickedSlideIndex = _this.slides.indexOf(_this.clickedSlide); _this.clickedSlideLoopIndex = _this.clickedSlideIndex - (_this.loopedSlides || 0); } - + _this.allowLinks = true; function preventClick(e) { if (!_this.allowLinks) { - if(e.preventDefault) e.preventDefault(); + if (e.preventDefault) e.preventDefault(); else e.returnValue = false; if (params.preventLinksPropagation && 'stopPropagation' in e) { e.stopPropagation(); @@ -1240,7 +1267,7 @@ var Swiper = function (selector, params) { if (e.stopPropagation) e.stopPropagation(); else e.returnValue = false; return false; - + } /*================================================== @@ -1258,20 +1285,18 @@ var Swiper = function (selector, params) { if (params.noSwiping && (event.target || event.srcElement) && noSwipingSlide(event.target || event.srcElement)) return false; allowMomentumBounce = false; - // Reset threshold - thresholdFirstMove = false; //Check For Nested Swipers _this.isTouched = true; - isTouchEvent = event.type=='touchstart'; + isTouchEvent = event.type === 'touchstart'; - if (!isTouchEvent || event.targetTouches.length == 1 ) { + if (!isTouchEvent || event.targetTouches.length === 1) { _this.callPlugins('onTouchStartBegin'); - if(!isTouchEvent && !_this.isAndroid) { - if(event.preventDefault) event.preventDefault(); + if (!isTouchEvent && !_this.isAndroid) { + if (event.preventDefault) event.preventDefault(); else event.returnValue = false; } - + var pageX = isTouchEvent ? event.targetTouches[0].pageX : (event.pageX || event.clientX); var pageY = isTouchEvent ? event.targetTouches[0].pageY : (event.pageY || event.clientY); @@ -1297,7 +1322,7 @@ var Swiper = function (selector, params) { isScrolling = undefined; //Set Treshold - if (params.moveStartThreshold>0) { + if (params.moveStartThreshold > 0) { allowThresholdMove = false; } @@ -1311,19 +1336,19 @@ var Swiper = function (selector, params) { function onTouchMove(event) { // If slider is not touched - exit if (!_this.isTouched || params.onlyExternal) return; - if (isTouchEvent && event.type=='mousemove') return; + if (isTouchEvent && event.type === 'mousemove') return; var pageX = isTouchEvent ? event.targetTouches[0].pageX : (event.pageX || event.clientX); var pageY = isTouchEvent ? event.targetTouches[0].pageY : (event.pageY || event.clientY); //check for scrolling - if ( typeof isScrolling === 'undefined' && isH) { - isScrolling = !!( isScrolling || Math.abs(pageY - _this.touches.startY) > Math.abs( pageX - _this.touches.startX ) ); + if (typeof isScrolling === 'undefined' && isH) { + isScrolling = !!(isScrolling || Math.abs(pageY - _this.touches.startY) > Math.abs(pageX - _this.touches.startX)); } - if ( typeof isScrolling === 'undefined' && !isH) { - isScrolling = !!( isScrolling || Math.abs(pageY - _this.touches.startY) < Math.abs( pageX - _this.touches.startX ) ); + if (typeof isScrolling === 'undefined' && !isH) { + isScrolling = !!(isScrolling || Math.abs(pageY - _this.touches.startY) < Math.abs(pageX - _this.touches.startX)); } - if (isScrolling ) { + if (isScrolling) { _this.isTouched = false; return; } @@ -1347,12 +1372,12 @@ var Swiper = function (selector, params) { if (params.autoplay) { _this.stopAutoplay(true); } - if (!isTouchEvent || event.touches.length == 1) { + if (!isTouchEvent || event.touches.length === 1) { //Moved Flag if (!_this.isMoved) { _this.callPlugins('onTouchMoveStart'); - + if (params.loop) { _this.fixLoop(); _this.positions.start = _this.getWrapperTranslate(); @@ -1360,53 +1385,54 @@ var Swiper = function (selector, params) { if (params.onTouchMoveStart) _this.fireCallback(params.onTouchMoveStart, _this); } _this.isMoved = true; - + // cancel event - if(event.preventDefault) event.preventDefault(); + if (event.preventDefault) event.preventDefault(); else event.returnValue = false; - _this.touches.current = isH ? pageX : pageY ; + _this.touches.current = isH ? pageX : pageY; _this.positions.current = (_this.touches.current - _this.touches.start) * params.touchRatio + _this.positions.start; //Resistance Callbacks - if(_this.positions.current > 0 && params.onResistanceBefore) { + if (_this.positions.current > 0 && params.onResistanceBefore) { _this.fireCallback(params.onResistanceBefore, _this, _this.positions.current); } - if(_this.positions.current < -maxWrapperPosition() && params.onResistanceAfter) { + if (_this.positions.current < -maxWrapperPosition() && params.onResistanceAfter) { _this.fireCallback(params.onResistanceAfter, _this, Math.abs(_this.positions.current + maxWrapperPosition())); } //Resistance - if (params.resistance && params.resistance!='100%') { + if (params.resistance && params.resistance !== '100%') { + var resistance; //Resistance for Negative-Back sliding - if(_this.positions.current > 0) { - var resistance = 1 - _this.positions.current/containerSize/2; + if (_this.positions.current > 0) { + resistance = 1 - _this.positions.current / containerSize / 2; if (resistance < 0.5) - _this.positions.current = (containerSize/2); + _this.positions.current = (containerSize / 2); else _this.positions.current = _this.positions.current * resistance; } //Resistance for After-End Sliding - if ( _this.positions.current < -maxWrapperPosition() ) { + if (_this.positions.current < -maxWrapperPosition()) { - var diff = (_this.touches.current - _this.touches.start)*params.touchRatio + (maxWrapperPosition()+_this.positions.start); - var resistance = (containerSize+diff)/(containerSize); - var newPos = _this.positions.current-diff*(1-resistance)/2; - var stopPos = -maxWrapperPosition() - containerSize/2; + var diff = (_this.touches.current - _this.touches.start) * params.touchRatio + (maxWrapperPosition() + _this.positions.start); + resistance = (containerSize + diff) / (containerSize); + var newPos = _this.positions.current - diff * (1 - resistance) / 2; + var stopPos = -maxWrapperPosition() - containerSize / 2; - if (newPos < stopPos || resistance<=0) + if (newPos < stopPos || resistance <= 0) _this.positions.current = stopPos; else _this.positions.current = newPos; } } - if (params.resistance && params.resistance=='100%') { + if (params.resistance && params.resistance === '100%') { //Resistance for Negative-Back sliding - if(_this.positions.current > 0 && !(params.freeMode&&!params.freeModeFluid)) { + if (_this.positions.current > 0 && !(params.freeMode && !params.freeModeFluid)) { _this.positions.current = 0; } //Resistance for After-End Sliding - if ( (_this.positions.current) < -maxWrapperPosition() && !(params.freeMode&&!params.freeModeFluid)) { + if (_this.positions.current < -maxWrapperPosition() && !(params.freeMode && !params.freeModeFluid)) { _this.positions.current = -maxWrapperPosition(); } } @@ -1417,11 +1443,11 @@ var Swiper = function (selector, params) { _this.setWrapperTranslate(_this.positions.current); } else { - if ( Math.abs(_this.touches.current - _this.touches.start)>params.moveStartThreshold || allowThresholdMove) { + if (Math.abs(_this.touches.current - _this.touches.start) > params.moveStartThreshold || allowThresholdMove) { if (!allowThresholdMove) { allowThresholdMove = true; _this.touches.start = _this.touches.current; - return + return; } _this.setWrapperTranslate(_this.positions.current); } @@ -1443,11 +1469,11 @@ var Swiper = function (selector, params) { } //Velocity if (!velocityPrevPosition) velocityPrevPosition = _this.touches.current; - if (!velocityPrevTime) velocityPrevTime = (new Date).getTime(); - _this.velocity = (_this.touches.current - velocityPrevPosition)/((new Date).getTime() - velocityPrevTime)/2; - if (Math.abs(_this.touches.current - velocityPrevPosition)<2) _this.velocity=0; + if (!velocityPrevTime) velocityPrevTime = (new Date()).getTime(); + _this.velocity = (_this.touches.current - velocityPrevPosition) / ((new Date()).getTime() - velocityPrevTime) / 2; + if (Math.abs(_this.touches.current - velocityPrevPosition) < 2) _this.velocity = 0; velocityPrevPosition = _this.touches.current; - velocityPrevTime = (new Date).getTime(); + velocityPrevTime = (new Date()).getTime(); //Callbacks _this.callPlugins('onTouchMoveEnd'); if (params.onTouchMove) _this.fireCallback(params.onTouchMove, _this); @@ -1461,8 +1487,8 @@ var Swiper = function (selector, params) { _this.swipeReset(); } // If slider is not touched exit - if ( params.onlyExternal || !_this.isTouched ) return; - _this.isTouched = false + if (params.onlyExternal || !_this.isTouched) return; + _this.isTouched = false; //Return Grab Cursor if (params.grabCursor) { @@ -1473,8 +1499,8 @@ var Swiper = function (selector, params) { } //Check for Current Position - if (!_this.positions.current && _this.positions.current!==0) { - _this.positions.current = _this.positions.start + if (!_this.positions.current && _this.positions.current !== 0) { + _this.positions.current = _this.positions.start; } //For case if slider touched but not moved @@ -1486,18 +1512,18 @@ var Swiper = function (selector, params) { _this.times.end = (new Date()).getTime(); //Difference - _this.touches.diff = _this.touches.current - _this.touches.start - _this.touches.abs = Math.abs(_this.touches.diff) + _this.touches.diff = _this.touches.current - _this.touches.start; + _this.touches.abs = Math.abs(_this.touches.diff); - _this.positions.diff = _this.positions.current - _this.positions.start - _this.positions.abs = Math.abs(_this.positions.diff) + _this.positions.diff = _this.positions.current - _this.positions.start; + _this.positions.abs = Math.abs(_this.positions.diff); - var diff = _this.positions.diff ; - var diffAbs =_this.positions.abs ; - var timeDiff = _this.times.end - _this.times.start + var diff = _this.positions.diff; + var diffAbs = _this.positions.abs; + var timeDiff = _this.times.end - _this.times.start; - if(diffAbs < 5 && (timeDiff) < 300 && _this.allowLinks == false) { - if (!params.freeMode && diffAbs!=0) _this.swipeReset() + if (diffAbs < 5 && (timeDiff) < 300 && _this.allowLinks === false) { + if (!params.freeMode && diffAbs !== 0) _this.swipeReset(); //Release inner links if (params.preventLinks) { _this.allowLinks = true; @@ -1506,7 +1532,7 @@ var Swiper = function (selector, params) { _this.allowSlideClick = true; } } - + setTimeout(function () { //Release inner links if (params.preventLinks) { @@ -1524,7 +1550,7 @@ var Swiper = function (selector, params) { _this.isMoved = false; if (params.onTouchEnd) _this.fireCallback(params.onTouchEnd, _this); _this.callPlugins('onTouchEnd'); - return; + return; } if (!_this.isMoved || _this.positions.current > 0 || _this.positions.current < -maxPosition) { _this.swipeReset(); @@ -1537,52 +1563,52 @@ var Swiper = function (selector, params) { //Free Mode if (params.freeMode) { - if ( params.freeModeFluid ) { - var momentumDuration = 1000*params.momentumRatio; - var momentumDistance = _this.velocity*momentumDuration; - var newPosition = _this.positions.current + momentumDistance + if (params.freeModeFluid) { + var momentumDuration = 1000 * params.momentumRatio; + var momentumDistance = _this.velocity * momentumDuration; + var newPosition = _this.positions.current + momentumDistance; var doBounce = false; var afterBouncePosition; - var bounceAmount = Math.abs( _this.velocity )*20*params.momentumBounceRatio; + var bounceAmount = Math.abs(_this.velocity) * 20 * params.momentumBounceRatio; if (newPosition < -maxPosition) { if (params.momentumBounce && _this.support.transitions) { - if (newPosition + maxPosition < -bounceAmount) newPosition = -maxPosition-bounceAmount; + if (newPosition + maxPosition < -bounceAmount) newPosition = -maxPosition - bounceAmount; afterBouncePosition = -maxPosition; - doBounce=true; + doBounce = true; allowMomentumBounce = true; } else newPosition = -maxPosition; } if (newPosition > 0) { if (params.momentumBounce && _this.support.transitions) { - if (newPosition>bounceAmount) newPosition = bounceAmount; - afterBouncePosition = 0 + if (newPosition > bounceAmount) newPosition = bounceAmount; + afterBouncePosition = 0; doBounce = true; allowMomentumBounce = true; } else newPosition = 0; } //Fix duration - if (_this.velocity!=0) momentumDuration = Math.abs((newPosition - _this.positions.current)/_this.velocity) + if (_this.velocity !== 0) momentumDuration = Math.abs((newPosition - _this.positions.current) / _this.velocity); _this.setWrapperTranslate(newPosition); - _this.setWrapperTransition( momentumDuration ); + _this.setWrapperTransition(momentumDuration); if (params.momentumBounce && doBounce) { _this.wrapperTransitionEnd(function () { if (!allowMomentumBounce) return; if (params.onMomentumBounce) _this.fireCallback(params.onMomentumBounce, _this); _this.callPlugins('onMomentumBounce'); - + _this.setWrapperTranslate(afterBouncePosition); _this.setWrapperTransition(300); - }) + }); } - _this.updateActiveSlide(newPosition) + _this.updateActiveSlide(newPosition); } - if (!params.freeModeFluid || timeDiff >= 300) _this.updateActiveSlide(_this.positions.current) + if (!params.freeModeFluid || timeDiff >= 300) _this.updateActiveSlide(_this.positions.current); if (params.onTouchEnd) _this.fireCallback(params.onTouchEnd, _this); _this.callPlugins('onTouchEnd'); @@ -1590,53 +1616,53 @@ var Swiper = function (selector, params) { } //Direction - direction = diff < 0 ? "toNext" : "toPrev" + direction = diff < 0 ? 'toNext' : 'toPrev'; //Short Touches - if (direction=="toNext" && ( timeDiff <= 300 ) ) { - if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset() + if (direction === 'toNext' && (timeDiff <= 300)) { + if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset(); else _this.swipeNext(true); } - if (direction=="toPrev" && ( timeDiff <= 300 ) ) { - if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset() + if (direction === 'toPrev' && (timeDiff <= 300)) { + if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset(); else _this.swipePrev(true); } //Long Touches var targetSlideSize = 0; - if(params.slidesPerView == 'auto') { + if (params.slidesPerView === 'auto') { //Define current slide's width var currentPosition = Math.abs(_this.getWrapperTranslate()); var slidesOffset = 0; var _slideSize; - for (var i=0; i<_this.slides.length; i++) { + for (var i = 0; i < _this.slides.length; i++) { _slideSize = isH ? _this.slides[i].getWidth(true) : _this.slides[i].getHeight(true); - slidesOffset+= _slideSize; - if (slidesOffset>currentPosition) { + slidesOffset += _slideSize; + if (slidesOffset > currentPosition) { targetSlideSize = _slideSize; break; } } - if (targetSlideSize>containerSize) targetSlideSize = containerSize; + if (targetSlideSize > containerSize) targetSlideSize = containerSize; } else { targetSlideSize = slideSize * params.slidesPerView; } - if (direction=="toNext" && ( timeDiff > 300 ) ) { - if (diffAbs >= targetSlideSize*params.longSwipesRatio) { - _this.swipeNext(true) + if (direction === 'toNext' && (timeDiff > 300)) { + if (diffAbs >= targetSlideSize * params.longSwipesRatio) { + _this.swipeNext(true); } else { - _this.swipeReset() + _this.swipeReset(); } } - if (direction=="toPrev" && ( timeDiff > 300 ) ) { - if (diffAbs >= targetSlideSize*params.longSwipesRatio) { + if (direction === 'toPrev' && (timeDiff > 300)) { + if (diffAbs >= targetSlideSize * params.longSwipesRatio) { _this.swipePrev(true); } else { - _this.swipeReset() + _this.swipeReset(); } } if (params.onTouchEnd) _this.fireCallback(params.onTouchEnd, _this); @@ -1647,7 +1673,7 @@ var Swiper = function (selector, params) { /*================================================== noSwiping Bubble Check by Isaac Strack ====================================================*/ - function noSwipingSlide(el){ + function noSwipingSlide(el) { /*This function is specifically designed to check the parent elements for the noSwiping class, up to the wrapper. We need to check parents because while onTouchStart bubbles, _this.isTouched is checked in onTouchStart, which stops the bubbling. So, if a text box, for example, is the initial target, and the parent slide container has the noSwiping class, the _this.isTouched @@ -1656,189 +1682,176 @@ var Swiper = function (selector, params) { // First we create a truthy variable, which is that swiping is allowd (noSwiping = false) var noSwiping = false; - + // Now we iterate up (parentElements) until we reach the node with the wrapperClass. - do{ + do { // Each time, we check to see if there's a 'swiper-no-swiping' class (noSwipingClass). - if (el.className.indexOf(params.noSwipingClass)>-1) + if (el.className.indexOf(params.noSwipingClass) > -1) { noSwiping = true; // If there is, we set noSwiping = true; } el = el.parentElement; // now we iterate up (parent node) - } while(!noSwiping && el.parentElement && el.className.indexOf(params.wrapperClass)==-1); // also include el.parentElement truthy, just in case. + } while (!noSwiping && el.parentElement && el.className.indexOf(params.wrapperClass) === -1); // also include el.parentElement truthy, just in case. // because we didn't check the wrapper itself, we do so now, if noSwiping is false: - if (!noSwiping && el.className.indexOf(params.wrapperClass)>-1 && el.className.indexOf(params.noSwipingClass)>-1) + if (!noSwiping && el.className.indexOf(params.wrapperClass) > -1 && el.className.indexOf(params.noSwipingClass) > -1) noSwiping = true; // if the wrapper has the noSwipingClass, we set noSwiping = true; return noSwiping; } - + function addClassToHtmlString(klass, outerHtml) { var par = document.createElement('div'); var child; par.innerHTML = outerHtml; child = par.firstChild; - child.className += ' '+ klass; + child.className += ' ' + klass; return child.outerHTML; } - + /*================================================== Swipe Functions ====================================================*/ - _this.swipeNext = function(internal){ + _this.swipeNext = function (internal) { if (!internal && params.loop) _this.fixLoop(); if (!internal && params.autoplay) _this.stopAutoplay(true); _this.callPlugins('onSwipeNext'); var currentPosition = _this.getWrapperTranslate(); var newPosition = currentPosition; - if (params.slidesPerView=='auto') { - for (var i=0; i<_this.snapGrid.length; i++) { - if (-currentPosition >= _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { - newPosition = -_this.snapGrid[i+1] + if (params.slidesPerView === 'auto') { + for (var i = 0; i < _this.snapGrid.length; i++) { + if (-currentPosition >= _this.snapGrid[i] && -currentPosition < _this.snapGrid[i + 1]) { + newPosition = -_this.snapGrid[i + 1]; break; } } } else { var groupSize = slideSize * params.slidesPerGroup; - newPosition = -(Math.floor(Math.abs(currentPosition)/Math.floor(groupSize))*groupSize + groupSize); + newPosition = -(Math.floor(Math.abs(currentPosition) / Math.floor(groupSize)) * groupSize + groupSize); } - if (newPosition < - maxWrapperPosition()) { - newPosition = - maxWrapperPosition() - }; - if (newPosition == currentPosition) return false; + if (newPosition < -maxWrapperPosition()) { + newPosition = -maxWrapperPosition(); + } + if (newPosition === currentPosition) return false; swipeToPosition(newPosition, 'next'); - return true - } - _this.swipePrev = function(internal){ + return true; + }; + _this.swipePrev = function (internal) { if (!internal && params.loop) _this.fixLoop(); if (!internal && params.autoplay) _this.stopAutoplay(true); _this.callPlugins('onSwipePrev'); var currentPosition = Math.ceil(_this.getWrapperTranslate()); var newPosition; - if (params.slidesPerView=='auto') { + if (params.slidesPerView === 'auto') { newPosition = 0; - for (var i=1; i<_this.snapGrid.length; i++) { - if (-currentPosition == _this.snapGrid[i]) { - newPosition = -_this.snapGrid[i-1] + for (var i = 1; i < _this.snapGrid.length; i++) { + if (-currentPosition === _this.snapGrid[i]) { + newPosition = -_this.snapGrid[i - 1]; break; } - if (-currentPosition > _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { - newPosition = -_this.snapGrid[i] + if (-currentPosition > _this.snapGrid[i] && -currentPosition < _this.snapGrid[i + 1]) { + newPosition = -_this.snapGrid[i]; break; } } } else { var groupSize = slideSize * params.slidesPerGroup; - newPosition = -(Math.ceil(-currentPosition/groupSize)-1)*groupSize; + newPosition = -(Math.ceil(-currentPosition / groupSize) - 1) * groupSize; } if (newPosition > 0) newPosition = 0; - if (newPosition == currentPosition) return false; + if (newPosition === currentPosition) return false; swipeToPosition(newPosition, 'prev'); return true; - } - _this.swipeReset = function(){ + }; + _this.swipeReset = function () { _this.callPlugins('onSwipeReset'); var currentPosition = _this.getWrapperTranslate(); var groupSize = slideSize * params.slidesPerGroup; var newPosition; var maxPosition = -maxWrapperPosition(); - if (params.slidesPerView=='auto') { + if (params.slidesPerView === 'auto') { newPosition = 0; - for (var i=0; i<_this.snapGrid.length; i++) { - if (-currentPosition===_this.snapGrid[i]) return; - if (-currentPosition >= _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { - if(_this.positions.diff>0) newPosition = -_this.snapGrid[i+1] - else newPosition = -_this.snapGrid[i] + for (var i = 0; i < _this.snapGrid.length; i++) { + if (-currentPosition === _this.snapGrid[i]) return; + if (-currentPosition >= _this.snapGrid[i] && -currentPosition < _this.snapGrid[i + 1]) { + if (_this.positions.diff > 0) newPosition = -_this.snapGrid[i + 1]; + else newPosition = -_this.snapGrid[i]; break; } } - if (-currentPosition >= _this.snapGrid[_this.snapGrid.length-1]) newPosition = -_this.snapGrid[_this.snapGrid.length-1]; - if (currentPosition <= -maxWrapperPosition()) newPosition = -maxWrapperPosition() + if (-currentPosition >= _this.snapGrid[_this.snapGrid.length - 1]) newPosition = -_this.snapGrid[_this.snapGrid.length - 1]; + if (currentPosition <= -maxWrapperPosition()) newPosition = -maxWrapperPosition(); } else { - newPosition = currentPosition<0 ? Math.round(currentPosition/groupSize)*groupSize : 0 + newPosition = currentPosition < 0 ? Math.round(currentPosition / groupSize) * groupSize : 0; } if (params.scrollContainer) { - newPosition = currentPosition<0 ? currentPosition : 0; + newPosition = currentPosition < 0 ? currentPosition : 0; } if (newPosition < -maxWrapperPosition()) { - newPosition = -maxWrapperPosition() + newPosition = -maxWrapperPosition(); } - if (params.scrollContainer && (containerSize>slideSize)) { + if (params.scrollContainer && (containerSize > slideSize)) { newPosition = 0; } - if (newPosition == currentPosition) return false; + if (newPosition === currentPosition) return false; swipeToPosition(newPosition, 'reset'); return true; - } - - _this.swipeTo = function(index, speed, runCallbacks) { + }; + + _this.swipeTo = function (index, speed, runCallbacks) { index = parseInt(index, 10); - _this.callPlugins('onSwipeTo', {index:index, speed:speed}); + _this.callPlugins('onSwipeTo', {index: index, speed: speed}); if (params.loop) index = index + _this.loopedSlides; var currentPosition = _this.getWrapperTranslate(); - if (index > (_this.slides.length-1) || index < 0) return; - var newPosition - if (params.slidesPerView=='auto') { - newPosition = -_this.slidesGrid[ index ]; + if (index > (_this.slides.length - 1) || index < 0) return; + var newPosition; + if (params.slidesPerView === 'auto') { + newPosition = -_this.slidesGrid[index]; } else { - newPosition = -index*slideSize; + newPosition = -index * slideSize; } if (newPosition < - maxWrapperPosition()) { newPosition = - maxWrapperPosition(); - }; + } - if (newPosition == currentPosition) return false; + if (newPosition === currentPosition) return false; - runCallbacks = runCallbacks===false ? false : true; - swipeToPosition(newPosition, 'to', {index:index, speed:speed, runCallbacks:runCallbacks}); + runCallbacks = runCallbacks === false ? false : true; + swipeToPosition(newPosition, 'to', {index: index, speed: speed, runCallbacks: runCallbacks}); return true; - } - + }; + function swipeToPosition(newPosition, action, toOptions) { - var speed = (action=='to' && toOptions.speed >= 0) ? toOptions.speed : params.speed; + var speed = (action === 'to' && toOptions.speed >= 0) ? toOptions.speed : params.speed; var timeOld = + new Date(); - if (_this.support.transitions || !params.DOMAnimation) { - _this.setWrapperTranslate(newPosition); - _this.setWrapperTransition(speed); - } - else { - //Try the DOM animation - var currentPosition = _this.getWrapperTranslate(); - var animationStep = Math.ceil( (newPosition - currentPosition)/speed*(1000/60) ); - var direction = currentPosition > newPosition ? 'toNext' : 'toPrev'; - var condition = direction=='toNext' ? currentPosition > newPosition : currentPosition < newPosition; - if (_this._DOMAnimating) return; - anim(); - } - function anim(){ + function anim() { var timeNew = + new Date(); var time = timeNew - timeOld; - currentPosition += animationStep * time / (1000/60); - condition = direction=='toNext' ? currentPosition > newPosition : currentPosition < newPosition; + currentPosition += animationStep * time / (1000 / 60); + condition = direction === 'toNext' ? currentPosition > newPosition : currentPosition < newPosition; if (condition) { _this.setWrapperTranslate(Math.round(currentPosition)); - _this._DOMAnimating = true - window.setTimeout(function(){ - anim() - }, 1000 / 60) + _this._DOMAnimating = true; + window.setTimeout(function () { + anim(); + }, 1000 / 60); } else { if (params.onSlideChangeEnd) _this.fireCallback(params.onSlideChangeEnd, _this); @@ -1847,23 +1860,38 @@ var Swiper = function (selector, params) { } } + if (_this.support.transitions || !params.DOMAnimation) { + _this.setWrapperTranslate(newPosition); + _this.setWrapperTransition(speed); + } + else { + //Try the DOM animation + var currentPosition = _this.getWrapperTranslate(); + var animationStep = Math.ceil((newPosition - currentPosition) / speed * (1000 / 60)); + var direction = currentPosition > newPosition ? 'toNext' : 'toPrev'; + var condition = direction === 'toNext' ? currentPosition > newPosition : currentPosition < newPosition; + if (_this._DOMAnimating) return; + + anim(); + } + //Update Active Slide Index _this.updateActiveSlide(newPosition); //Callbacks - if (params.onSlideNext && action=='next') { + if (params.onSlideNext && action === 'next') { _this.fireCallback(params.onSlideNext, _this, newPosition); } - if (params.onSlidePrev && action=='prev') { + if (params.onSlidePrev && action === 'prev') { _this.fireCallback(params.onSlidePrev, _this, newPosition); } - //"Reset" Callback - if (params.onSlideReset && action=='reset') { + //'Reset' Callback + if (params.onSlideReset && action === 'reset') { _this.fireCallback(params.onSlideReset, _this, newPosition); } - //"Next", "Prev" and "To" Callbacks - if (action=='next' || action=='prev' || (action=='to' && toOptions.runCallbacks==true)) + //'Next', 'Prev' and 'To' Callbacks + if (action === 'next' || action === 'prev' || (action === 'to' && toOptions.runCallbacks === true)) slideChangeCallbacks(action); } /*================================================== @@ -1879,12 +1907,12 @@ var Swiper = function (selector, params) { if (params.queueStartCallbacks && _this.support.transitions) { if (_this._queueStartCallbacks) return; _this._queueStartCallbacks = true; - _this.fireCallback(params.onSlideChangeStart, _this, direction) - _this.wrapperTransitionEnd(function(){ + _this.fireCallback(params.onSlideChangeStart, _this, direction); + _this.wrapperTransitionEnd(function () { _this._queueStartCallbacks = false; - }) + }); } - else _this.fireCallback(params.onSlideChangeStart, _this, direction) + else _this.fireCallback(params.onSlideChangeStart, _this, direction); } //Transition End Callback if (params.onSlideChangeEnd) { @@ -1892,82 +1920,88 @@ var Swiper = function (selector, params) { if (params.queueEndCallbacks) { if (_this._queueEndCallbacks) return; _this._queueEndCallbacks = true; - _this.wrapperTransitionEnd(function(swiper){_this.fireCallback(params.onSlideChangeEnd, swiper, direction)}) + _this.wrapperTransitionEnd(function (swiper) { + _this.fireCallback(params.onSlideChangeEnd, swiper, direction); + }); + } + else { + _this.wrapperTransitionEnd(function (swiper) { + _this.fireCallback(params.onSlideChangeEnd, swiper, direction); + }); } - else _this.wrapperTransitionEnd(function(swiper){_this.fireCallback(params.onSlideChangeEnd, swiper, direction)}) } else { if (!params.DOMAnimation) { - setTimeout(function(){ - _this.fireCallback(params.onSlideChangeEnd, _this, direction) - },10) + setTimeout(function () { + _this.fireCallback(params.onSlideChangeEnd, _this, direction); + }, 10); } } } } - + /*================================================== Update Active Slide Index ====================================================*/ - _this.updateActiveSlide = function(position) { + _this.updateActiveSlide = function (position) { if (!_this.initialized) return; - if (_this.slides.length==0) return; + if (_this.slides.length === 0) return; _this.previousIndex = _this.activeIndex; - if (typeof position=='undefined') position = _this.getWrapperTranslate(); - if (position>0) position=0; - - if (params.slidesPerView == 'auto') { + if (typeof position === 'undefined') position = _this.getWrapperTranslate(); + if (position > 0) position = 0; + + if (params.slidesPerView === 'auto') { var slidesOffset = 0; _this.activeIndex = _this.slidesGrid.indexOf(-position); - if (_this.activeIndex<0) { - for (var i=0; i<_this.slidesGrid.length-1; i++) { - if (-position>_this.slidesGrid[i] && -position<_this.slidesGrid[i+1]) { + if (_this.activeIndex < 0) { + for (var i = 0; i < _this.slidesGrid.length - 1; i++) { + if (-position > _this.slidesGrid[i] && -position < _this.slidesGrid[i + 1]) { break; } } - var leftDistance = Math.abs( _this.slidesGrid[i] + position ) - var rightDistance = Math.abs( _this.slidesGrid[i+1] + position ) - if (leftDistance<=rightDistance) _this.activeIndex = i; - else _this.activeIndex = i+1; + var leftDistance = Math.abs(_this.slidesGrid[i] + position); + var rightDistance = Math.abs(_this.slidesGrid[i + 1] + position); + if (leftDistance <= rightDistance) _this.activeIndex = i; + else _this.activeIndex = i + 1; } } else { - _this.activeIndex = Math[params.visibilityFullFit ? 'ceil' : 'round']( -position/slideSize ); + _this.activeIndex = Math[params.visibilityFullFit ? 'ceil' : 'round'](-position / slideSize); } - - if (_this.activeIndex == _this.slides.length ) _this.activeIndex = _this.slides.length - 1; + + if (_this.activeIndex === _this.slides.length) _this.activeIndex = _this.slides.length - 1; if (_this.activeIndex < 0) _this.activeIndex = 0; - + // Check for slide if (!_this.slides[_this.activeIndex]) return; - + // Calc Visible slides _this.calcVisibleSlides(position); // Mark visible and active slides with additonal classes - var activeClassRegexp = new RegExp( "\\s*" + params.slideActiveClass ); - var inViewClassRegexp = new RegExp( "\\s*" + params.slideVisibleClass ); + var activeClassRegexp = new RegExp('\\s*' + params.slideActiveClass); + var inViewClassRegexp = new RegExp('\\s*' + params.slideVisibleClass); - for (var i = 0; i < _this.slides.length; i++) { - _this.slides[ i ].className = _this.slides[ i ].className.replace( activeClassRegexp, '' ).replace( inViewClassRegexp, '' ); - if ( _this.visibleSlides.indexOf( _this.slides[ i ] )>=0 ) { - _this.slides[ i ].className += ' ' + params.slideVisibleClass; + for (var j = 0; j < _this.slides.length; j++) { + _this.slides[j].className = _this.slides[j].className.replace(activeClassRegexp, '').replace(inViewClassRegexp, ''); + if (_this.visibleSlides.indexOf(_this.slides[j]) >= 0) { + _this.slides[j].className += ' ' + params.slideVisibleClass; } } - _this.slides[ _this.activeIndex ].className += ' ' + params.slideActiveClass; + _this.slides[_this.activeIndex].className += ' ' + params.slideActiveClass; //Update loop index if (params.loop) { var ls = _this.loopedSlides; _this.activeLoopIndex = _this.activeIndex - ls; - if (_this.activeLoopIndex >= _this.slides.length - ls*2 ) { - _this.activeLoopIndex = _this.slides.length - ls*2 - _this.activeLoopIndex; + if (_this.activeLoopIndex >= _this.slides.length - ls * 2) { + _this.activeLoopIndex = _this.slides.length - ls * 2 - _this.activeLoopIndex; } - if (_this.activeLoopIndex<0) { - _this.activeLoopIndex = _this.slides.length - ls*2 + _this.activeLoopIndex; + if (_this.activeLoopIndex < 0) { + _this.activeLoopIndex = _this.slides.length - ls * 2 + _this.activeLoopIndex; } - if (_this.activeLoopIndex<0) _this.activeLoopIndex = 0; + if (_this.activeLoopIndex < 0) _this.activeLoopIndex = 0; } else { _this.activeLoopIndex = _this.activeIndex; @@ -1976,7 +2010,7 @@ var Swiper = function (selector, params) { if (params.pagination) { _this.updatePagination(position); } - } + }; /*================================================== Pagination ====================================================*/ @@ -1986,147 +2020,149 @@ var Swiper = function (selector, params) { } _this.paginationContainer = params.pagination.nodeType ? params.pagination : $$(params.pagination)[0]; if (params.createPagination) { - var paginationHTML = ""; + var paginationHTML = ''; var numOfSlides = _this.slides.length; var numOfButtons = numOfSlides; - if (params.loop) numOfButtons -= _this.loopedSlides*2 + if (params.loop) numOfButtons -= _this.loopedSlides * 2; for (var i = 0; i < numOfButtons; i++) { - paginationHTML += '<'+params.paginationElement+' class="'+params.paginationElementClass+'">' + paginationHTML += '<' + params.paginationElement + ' class="' + params.paginationElementClass + '">'; } - _this.paginationContainer.innerHTML = paginationHTML; + _this.paginationContainer.innerHTML = paginationHTML; } - _this.paginationButtons = $$('.'+params.paginationElementClass, _this.paginationContainer); - if (!firstInit) _this.updatePagination() + _this.paginationButtons = $$('.' + params.paginationElementClass, _this.paginationContainer); + if (!firstInit) _this.updatePagination(); _this.callPlugins('onCreatePagination'); if (params.paginationClickable) { addPaginationEvents(); } - } + }; function removePaginationEvents() { var pagers = _this.paginationButtons; - for (var i=0; i=_this.slides.length-_this.loopedSlides*2) { - visIndex = _this.slides.length - _this.loopedSlides*2 - visIndex; - visIndex = Math.abs(visIndex) + if (params.loop && visIndex >= _this.slides.length - _this.loopedSlides * 2) { + visIndex = _this.slides.length - _this.loopedSlides * 2 - visIndex; + visIndex = Math.abs(visIndex); } - visibleIndexes.push( visIndex ) + visibleIndexes.push(visIndex); } - - for (i=0; i0) position = position+_this.wrapperLeft; - if (!isH && _this.wrapperTop>0) position = position+_this.wrapperTop; + if (isH && _this.wrapperLeft > 0) position = position + _this.wrapperLeft; + if (!isH && _this.wrapperTop > 0) position = position + _this.wrapperTop; - for (var i=0; i<_this.slides.length; i++) { + for (var i = 0; i < _this.slides.length; i++) { _slideLeft += _slideSize; - if (params.slidesPerView == 'auto') - _slideSize = isH ? _this.h.getWidth(_this.slides[i],true) : _this.h.getHeight(_this.slides[i],true); + if (params.slidesPerView === 'auto') + _slideSize = isH ? _this.h.getWidth(_this.slides[i], true) : _this.h.getHeight(_this.slides[i], true); else _slideSize = slideSize; _slideRight = _slideLeft + _slideSize; var isVisibile = false; if (params.visibilityFullFit) { - if (_slideLeft >= -position && _slideRight <= -position+containerSize) isVisibile = true; - if (_slideLeft <= -position && _slideRight >= -position+containerSize) isVisibile = true; + if (_slideLeft >= -position && _slideRight <= -position + containerSize) isVisibile = true; + if (_slideLeft <= -position && _slideRight >= -position + containerSize) isVisibile = true; } else { - - if (_slideRight > -position && _slideRight <= ((-position+containerSize))) isVisibile = true; - if (_slideLeft >= -position && _slideLeft < ((-position+containerSize))) isVisibile = true; - if (_slideLeft < -position && _slideRight > ((-position+containerSize))) isVisibile = true; + if (_slideRight > -position && _slideRight <= ((-position + containerSize))) isVisibile = true; + if (_slideLeft >= -position && _slideLeft < ((-position + containerSize))) isVisibile = true; + if (_slideLeft < -position && _slideRight > ((-position + containerSize))) isVisibile = true; } - if (isVisibile) visibleSlides.push(_this.slides[i]) + if (isVisibile) visibleSlides.push(_this.slides[i]); } - if (visibleSlides.length==0) visibleSlides = [ _this.slides[ _this.activeIndex ] ] + if (visibleSlides.length === 0) visibleSlides = [_this.slides[_this.activeIndex]]; _this.visibleSlides = visibleSlides; - } + }; /*========================================== Autoplay ============================================*/ - var autoplayTimeoutId = undefined; - var autoplayIntervalId = undefined; + var autoplayTimeoutId, autoplayIntervalId; _this.startAutoplay = function () { if (_this.support.transitions) { if (typeof autoplayTimeoutId !== 'undefined') return false; if (!params.autoplay) return; _this.callPlugins('onAutoplayStart'); - autoplay(); + autoplay(); } else { if (typeof autoplayIntervalId !== 'undefined') return false; if (!params.autoplay) return; _this.callPlugins('onAutoplayStart'); - autoplayIntervalId = setInterval(function(){ + autoplayIntervalId = setInterval(function () { if (params.loop) { _this.fixLoop(); _this.swipeNext(true); @@ -2138,18 +2174,18 @@ var Swiper = function (selector, params) { autoplayIntervalId = undefined; } } - }, params.autoplay) + }, params.autoplay); } - } + }; _this.stopAutoplay = function (internal) { if (_this.support.transitions) { if (!autoplayTimeoutId) return; if (autoplayTimeoutId) clearTimeout(autoplayTimeoutId); autoplayTimeoutId = undefined; if (internal && !params.autoplayDisableOnInteraction) { - _this.wrapperTransitionEnd(function(){ + _this.wrapperTransitionEnd(function () { autoplay(); - }) + }); } _this.callPlugins('onAutoplayStop'); } @@ -2158,10 +2194,10 @@ var Swiper = function (selector, params) { autoplayIntervalId = undefined; _this.callPlugins('onAutoplayStop'); } - } - function autoplay(){ - autoplayTimeoutId = setTimeout(function(){ - if(params.loop) { + }; + function autoplay() { + autoplayTimeoutId = setTimeout(function () { + if (params.loop) { _this.fixLoop(); _this.swipeNext(true); } @@ -2172,36 +2208,36 @@ var Swiper = function (selector, params) { autoplayTimeoutId = undefined; } } - _this.wrapperTransitionEnd(function(){ + _this.wrapperTransitionEnd(function () { if (typeof autoplayTimeoutId !== 'undefined') autoplay(); - }) - },params.autoplay) + }); + }, params.autoplay); } /*================================================== Loop ====================================================*/ _this.loopCreated = false; - _this.removeLoopedSlides = function(){ + _this.removeLoopedSlides = function () { if (_this.loopCreated) { - for (var i=0; i<_this.slides.length; i++) { - if (_this.slides[i].getData('looped')===true) _this.wrapper.removeChild(_this.slides[i]); + for (var i = 0; i < _this.slides.length; i++) { + if (_this.slides[i].getData('looped') === true) _this.wrapper.removeChild(_this.slides[i]); } } - } - - _this.createLoop = function() { - if (_this.slides.length==0) return; - if (params.slidesPerView=='auto') { - _this.loopedSlides = params.loopedSlides||1; + }; + + _this.createLoop = function () { + if (_this.slides.length === 0) return; + if (params.slidesPerView === 'auto') { + _this.loopedSlides = params.loopedSlides || 1; } else { - _this.loopedSlides = params.slidesPerView + params.loopAdditionalSlides; + _this.loopedSlides = params.slidesPerView + params.loopAdditionalSlides; } - + if (_this.loopedSlides > _this.slides.length) { _this.loopedSlides = _this.slides.length; } - + var slideFirstHTML = '', slideLastHTML = '', i; @@ -2209,29 +2245,29 @@ var Swiper = function (selector, params) { /** loopedSlides is too large if loopAdditionalSlides are set. Need to divide the slides by maximum number of slides existing. - + @author Tomaz Lovrec */ var numSlides = _this.slides.length; var fullSlideSets = Math.floor(_this.loopedSlides / numSlides); var remainderSlides = _this.loopedSlides % numSlides; // assemble full sets of slides - for (i = 0; i<(fullSlideSets*numSlides);i++) { - var j = i; - if (i >= numSlides) { - var over = Math.floor(i / numSlides); - j = i - (numSlides * over); - } - slidesSetFullHTML+=_this.slides[j].outerHTML; + for (i = 0; i < (fullSlideSets * numSlides); i++) { + var j = i; + if (i >= numSlides) { + var over = Math.floor(i / numSlides); + j = i - (numSlides * over); + } + slidesSetFullHTML += _this.slides[j].outerHTML; } // assemble remainder slides // assemble remainder appended to existing slides - for(i = 0;i=_this.slides.length-_this.loopedSlides) _this.slides[i].setData('looped', true); + for (i = 0; i < _this.slides.length; i++) { + if (i < _this.loopedSlides || i >= _this.slides.length - _this.loopedSlides) _this.slides[i].setData('looped', true); } _this.callPlugins('onCreateLoop'); - } - - _this.fixLoop = function() { + }; + + _this.fixLoop = function () { var newIndex; //Fix For Negative Oversliding if (_this.activeIndex < _this.loopedSlides) { - newIndex = _this.slides.length - _this.loopedSlides*3 + _this.activeIndex; + newIndex = _this.slides.length - _this.loopedSlides * 3 + _this.activeIndex; _this.swipeTo(newIndex, 0, false); } //Fix For Positive Oversliding - else if ((params.slidesPerView == "auto" && _this.activeIndex >= _this.loopedSlides*2) || (_this.activeIndex > _this.slides.length - params.slidesPerView*2)) { + else if ((params.slidesPerView === 'auto' && _this.activeIndex >= _this.loopedSlides * 2) || (_this.activeIndex > _this.slides.length - params.slidesPerView * 2)) { newIndex = -_this.slides.length + _this.activeIndex + _this.loopedSlides; _this.swipeTo(newIndex, 0, false); } - } - + }; + /*================================================== Slides Loader ====================================================*/ - _this.loadSlides = function(){ + _this.loadSlides = function () { var slidesHTML = ''; _this.activeLoaderIndex = 0; var slides = params.loader.slides; - var slidesToLoad = params.loader.loadAllSlides ? slides.length : params.slidesPerView*(1+params.loader.surroundGroups); - for (var i=0; i< slidesToLoad; i++) { - if (params.loader.slidesHTMLType=='outer') slidesHTML+=slides[i]; + var slidesToLoad = params.loader.loadAllSlides ? slides.length : params.slidesPerView * (1 + params.loader.surroundGroups); + for (var i = 0; i < slidesToLoad; i++) { + if (params.loader.slidesHTMLType === 'outer') slidesHTML += slides[i]; else { - slidesHTML+='<'+params.slideElement+' class="'+params.slideClass+'" data-swiperindex="'+i+'">'+slides[i]+''; + slidesHTML += '<' + params.slideElement + ' class="' + params.slideClass + '" data-swiperindex="' + i + '">' + slides[i] + ''; } } _this.wrapper.innerHTML = slidesHTML; @@ -2283,55 +2319,58 @@ var Swiper = function (selector, params) { if (!params.loader.loadAllSlides) { _this.wrapperTransitionEnd(_this.reloadSlides, true); } - } - - _this.reloadSlides = function(){ + }; + + _this.reloadSlides = function () { var slides = params.loader.slides; - var newActiveIndex = parseInt(_this.activeSlide().data('swiperindex'),10) - if (newActiveIndex<0 || newActiveIndex>slides.length-1) return //<-- Exit + var newActiveIndex = parseInt(_this.activeSlide().data('swiperindex'), 10); + if (newActiveIndex < 0 || newActiveIndex > slides.length - 1) return; //<-- Exit _this.activeLoaderIndex = newActiveIndex; - var firstIndex = Math.max(0, newActiveIndex - params.slidesPerView*params.loader.surroundGroups) - var lastIndex = Math.min(newActiveIndex+params.slidesPerView*(1+params.loader.surroundGroups)-1, slides.length-1) + var firstIndex = Math.max(0, newActiveIndex - params.slidesPerView * params.loader.surroundGroups); + var lastIndex = Math.min(newActiveIndex + params.slidesPerView * (1 + params.loader.surroundGroups) - 1, slides.length - 1); //Update Transforms - if (newActiveIndex>0) { - var newTransform = -slideSize*(newActiveIndex-firstIndex) + if (newActiveIndex > 0) { + var newTransform = -slideSize * (newActiveIndex - firstIndex); _this.setWrapperTranslate(newTransform); _this.setWrapperTransition(0); } + var i; // loop index //New Slides - if (params.loader.logic==='reload') { + if (params.loader.logic === 'reload') { _this.wrapper.innerHTML = ''; var slidesHTML = ''; - for (var i = firstIndex; i<=lastIndex; i++) { - slidesHTML += params.loader.slidesHTMLType == 'outer' ? slides[i] : '<'+params.slideElement+' class="'+params.slideClass+'" data-swiperindex="'+i+'">'+slides[i]+''; + for (i = firstIndex; i <= lastIndex; i++) { + slidesHTML += params.loader.slidesHTMLType === 'outer' ? slides[i] : '<' + params.slideElement + ' class="' + params.slideClass + '" data-swiperindex="' + i + '">' + slides[i] + ''; } _this.wrapper.innerHTML = slidesHTML; } else { - var minExistIndex=1000; - var maxExistIndex=0; - for (var i=0; i<_this.slides.length; i++) { + var minExistIndex = 1000; + var maxExistIndex = 0; + + for (i = 0; i < _this.slides.length; i++) { var index = _this.slides[i].data('swiperindex'); - if (indexlastIndex) { + if (index < firstIndex || index > lastIndex) { _this.wrapper.removeChild(_this.slides[i]); } else { - minExistIndex = Math.min(index, minExistIndex) - maxExistIndex = Math.max(index, maxExistIndex) + minExistIndex = Math.min(index, minExistIndex); + maxExistIndex = Math.max(index, maxExistIndex); } } - for (var i=firstIndex; i<=lastIndex; i++) { - if (imaxExistIndex) { - var newSlide = document.createElement(params.slideElement); + if (i > maxExistIndex) { + newSlide = document.createElement(params.slideElement); newSlide.className = params.slideClass; - newSlide.setAttribute('data-swiperindex',i); + newSlide.setAttribute('data-swiperindex', i); newSlide.innerHTML = slides[i]; _this.wrapper.appendChild(newSlide); } @@ -2339,14 +2378,14 @@ var Swiper = function (selector, params) { } //reInit _this.reInit(true); - } - + }; + /*================================================== Make Swiper ====================================================*/ - function makeSwiper(){ + function makeSwiper() { _this.calcSlides(); - if (params.loader.slides.length>0 && _this.slides.length==0) { + if (params.loader.slides.length > 0 && _this.slides.length === 0) { _this.loadSlides(); } if (params.loop) { @@ -2358,8 +2397,8 @@ var Swiper = function (selector, params) { _this.createPagination(true); } - if (params.loop || params.initialSlide>0) { - _this.swipeTo( params.initialSlide, 0, false ); + if (params.loop || params.initialSlide > 0) { + _this.swipeTo(params.initialSlide, 0, false); } else { _this.updateActiveSlide(0); @@ -2369,8 +2408,8 @@ var Swiper = function (selector, params) { } /** * Set center slide index. - * - * @author Tomaz Lovrec + * + * @author Tomaz Lovrec */ _this.centerIndex = _this.activeIndex; @@ -2378,104 +2417,107 @@ var Swiper = function (selector, params) { if (params.onSwiperCreated) _this.fireCallback(params.onSwiperCreated, _this); _this.callPlugins('onSwiperCreated'); } - + makeSwiper(); -} +}; Swiper.prototype = { plugins : {}, - + /*================================================== Wrapper Operations ====================================================*/ - wrapperTransitionEnd : function(callback, permanent) { + wrapperTransitionEnd : function (callback, permanent) { + 'use strict'; var a = this, el = a.wrapper, events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'], i; - + function fireCallBack() { callback(a); if (a.params.queueEndCallbacks) a._queueEndCallbacks = false; if (!permanent) { - for (i=0; i0) { + if (isNaN(returnWidth) || width.indexOf('%') > 0) { returnWidth = el.offsetWidth - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right')); } - if (outer) returnWidth += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right')) + if (outer) returnWidth += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right')); return returnWidth; }, - getHeight: function(el, outer) { + getHeight: function (el, outer) { + 'use strict'; if (outer) return el.offsetHeight; - var height = window.getComputedStyle(el, null).getPropertyValue('height') + var height = window.getComputedStyle(el, null).getPropertyValue('height'); var returnHeight = parseFloat(height); //IE Fixes - if(isNaN(returnHeight) || height.indexOf('%')>0) { + if (isNaN(returnHeight) || height.indexOf('%') > 0) { returnHeight = el.offsetHeight - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom')); } - if (outer) returnHeight += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom')) + if (outer) returnHeight += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom')); return returnHeight; }, - getOffset: function(el) { + getOffset: function (el) { + 'use strict'; var box = el.getBoundingClientRect(); var body = document.body; var clientTop = el.clientTop || body.clientTop || 0; @@ -2544,35 +2590,38 @@ Swiper.prototype = { left: box.left + scrollLeft - clientLeft }; }, - windowWidth : function() { - if (window.innerWidth) return window.innerWidth + windowWidth : function () { + 'use strict'; + if (window.innerWidth) return window.innerWidth; else if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth; }, - windowHeight : function() { - if (window.innerHeight) return window.innerHeight + windowHeight : function () { + 'use strict'; + if (window.innerHeight) return window.innerHeight; else if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight; }, - windowScroll : function() { - var left=0, top=0; - if (typeof pageYOffset != 'undefined') { + windowScroll : function () { + 'use strict'; + if (typeof pageYOffset !== 'undefined') { return { left: window.pageXOffset, top: window.pageYOffset - } + }; } else if (document.documentElement) { return { left: document.documentElement.scrollLeft, top: document.documentElement.scrollTop - } + }; } }, addEventListener : function (el, event, listener, useCapture) { - if (typeof useCapture == 'undefined') { + 'use strict'; + if (typeof useCapture === 'undefined') { useCapture = false; } - + if (el.addEventListener) { el.addEventListener(event, listener, useCapture); } @@ -2580,12 +2629,13 @@ Swiper.prototype = { el.attachEvent('on' + event, listener); } }, - + removeEventListener : function (el, event, listener, useCapture) { - if (typeof useCapture == 'undefined') { + 'use strict'; + if (typeof useCapture === 'undefined') { useCapture = false; } - + if (el.removeEventListener) { el.removeEventListener(event, listener, useCapture); } @@ -2595,47 +2645,54 @@ Swiper.prototype = { } }, setTransform : function (el, transform) { - var es = el.style - es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = transform + 'use strict'; + var es = el.style; + es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = transform; }, setTranslate : function (el, translate) { - var es = el.style + 'use strict'; + var es = el.style; var pos = { x : translate.x || 0, y : translate.y || 0, z : translate.z || 0 }; - var transformString = this.support.transforms3d ? 'translate3d('+(pos.x)+'px,'+(pos.y)+'px,'+(pos.z)+'px)' : 'translate('+(pos.x)+'px,'+(pos.y)+'px)'; + var transformString = this.support.transforms3d ? 'translate3d(' + (pos.x) + 'px,' + (pos.y) + 'px,' + (pos.z) + 'px)' : 'translate(' + (pos.x) + 'px,' + (pos.y) + 'px)'; es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = transformString; if (!this.support.transforms) { - es.left = pos.x+'px' - es.top = pos.y+'px' + es.left = pos.x + 'px'; + es.top = pos.y + 'px'; } }, setTransition : function (el, duration) { - var es = el.style - es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = duration+'ms'; + 'use strict'; + var es = el.style; + es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = duration + 'ms'; }, /*================================================== Feature Detection ====================================================*/ support: { - touch : (window.Modernizr && Modernizr.touch===true) || (function() { - return !!(("ontouchstart" in window) || window.DocumentTouch && document instanceof DocumentTouch); + touch : (window.Modernizr && Modernizr.touch === true) || (function () { + 'use strict'; + return !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch); })(), - transforms3d : (window.Modernizr && Modernizr.csstransforms3d===true) || (function() { + transforms3d : (window.Modernizr && Modernizr.csstransforms3d === true) || (function () { + 'use strict'; var div = document.createElement('div').style; - return ("webkitPerspective" in div || "MozPerspective" in div || "OPerspective" in div || "MsPerspective" in div || "perspective" in div); + return ('webkitPerspective' in div || 'MozPerspective' in div || 'OPerspective' in div || 'MsPerspective' in div || 'perspective' in div); })(), - transforms : (window.Modernizr && Modernizr.csstransforms===true) || (function(){ + transforms : (window.Modernizr && Modernizr.csstransforms === true) || (function () { + 'use strict'; var div = document.createElement('div').style; return ('transform' in div || 'WebkitTransform' in div || 'MozTransform' in div || 'msTransform' in div || 'MsTransform' in div || 'OTransform' in div); })(), - transitions : (window.Modernizr && Modernizr.csstransitions===true) || (function(){ + transitions : (window.Modernizr && Modernizr.csstransitions === true) || (function () { + 'use strict'; var div = document.createElement('div').style; return ('transition' in div || 'WebkitTransition' in div || 'MozTransition' in div || 'msTransition' in div || 'MsTransition' in div || 'OTransition' in div); })() @@ -2643,37 +2700,47 @@ Swiper.prototype = { browser : { - ie8 : (function(){ + ie8 : (function () { + 'use strict'; var rv = -1; // Return value assumes failure. - if (navigator.appName == 'Microsoft Internet Explorer') { + if (navigator.appName === 'Microsoft Internet Explorer') { var ua = navigator.userAgent; - var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); - if (re.exec(ua) != null) + var re = new RegExp(/MSIE ([0-9]{1,}[\.0-9]{0,})/); + if (re.exec(ua) !== null) rv = parseFloat(RegExp.$1); } - return rv != -1 && rv < 9; + return rv !== -1 && rv < 9; })(), ie10 : window.navigator.msPointerEnabled, ie11 : window.navigator.pointerEnabled } -} +}; /*========================= jQuery & Zepto Plugins ===========================*/ -if (window.jQuery||window.Zepto) { - (function($){ - $.fn.swiper = function(params) { - var s = new Swiper($(this)[0], params) - $(this).data('swiper',s); +if (window.jQuery || window.Zepto) { + (function ($) { + 'use strict'; + $.fn.swiper = function (params) { + var s = new Swiper($(this)[0], params); + $(this).data('swiper', s); return s; - } - })(window.jQuery||window.Zepto) + }; + })(window.jQuery || window.Zepto); } // component -if ( typeof( module ) !== 'undefined' ) +if (typeof(module) !== 'undefined') { module.exports = Swiper; } + +// requirejs support +if (typeof define === 'function' && define.amd) { + define([], function () { + 'use strict'; + return Swiper; + }); +} diff --git a/dist/idangerous.swiper.min.js b/dist/idangerous.swiper.min.js index 5b941c9ef..22509b9e1 100644 --- a/dist/idangerous.swiper.min.js +++ b/dist/idangerous.swiper.min.js @@ -1,5 +1,5 @@ /* - * swiper 2.4.3 + * swiper 2.5.0 * Mobile touch slider and framework with hardware accelerated transitions * * http://www.idangero.us/sliders/swiper/ @@ -10,7 +10,7 @@ * * Licensed under GPL & MIT * - * Released on: January 29, 2014 + * Released on: March 6, 2014 */ -var Swiper=function(a,b){function c(a,b){return document.querySelectorAll?(b||document).querySelectorAll(a):jQuery(a,b)}function d(a){"use strict";return"[object Array]"===Object.prototype.toString.apply(a)?!0:!1}function e(){var a=F-I;return b.freeMode&&(a=F-I),b.slidesPerView>C.slides.length&&(a=0),0>a&&(a=0),a}function f(){function a(a){var c=new Image;c.onload=function(){C.imagesLoaded++,C.imagesLoaded==C.imagesToLoad.length&&(C.reInit(),b.onImagesReady&&C.fireCallback(b.onImagesReady,C))},c.src=a}var d=C.h.addEventListener,e="wrapper"==b.eventTarget?C.wrapper:C.container;if(C.browser.ie10||C.browser.ie11?(d(e,C.touchEvents.touchStart,p),d(document,C.touchEvents.touchMove,q),d(document,C.touchEvents.touchEnd,r)):(C.support.touch&&(d(e,"touchstart",p),d(e,"touchmove",q),d(e,"touchend",r)),b.simulateTouch&&(d(e,"mousedown",p),d(document,"mousemove",q),d(document,"mouseup",r))),b.autoResize&&d(window,"resize",C.resizeFix),g(),C._wheelEvent=!1,b.mousewheelControl){void 0!==document.onmousewheel&&(C._wheelEvent="mousewheel");try{WheelEvent("wheel"),C._wheelEvent="wheel"}catch(f){}C._wheelEvent||(C._wheelEvent="DOMMouseScroll"),C._wheelEvent&&d(C.container,C._wheelEvent,j)}if(b.keyboardControl&&d(document,"keydown",i),b.updateOnImagesReady){C.imagesToLoad=c("img",C.container);for(var h=0;h=e&&k[0]<=e+g&&k[1]>=f&&k[1]<=f+h&&(c=!0)}if(!c)return}M?((37==b||39==b)&&(a.preventDefault?a.preventDefault():a.returnValue=!1),39==b&&C.swipeNext(),37==b&&C.swipePrev()):((38==b||40==b)&&(a.preventDefault?a.preventDefault():a.returnValue=!1),40==b&&C.swipeNext(),38==b&&C.swipePrev())}function j(a){var c=C._wheelEvent,d=0;if(a.detail)d=-a.detail;else if("mousewheel"==c)if(b.mousewheelControlForceToAxis)if(M){if(!(Math.abs(a.wheelDeltaX)>Math.abs(a.wheelDeltaY)))return;d=a.wheelDeltaX}else{if(!(Math.abs(a.wheelDeltaY)>Math.abs(a.wheelDeltaX)))return;d=a.wheelDeltaY}else d=a.wheelDelta;else if("DOMMouseScroll"==c)d=-a.detail;else if("wheel"==c)if(b.mousewheelControlForceToAxis)if(M){if(!(Math.abs(a.deltaX)>Math.abs(a.deltaY)))return;d=-a.deltaX}else{if(!(Math.abs(a.deltaY)>Math.abs(a.deltaX)))return;d=-a.deltaY}else d=Math.abs(a.deltaX)>Math.abs(a.deltaY)?-a.deltaX:-a.deltaY;if(b.freeMode){var f=C.getWrapperTranslate()+d;if(f>0&&(f=0),f<-e()&&(f=-e()),C.setWrapperTransition(0),C.setWrapperTranslate(f),C.updateActiveSlide(f),0==f||f==-e())return}else(new Date).getTime()-U>60&&(0>d?C.swipeNext():C.swipePrev()),U=(new Date).getTime();return b.autoplay&&C.stopAutoplay(!0),a.preventDefault?a.preventDefault():a.returnValue=!1,!1}function k(a){C.allowSlideClick&&(m(a),C.fireCallback(b.onSlideClick,C,a))}function l(a){m(a),C.fireCallback(b.onSlideTouch,C,a)}function m(a){if(a.currentTarget)C.clickedSlide=a.currentTarget;else{var c=a.srcElement;do if(c.className.indexOf(b.slideClass)>-1)break;while(c=c.parentNode);C.clickedSlide=c}C.clickedSlideIndex=C.slides.indexOf(C.clickedSlide),C.clickedSlideLoopIndex=C.clickedSlideIndex-(C.loopedSlides||0)}function n(a){return C.allowLinks?void 0:(a.preventDefault?a.preventDefault():a.returnValue=!1,b.preventLinksPropagation&&"stopPropagation"in a&&a.stopPropagation(),!1)}function o(a){return a.stopPropagation?a.stopPropagation():a.returnValue=!1,!1}function p(a){if(b.preventLinks&&(C.allowLinks=!0),C.isTouched||b.onlyExternal)return!1;if(b.noSwiping&&(a.target||a.srcElement)&&s(a.target||a.srcElement))return!1;if($=!1,thresholdFirstMove=!1,C.isTouched=!0,Z="touchstart"==a.type,!Z||1==a.targetTouches.length){C.callPlugins("onTouchStartBegin"),Z||C.isAndroid||(a.preventDefault?a.preventDefault():a.returnValue=!1);var c=Z?a.targetTouches[0].pageX:a.pageX||a.clientX,d=Z?a.targetTouches[0].pageY:a.pageY||a.clientY;C.touches.startX=C.touches.currentX=c,C.touches.startY=C.touches.currentY=d,C.touches.start=C.touches.current=M?c:d,C.setWrapperTransition(0),C.positions.start=C.positions.current=C.getWrapperTranslate(),C.setWrapperTranslate(C.positions.start),C.times.start=(new Date).getTime(),H=void 0,b.moveStartThreshold>0&&(W=!1),b.onTouchStart&&C.fireCallback(b.onTouchStart,C),C.callPlugins("onTouchStartEnd")}}function q(a){if(C.isTouched&&!b.onlyExternal&&(!Z||"mousemove"!=a.type)){var c=Z?a.targetTouches[0].pageX:a.pageX||a.clientX,d=Z?a.targetTouches[0].pageY:a.pageY||a.clientY;if("undefined"==typeof H&&M&&(H=!!(H||Math.abs(d-C.touches.startY)>Math.abs(c-C.touches.startX))),"undefined"!=typeof H||M||(H=!!(H||Math.abs(d-C.touches.startY)0&&b.onResistanceBefore&&C.fireCallback(b.onResistanceBefore,C,C.positions.current),C.positions.current<-e()&&b.onResistanceAfter&&C.fireCallback(b.onResistanceAfter,C,Math.abs(C.positions.current+e())),b.resistance&&"100%"!=b.resistance){if(C.positions.current>0){var f=1-C.positions.current/I/2;C.positions.current=.5>f?I/2:C.positions.current*f}if(C.positions.current<-e()){var g=(C.touches.current-C.touches.start)*b.touchRatio+(e()+C.positions.start),f=(I+g)/I,h=C.positions.current-g*(1-f)/2,i=-e()-I/2;C.positions.current=i>h||0>=f?i:h}}if(b.resistance&&"100%"==b.resistance&&(C.positions.current>0&&(!b.freeMode||b.freeModeFluid)&&(C.positions.current=0),C.positions.current<-e()&&(!b.freeMode||b.freeModeFluid)&&(C.positions.current=-e())),!b.followFinger)return;if(b.moveStartThreshold)if(Math.abs(C.touches.current-C.touches.start)>b.moveStartThreshold||W){if(!W)return W=!0,void(C.touches.start=C.touches.current);C.setWrapperTranslate(C.positions.current)}else C.positions.current=C.positions.start;else C.setWrapperTranslate(C.positions.current);return(b.freeMode||b.watchActiveIndex)&&C.updateActiveSlide(C.positions.current),b.grabCursor&&(C.container.style.cursor="move",C.container.style.cursor="grabbing",C.container.style.cursor="-moz-grabbin",C.container.style.cursor="-webkit-grabbing"),X||(X=C.touches.current),Y||(Y=(new Date).getTime()),C.velocity=(C.touches.current-X)/((new Date).getTime()-Y)/2,Math.abs(C.touches.current-X)<2&&(C.velocity=0),X=C.touches.current,Y=(new Date).getTime(),C.callPlugins("onTouchMoveEnd"),b.onTouchMove&&C.fireCallback(b.onTouchMove,C),!1}}}function r(){if(H&&C.swipeReset(),!b.onlyExternal&&C.isTouched){C.isTouched=!1,b.grabCursor&&(C.container.style.cursor="move",C.container.style.cursor="grab",C.container.style.cursor="-moz-grab",C.container.style.cursor="-webkit-grab"),C.positions.current||0===C.positions.current||(C.positions.current=C.positions.start),b.followFinger&&C.setWrapperTranslate(C.positions.current),C.times.end=(new Date).getTime(),C.touches.diff=C.touches.current-C.touches.start,C.touches.abs=Math.abs(C.touches.diff),C.positions.diff=C.positions.current-C.positions.start,C.positions.abs=Math.abs(C.positions.diff);var a=C.positions.diff,c=C.positions.abs,d=C.times.end-C.times.start;5>c&&300>d&&0==C.allowLinks&&(b.freeMode||0==c||C.swipeReset(),b.preventLinks&&(C.allowLinks=!0),b.onSlideClick&&(C.allowSlideClick=!0)),setTimeout(function(){b.preventLinks&&(C.allowLinks=!0),b.onSlideClick&&(C.allowSlideClick=!0)},100);var f=e();if(!C.isMoved&&b.freeMode)return C.isMoved=!1,b.onTouchEnd&&C.fireCallback(b.onTouchEnd,C),void C.callPlugins("onTouchEnd");if(!C.isMoved||C.positions.current>0||C.positions.current<-f)return C.swipeReset(),b.onTouchEnd&&C.fireCallback(b.onTouchEnd,C),void C.callPlugins("onTouchEnd");if(C.isMoved=!1,b.freeMode){if(b.freeModeFluid){var g,h=1e3*b.momentumRatio,i=C.velocity*h,j=C.positions.current+i,k=!1,l=20*Math.abs(C.velocity)*b.momentumBounceRatio;-f>j&&(b.momentumBounce&&C.support.transitions?(-l>j+f&&(j=-f-l),g=-f,k=!0,$=!0):j=-f),j>0&&(b.momentumBounce&&C.support.transitions?(j>l&&(j=l),g=0,k=!0,$=!0):j=0),0!=C.velocity&&(h=Math.abs((j-C.positions.current)/C.velocity)),C.setWrapperTranslate(j),C.setWrapperTransition(h),b.momentumBounce&&k&&C.wrapperTransitionEnd(function(){$&&(b.onMomentumBounce&&C.fireCallback(b.onMomentumBounce,C),C.callPlugins("onMomentumBounce"),C.setWrapperTranslate(g),C.setWrapperTransition(300))}),C.updateActiveSlide(j)}return(!b.freeModeFluid||d>=300)&&C.updateActiveSlide(C.positions.current),b.onTouchEnd&&C.fireCallback(b.onTouchEnd,C),void C.callPlugins("onTouchEnd")}G=0>a?"toNext":"toPrev","toNext"==G&&300>=d&&(30>c||!b.shortSwipes?C.swipeReset():C.swipeNext(!0)),"toPrev"==G&&300>=d&&(30>c||!b.shortSwipes?C.swipeReset():C.swipePrev(!0));var m=0;if("auto"==b.slidesPerView){for(var n,o=Math.abs(C.getWrapperTranslate()),p=0,q=0;qo){m=n;break}m>I&&(m=I)}else m=E*b.slidesPerView;"toNext"==G&&d>300&&(c>=m*b.longSwipesRatio?C.swipeNext(!0):C.swipeReset()),"toPrev"==G&&d>300&&(c>=m*b.longSwipesRatio?C.swipePrev(!0):C.swipeReset()),b.onTouchEnd&&C.fireCallback(b.onTouchEnd,C),C.callPlugins("onTouchEnd")}}function s(a){var c=!1;do a.className.indexOf(b.noSwipingClass)>-1&&(c=!0),a=a.parentElement;while(!c&&a.parentElement&&-1==a.className.indexOf(b.wrapperClass));return!c&&a.className.indexOf(b.wrapperClass)>-1&&a.className.indexOf(b.noSwipingClass)>-1&&(c=!0),c}function t(a,b){var c,d=document.createElement("div");return d.innerHTML=b,c=d.firstChild,c.className+=" "+a,c.outerHTML}function u(a,c,d){function e(){var c=+new Date,d=c-g;h+=i*d/(1e3/60),k="toNext"==j?h>a:a>h,k?(C.setWrapperTranslate(Math.round(h)),C._DOMAnimating=!0,window.setTimeout(function(){e()},1e3/60)):(b.onSlideChangeEnd&&C.fireCallback(b.onSlideChangeEnd,C),C.setWrapperTranslate(a),C._DOMAnimating=!1)}var f="to"==c&&d.speed>=0?d.speed:b.speed,g=+new Date;if(C.support.transitions||!b.DOMAnimation)C.setWrapperTranslate(a),C.setWrapperTransition(f);else{var h=C.getWrapperTranslate(),i=Math.ceil((a-h)/f*(1e3/60)),j=h>a?"toNext":"toPrev",k="toNext"==j?h>a:a>h;if(C._DOMAnimating)return;e()}C.updateActiveSlide(a),b.onSlideNext&&"next"==c&&C.fireCallback(b.onSlideNext,C,a),b.onSlidePrev&&"prev"==c&&C.fireCallback(b.onSlidePrev,C,a),b.onSlideReset&&"reset"==c&&C.fireCallback(b.onSlideReset,C,a),("next"==c||"prev"==c||"to"==c&&1==d.runCallbacks)&&v(c)}function v(a){if(C.callPlugins("onSlideChangeStart"),b.onSlideChangeStart)if(b.queueStartCallbacks&&C.support.transitions){if(C._queueStartCallbacks)return;C._queueStartCallbacks=!0,C.fireCallback(b.onSlideChangeStart,C,a),C.wrapperTransitionEnd(function(){C._queueStartCallbacks=!1})}else C.fireCallback(b.onSlideChangeStart,C,a);if(b.onSlideChangeEnd)if(C.support.transitions)if(b.queueEndCallbacks){if(C._queueEndCallbacks)return;C._queueEndCallbacks=!0,C.wrapperTransitionEnd(function(c){C.fireCallback(b.onSlideChangeEnd,c,a)})}else C.wrapperTransitionEnd(function(c){C.fireCallback(b.onSlideChangeEnd,c,a)});else b.DOMAnimation||setTimeout(function(){C.fireCallback(b.onSlideChangeEnd,C,a)},10)}function w(){for(var a=C.paginationButtons,b=0;b0&&0==C.slides.length&&C.loadSlides(),b.loop&&C.createLoop(),C.init(),f(),b.pagination&&C.createPagination(!0),b.loop||b.initialSlide>0?C.swipeTo(b.initialSlide,0,!1):C.updateActiveSlide(0),b.autoplay&&C.startAutoplay(),C.centerIndex=C.activeIndex,b.onSwiperCreated&&C.fireCallback(b.onSwiperCreated,C),C.callPlugins("onSwiperCreated")}if(document.body.__defineGetter__&&HTMLElement){var B=HTMLElement.prototype;B.__defineGetter__&&B.__defineGetter__("outerHTML",function(){return(new XMLSerializer).serializeToString(this)})}if(window.getComputedStyle||(window.getComputedStyle=function(a){return this.el=a,this.getPropertyValue=function(b){var c=/(\-([a-z]){1})/g;return"float"===b&&(b="styleFloat"),c.test(b)&&(b=b.replace(c,function(){return arguments[2].toUpperCase()})),a.currentStyle[b]?a.currentStyle[b]:null},this}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){for(var c=b||0,d=this.length;d>c;c++)if(this[c]===a)return c;return-1}),(document.querySelectorAll||window.jQuery)&&"undefined"!=typeof a&&(a.nodeType||0!==c(a).length)){var C=this;C.touches={start:0,startX:0,startY:0,current:0,currentX:0,currentY:0,diff:0,abs:0},C.positions={start:0,abs:0,diff:0,current:0},C.times={start:0,end:0},C.id=(new Date).getTime(),C.container=a.nodeType?a:c(a)[0],C.isTouched=!1,C.isMoved=!1,C.activeIndex=0,C.centerIndex=0,C.activeLoaderIndex=0,C.activeLoopIndex=0,C.previousIndex=null,C.velocity=0,C.snapGrid=[],C.slidesGrid=[],C.imagesToLoad=[],C.imagesLoaded=0,C.wrapperLeft=0,C.wrapperRight=0,C.wrapperTop=0,C.wrapperBottom=0,C.isAndroid=navigator.userAgent.toLowerCase().indexOf("android")>=0;var D,E,F,G,H,I,J={eventTarget:"wrapper",mode:"horizontal",touchRatio:1,speed:300,freeMode:!1,freeModeFluid:!1,momentumRatio:1,momentumBounce:!0,momentumBounceRatio:1,slidesPerView:1,slidesPerGroup:1,simulateTouch:!0,followFinger:!0,shortSwipes:!0,longSwipesRatio:.5,moveStartThreshold:!1,onlyExternal:!1,createPagination:!0,pagination:!1,paginationElement:"span",paginationClickable:!1,paginationAsRange:!0,resistance:!0,scrollContainer:!1,preventLinks:!0,preventLinksPropagation:!1,noSwiping:!1,noSwipingClass:"swiper-no-swiping",initialSlide:0,keyboardControl:!1,mousewheelControl:!1,mousewheelControlForceToAxis:!1,useCSS3Transforms:!0,autoplay:!1,autoplayDisableOnInteraction:!0,autoplayStopOnLast:!1,loop:!1,loopAdditionalSlides:0,calculateHeight:!1,cssWidthAndHeight:!1,updateOnImagesReady:!0,releaseFormElements:!0,watchActiveIndex:!1,visibilityFullFit:!1,offsetPxBefore:0,offsetPxAfter:0,offsetSlidesBefore:0,offsetSlidesAfter:0,centeredSlides:!1,queueStartCallbacks:!1,queueEndCallbacks:!1,autoResize:!0,resizeReInit:!1,DOMAnimation:!0,loader:{slides:[],slidesHTMLType:"inner",surroundGroups:1,logic:"reload",loadAllSlides:!1},slideElement:"div",slideClass:"swiper-slide",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideDuplicateClass:"swiper-slide-duplicate",wrapperClass:"swiper-wrapper",paginationElementClass:"swiper-pagination-switch",paginationActiveClass:"swiper-active-switch",paginationVisibleClass:"swiper-visible-switch"};b=b||{};for(var K in J)if(K in b&&"object"==typeof b[K])for(var L in J[K])L in b[K]||(b[K][L]=J[K][L]);else K in b||(b[K]=J[K]);C.params=b,b.scrollContainer&&(b.freeMode=!0,b.freeModeFluid=!0),b.loop&&(b.resistance="100%");var M="horizontal"===b.mode,N=["mousedown","mousemove","mouseup"];C.browser.ie10&&(N=["MSPointerDown","MSPointerMove","MSPointerUp"]),C.browser.ie11&&(N=["pointerdown","pointermove","pointerup"]),C.touchEvents={touchStart:C.support.touch||!b.simulateTouch?"touchstart":N[0],touchMove:C.support.touch||!b.simulateTouch?"touchmove":N[1],touchEnd:C.support.touch||!b.simulateTouch?"touchend":N[2]};for(var O=C.container.childNodes.length-1;O>=0;O--)if(C.container.childNodes[O].className)for(var P=C.container.childNodes[O].className.split(" "),Q=0;Q=0;c--)a===C.slides[c]&&(b=c);return b},a.isActive=function(){return a.index()===C.activeIndex?!0:!1},a.swiperSlideDataStorage||(a.swiperSlideDataStorage={}),a.getData=function(b){return a.swiperSlideDataStorage[b]},a.setData=function(b,c){return a.swiperSlideDataStorage[b]=c,a},a.data=function(b,c){return c?(a.setAttribute("data-"+b,c),a):a.getAttribute("data-"+b)},a.getWidth=function(b){return C.h.getWidth(a,b)},a.getHeight=function(b){return C.h.getHeight(a,b)},a.getOffset=function(){return C.h.getOffset(a)},a},C.calcSlides=function(a){var c=C.slides?C.slides.length:!1;C.slides=[],C.displaySlides=[];for(var d=0;d=0;d--)C._extendSwiperSlide(C.slides[d]);c!==!1&&(c!==C.slides.length||a)&&(h(),g(),C.updateActiveSlide(),C.params.pagination&&C.createPagination(),C.callPlugins("numberOfSlidesChanged"))},C.createSlide=function(a,c,d){var c=c||C.params.slideClass,d=d||b.slideElement,e=document.createElement(d);return e.innerHTML=a||"",e.className=c,C._extendSwiperSlide(e)},C.appendSlide=function(a,b,c){return a?a.nodeType?C._extendSwiperSlide(a).append():C.createSlide(a,b,c).append():void 0},C.prependSlide=function(a,b,c){return a?a.nodeType?C._extendSwiperSlide(a).prepend():C.createSlide(a,b,c).prepend():void 0},C.insertSlideAfter=function(a,b,c,d){return"undefined"==typeof a?!1:b.nodeType?C._extendSwiperSlide(b).insertAfter(a):C.createSlide(b,c,d).insertAfter(a)},C.removeSlide=function(a){if(C.slides[a]){if(b.loop){if(!C.slides[a+C.loopedSlides])return!1;C.slides[a+C.loopedSlides].remove(),C.removeLoopedSlides(),C.calcSlides(),C.createLoop()}else C.slides[a].remove();return!0}return!1},C.removeLastSlide=function(){return C.slides.length>0?(b.loop?(C.slides[C.slides.length-1-C.loopedSlides].remove(),C.removeLoopedSlides(),C.calcSlides(),C.createLoop()):C.slides[C.slides.length-1].remove(),!0):!1},C.removeAllSlides=function(){for(var a=C.slides.length-1;a>=0;a--)C.slides[a].remove()},C.getSlide=function(a){return C.slides[a]},C.getLastSlide=function(){return C.slides[C.slides.length-1]},C.getFirstSlide=function(){return C.slides[0]},C.activeSlide=function(){return C.slides[C.activeIndex]},C.fireCallback=function(){var a=arguments[0];if("[object Array]"===Object.prototype.toString.call(a))for(var c=0;c0&&(f.style.paddingLeft="",f.style.paddingRight="",f.style.paddingTop="",f.style.paddingBottom=""),f.style.width="",f.style.height="",b.offsetPxBefore>0&&(M?C.wrapperLeft=b.offsetPxBefore:C.wrapperTop=b.offsetPxBefore),b.offsetPxAfter>0&&(M?C.wrapperRight=b.offsetPxAfter:C.wrapperBottom=b.offsetPxAfter),b.centeredSlides&&(M?(C.wrapperLeft=(I-this.slides[0].getWidth(!0))/2,C.wrapperRight=(I-C.slides[C.slides.length-1].getWidth(!0))/2):(C.wrapperTop=(I-C.slides[0].getHeight(!0))/2,C.wrapperBottom=(I-C.slides[C.slides.length-1].getHeight(!0))/2)),M?(C.wrapperLeft>=0&&(f.style.paddingLeft=C.wrapperLeft+"px"),C.wrapperRight>=0&&(f.style.paddingRight=C.wrapperRight+"px")):(C.wrapperTop>=0&&(f.style.paddingTop=C.wrapperTop+"px"),C.wrapperBottom>=0&&(f.style.paddingBottom=C.wrapperBottom+"px"));var i=0,j=0;C.snapGrid=[],C.slidesGrid=[];for(var k=0,l=0;lI){for(var s=0;s<=Math.floor(o/(I+C.wrapperLeft));s++)C.snapGrid.push(0===s?i+C.wrapperLeft:i+C.wrapperLeft+I*s);C.slidesGrid.push(i+C.wrapperLeft)}else C.snapGrid.push(j),C.slidesGrid.push(j);j+=o/2+r/2}else{if(o>I)for(var s=0;s<=Math.floor(o/I);s++)C.snapGrid.push(i+I*s);else C.snapGrid.push(i);C.slidesGrid.push(i)}i+=o,g+=m,h+=n}b.calculateHeight&&(C.height=k),M?(F=g+C.wrapperRight+C.wrapperLeft,f.style.width=g+"px",f.style.height=C.height+"px"):(F=h+C.wrapperTop+C.wrapperBottom,f.style.width=C.width+"px",f.style.height=h+"px")}else if(b.scrollContainer){f.style.width="",f.style.height="";var t=C.slides[0].getWidth(!0),u=C.slides[0].getHeight(!0);F=M?t:u,f.style.width=t+"px",f.style.height=u+"px",E=M?t:u}else{if(b.calculateHeight){var k=0,u=0;M||(C.container.style.height=""),f.style.height="";for(var l=0;l0&&(M?C.wrapperLeft=E*b.offsetSlidesBefore:C.wrapperTop=E*b.offsetSlidesBefore),b.offsetSlidesAfter>0&&(M?C.wrapperRight=E*b.offsetSlidesAfter:C.wrapperBottom=E*b.offsetSlidesAfter),b.offsetPxBefore>0&&(M?C.wrapperLeft=b.offsetPxBefore:C.wrapperTop=b.offsetPxBefore),b.offsetPxAfter>0&&(M?C.wrapperRight=b.offsetPxAfter:C.wrapperBottom=b.offsetPxAfter),b.centeredSlides&&(M?(C.wrapperLeft=(I-E)/2,C.wrapperRight=(I-E)/2):(C.wrapperTop=(I-E)/2,C.wrapperBottom=(I-E)/2)),M?(C.wrapperLeft>0&&(f.style.paddingLeft=C.wrapperLeft+"px"),C.wrapperRight>0&&(f.style.paddingRight=C.wrapperRight+"px")):(C.wrapperTop>0&&(f.style.paddingTop=C.wrapperTop+"px"),C.wrapperBottom>0&&(f.style.paddingBottom=C.wrapperBottom+"px")),F=M?t+C.wrapperRight+C.wrapperLeft:u+C.wrapperTop+C.wrapperBottom,b.cssWidthAndHeight||(parseFloat(t)>0&&(f.style.width=t+"px"),parseFloat(u)>0&&(f.style.height=u+"px"));var i=0;C.snapGrid=[],C.slidesGrid=[];for(var l=0;l0&&(C.slides[l].style.width=m+"px"),parseFloat(n)>0&&(C.slides[l].style.height=n+"px"))}C.initialized?(C.callPlugins("onInit"),b.onInit&&C.fireCallback(b.onInit,C)):(C.callPlugins("onFirstInit"),b.onFirstInit&&C.fireCallback(b.onFirstInit,C)),C.initialized=!0}},C.reInit=function(a){C.init(!0,a)},C.resizeFix=function(a){C.callPlugins("beforeResizeFix"),C.init(b.resizeReInit||a),b.freeMode?C.getWrapperTranslate()<-e()&&(C.setWrapperTransition(0),C.setWrapperTranslate(-e())):(C.swipeTo(b.loop?C.activeLoopIndex:C.activeIndex,0,!1),b.autoplay&&(C.support.transitions&&"undefined"!=typeof _?"undefined"!=typeof _&&(clearTimeout(_),_=void 0,C.startAutoplay()):"undefined"!=typeof ab&&(clearInterval(ab),ab=void 0,C.startAutoplay()))),C.callPlugins("afterResizeFix")},C.destroy=function(){var a=C.h.removeEventListener,c="wrapper"==b.eventTarget?C.wrapper:C.container;C.browser.ie10||C.browser.ie11?(a(c,C.touchEvents.touchStart,p),a(document,C.touchEvents.touchMove,q),a(document,C.touchEvents.touchEnd,r)):(C.support.touch&&(a(c,"touchstart",p),a(c,"touchmove",q),a(c,"touchend",r)),b.simulateTouch&&(a(c,"mousedown",p),a(document,"mousemove",q),a(document,"mouseup",r))),b.autoResize&&a(window,"resize",C.resizeFix),h(),b.paginationClickable&&w(),b.mousewheelControl&&C._wheelEvent&&a(C.container,C._wheelEvent,j),b.keyboardControl&&a(document,"keydown",i),b.autoplay&&C.stopAutoplay(),C.callPlugins("onDestroy"),C=null};var U=(new Date).getTime();if(b.grabCursor){var V=C.container.style;V.cursor="move",V.cursor="grab",V.cursor="-moz-grab",V.cursor="-webkit-grab"}C.allowSlideClick=!0,C.allowLinks=!0;var W,X,Y,Z=!1,$=!0;C.swipeNext=function(a){!a&&b.loop&&C.fixLoop(),!a&&b.autoplay&&C.stopAutoplay(!0),C.callPlugins("onSwipeNext");var c=C.getWrapperTranslate(),d=c;if("auto"==b.slidesPerView){for(var f=0;f=C.snapGrid[f]&&-cC.snapGrid[e]&&-d0&&(c=0),c==d?!1:(u(c,"prev"),!0)},C.swipeReset=function(){C.callPlugins("onSwipeReset");{var a,c=C.getWrapperTranslate(),d=E*b.slidesPerGroup;-e()}if("auto"==b.slidesPerView){a=0;for(var f=0;f=C.snapGrid[f]&&-c0?-C.snapGrid[f+1]:-C.snapGrid[f];break}}-c>=C.snapGrid[C.snapGrid.length-1]&&(a=-C.snapGrid[C.snapGrid.length-1]),c<=-e()&&(a=-e())}else a=0>c?Math.round(c/d)*d:0;return b.scrollContainer&&(a=0>c?c:0),a<-e()&&(a=-e()),b.scrollContainer&&I>E&&(a=0),a==c?!1:(u(a,"reset"),!0)},C.swipeTo=function(a,c,d){a=parseInt(a,10),C.callPlugins("onSwipeTo",{index:a,speed:c}),b.loop&&(a+=C.loopedSlides);var f=C.getWrapperTranslate();if(!(a>C.slides.length-1||0>a)){var g;return g="auto"==b.slidesPerView?-C.slidesGrid[a]:-a*E,g<-e()&&(g=-e()),g==f?!1:(d=d===!1?!1:!0,u(g,"to",{index:a,speed:c,runCallbacks:d}),!0)}},C._queueStartCallbacks=!1,C._queueEndCallbacks=!1,C.updateActiveSlide=function(a){if(C.initialized&&0!=C.slides.length){if(C.previousIndex=C.activeIndex,"undefined"==typeof a&&(a=C.getWrapperTranslate()),a>0&&(a=0),"auto"==b.slidesPerView){if(C.activeIndex=C.slidesGrid.indexOf(-a),C.activeIndex<0){for(var c=0;cC.slidesGrid[c]&&-a=d?c:c+1}}else C.activeIndex=Math[b.visibilityFullFit?"ceil":"round"](-a/E);if(C.activeIndex==C.slides.length&&(C.activeIndex=C.slides.length-1),C.activeIndex<0&&(C.activeIndex=0),C.slides[C.activeIndex]){C.calcVisibleSlides(a);for(var f=new RegExp("\\s*"+b.slideActiveClass),g=new RegExp("\\s*"+b.slideVisibleClass),c=0;c=0&&(C.slides[c].className+=" "+b.slideVisibleClass);if(C.slides[C.activeIndex].className+=" "+b.slideActiveClass,b.loop){var h=C.loopedSlides;C.activeLoopIndex=C.activeIndex-h,C.activeLoopIndex>=C.slides.length-2*h&&(C.activeLoopIndex=C.slides.length-2*h-C.activeLoopIndex),C.activeLoopIndex<0&&(C.activeLoopIndex=C.slides.length-2*h+C.activeLoopIndex),C.activeLoopIndex<0&&(C.activeLoopIndex=0)}else C.activeLoopIndex=C.activeIndex;b.pagination&&C.updatePagination(a)}}},C.createPagination=function(a){if(b.paginationClickable&&C.paginationButtons&&w(),C.paginationContainer=b.pagination.nodeType?b.pagination:c(b.pagination)[0],b.createPagination){var d="",e=C.slides.length,f=e;b.loop&&(f-=2*C.loopedSlides);for(var g=0;f>g;g++)d+="<"+b.paginationElement+' class="'+b.paginationElementClass+'">";C.paginationContainer.innerHTML=d}C.paginationButtons=c("."+b.paginationElementClass,C.paginationContainer),a||C.updatePagination(),C.callPlugins("onCreatePagination"),b.paginationClickable&&x()},C.updatePagination=function(a){if(b.pagination&&!(C.slides.length<1)){var d=c("."+b.paginationActiveClass,C.paginationContainer);if(d){var e=C.paginationButtons;if(0!=e.length){for(var f=0;fi&&(i=C.slides.length-2*C.loopedSlides+i),b.loop&&i>=C.slides.length-2*C.loopedSlides&&(i=C.slides.length-2*C.loopedSlides-i,i=Math.abs(i)),h.push(i)}for(f=0;f0&&(a+=C.wrapperLeft),!M&&C.wrapperTop>0&&(a+=C.wrapperTop);for(var g=0;g=-a&&-a+I>=f&&(h=!0),-a>=d&&f>=-a+I&&(h=!0)):(f>-a&&-a+I>=f&&(h=!0),d>=-a&&-a+I>d&&(h=!0),-a>d&&f>-a+I&&(h=!0)),h&&c.push(C.slides[g])}0==c.length&&(c=[C.slides[C.activeIndex]]),C.visibleSlides=c};var _=void 0,ab=void 0;C.startAutoplay=function(){if(C.support.transitions){if("undefined"!=typeof _)return!1;if(!b.autoplay)return;C.callPlugins("onAutoplayStart"),z() -}else{if("undefined"!=typeof ab)return!1;if(!b.autoplay)return;C.callPlugins("onAutoplayStart"),ab=setInterval(function(){b.loop?(C.fixLoop(),C.swipeNext(!0)):C.swipeNext(!0)||(b.autoplayStopOnLast?(clearInterval(ab),ab=void 0):C.swipeTo(0))},b.autoplay)}},C.stopAutoplay=function(a){if(C.support.transitions){if(!_)return;_&&clearTimeout(_),_=void 0,a&&!b.autoplayDisableOnInteraction&&C.wrapperTransitionEnd(function(){z()}),C.callPlugins("onAutoplayStop")}else ab&&clearInterval(ab),ab=void 0,C.callPlugins("onAutoplayStop")},C.loopCreated=!1,C.removeLoopedSlides=function(){if(C.loopCreated)for(var a=0;aC.slides.length&&(C.loopedSlides=C.slides.length);var a,c="",d="",e="",f=C.slides.length,g=Math.floor(C.loopedSlides/f),h=C.loopedSlides%f;for(a=0;g*f>a;a++){var i=a;if(a>=f){var j=Math.floor(a/f);i=a-f*j}e+=C.slides[i].outerHTML}for(a=0;h>a;a++)d+=t(b.slideDuplicateClass,C.slides[a].outerHTML);for(a=f-h;f>a;a++)c+=t(b.slideDuplicateClass,C.slides[a].outerHTML);var k=c+e+D.innerHTML+e+d;for(D.innerHTML=k,C.loopCreated=!0,C.calcSlides(),a=0;a=C.slides.length-C.loopedSlides)&&C.slides[a].setData("looped",!0);C.callPlugins("onCreateLoop")}},C.fixLoop=function(){var a;C.activeIndex=2*C.loopedSlides||C.activeIndex>C.slides.length-2*b.slidesPerView)&&(a=-C.slides.length+C.activeIndex+C.loopedSlides,C.swipeTo(a,0,!1))},C.loadSlides=function(){var a="";C.activeLoaderIndex=0;for(var c=b.loader.slides,d=b.loader.loadAllSlides?c.length:b.slidesPerView*(1+b.loader.surroundGroups),e=0;d>e;e++)a+="outer"==b.loader.slidesHTMLType?c[e]:"<"+b.slideElement+' class="'+b.slideClass+'" data-swiperindex="'+e+'">'+c[e]+"";C.wrapper.innerHTML=a,C.calcSlides(!0),b.loader.loadAllSlides||C.wrapperTransitionEnd(C.reloadSlides,!0)},C.reloadSlides=function(){var a=b.loader.slides,c=parseInt(C.activeSlide().data("swiperindex"),10);if(!(0>c||c>a.length-1)){C.activeLoaderIndex=c;var d=Math.max(0,c-b.slidesPerView*b.loader.surroundGroups),e=Math.min(c+b.slidesPerView*(1+b.loader.surroundGroups)-1,a.length-1);if(c>0){var f=-E*(c-d);C.setWrapperTranslate(f),C.setWrapperTransition(0)}if("reload"===b.loader.logic){C.wrapper.innerHTML="";for(var g="",h=d;e>=h;h++)g+="outer"==b.loader.slidesHTMLType?a[h]:"<"+b.slideElement+' class="'+b.slideClass+'" data-swiperindex="'+h+'">'+a[h]+"";C.wrapper.innerHTML=g}else{for(var i=1e3,j=0,h=0;hk||k>e?C.wrapper.removeChild(C.slides[h]):(i=Math.min(k,i),j=Math.max(k,j))}for(var h=d;e>=h;h++){if(i>h){var l=document.createElement(b.slideElement);l.className=b.slideClass,l.setAttribute("data-swiperindex",h),l.innerHTML=a[h],C.wrapper.insertBefore(l,C.wrapper.firstChild)}if(h>j){var l=document.createElement(b.slideElement);l.className=b.slideClass,l.setAttribute("data-swiperindex",h),l.innerHTML=a[h],C.wrapper.appendChild(l)}}}C.reInit(!0)}},A()}};Swiper.prototype={plugins:{},wrapperTransitionEnd:function(a,b){function c(){if(a(e),e.params.queueEndCallbacks&&(e._queueEndCallbacks=!1),!b)for(d=0;d0)&&(d=a.offsetWidth-parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-left"))-parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-right"))),b&&(d+=parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-left"))+parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-right"))),d},getHeight:function(a,b){if(b)return a.offsetHeight;var c=window.getComputedStyle(a,null).getPropertyValue("height"),d=parseFloat(c);return(isNaN(d)||c.indexOf("%")>0)&&(d=a.offsetHeight-parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-top"))-parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-bottom"))),b&&(d+=parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-top"))+parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-bottom"))),d},getOffset:function(a){var b=a.getBoundingClientRect(),c=document.body,d=a.clientTop||c.clientTop||0,e=a.clientLeft||c.clientLeft||0,f=window.pageYOffset||a.scrollTop,g=window.pageXOffset||a.scrollLeft;return document.documentElement&&!window.pageYOffset&&(f=document.documentElement.scrollTop,g=document.documentElement.scrollLeft),{top:b.top+f-d,left:b.left+g-e}},windowWidth:function(){return window.innerWidth?window.innerWidth:document.documentElement&&document.documentElement.clientWidth?document.documentElement.clientWidth:void 0},windowHeight:function(){return window.innerHeight?window.innerHeight:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientHeight:void 0},windowScroll:function(){return"undefined"!=typeof pageYOffset?{left:window.pageXOffset,top:window.pageYOffset}:document.documentElement?{left:document.documentElement.scrollLeft,top:document.documentElement.scrollTop}:void 0},addEventListener:function(a,b,c,d){"undefined"==typeof d&&(d=!1),a.addEventListener?a.addEventListener(b,c,d):a.attachEvent&&a.attachEvent("on"+b,c)},removeEventListener:function(a,b,c,d){"undefined"==typeof d&&(d=!1),a.removeEventListener?a.removeEventListener(b,c,d):a.detachEvent&&a.detachEvent("on"+b,c)}},setTransform:function(a,b){var c=a.style;c.webkitTransform=c.MsTransform=c.msTransform=c.MozTransform=c.OTransform=c.transform=b},setTranslate:function(a,b){var c=a.style,d={x:b.x||0,y:b.y||0,z:b.z||0},e=this.support.transforms3d?"translate3d("+d.x+"px,"+d.y+"px,"+d.z+"px)":"translate("+d.x+"px,"+d.y+"px)";c.webkitTransform=c.MsTransform=c.msTransform=c.MozTransform=c.OTransform=c.transform=e,this.support.transforms||(c.left=d.x+"px",c.top=d.y+"px")},setTransition:function(a,b){var c=a.style;c.webkitTransitionDuration=c.MsTransitionDuration=c.msTransitionDuration=c.MozTransitionDuration=c.OTransitionDuration=c.transitionDuration=b+"ms"},support:{touch:window.Modernizr&&Modernizr.touch===!0||function(){return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)}(),transforms3d:window.Modernizr&&Modernizr.csstransforms3d===!0||function(){var a=document.createElement("div").style;return"webkitPerspective"in a||"MozPerspective"in a||"OPerspective"in a||"MsPerspective"in a||"perspective"in a}(),transforms:window.Modernizr&&Modernizr.csstransforms===!0||function(){var a=document.createElement("div").style;return"transform"in a||"WebkitTransform"in a||"MozTransform"in a||"msTransform"in a||"MsTransform"in a||"OTransform"in a}(),transitions:window.Modernizr&&Modernizr.csstransitions===!0||function(){var a=document.createElement("div").style;return"transition"in a||"WebkitTransition"in a||"MozTransition"in a||"msTransition"in a||"MsTransition"in a||"OTransition"in a}()},browser:{ie8:function(){var a=-1;if("Microsoft Internet Explorer"==navigator.appName){var b=navigator.userAgent,c=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");null!=c.exec(b)&&(a=parseFloat(RegExp.$1))}return-1!=a&&9>a}(),ie10:window.navigator.msPointerEnabled,ie11:window.navigator.pointerEnabled}},(window.jQuery||window.Zepto)&&!function(a){a.fn.swiper=function(b){var c=new Swiper(a(this)[0],b);return a(this).data("swiper",c),c}}(window.jQuery||window.Zepto),"undefined"!=typeof module&&(module.exports=Swiper); \ No newline at end of file +var Swiper=function(a,b){"use strict";function c(a,b){return document.querySelectorAll?(b||document).querySelectorAll(a):jQuery(a,b)}function d(a){return"[object Array]"===Object.prototype.toString.apply(a)?!0:!1}function e(){var a=F-I;return b.freeMode&&(a=F-I),b.slidesPerView>C.slides.length&&!b.centeredSlides&&(a=0),0>a&&(a=0),a}function f(){function a(a){var c=new Image;c.onload=function(){C&&C.imagesLoaded&&C.imagesLoaded++,C.imagesLoaded===C.imagesToLoad.length&&(C.reInit(),b.onImagesReady&&C.fireCallback(b.onImagesReady,C))},c.src=a}var d=C.h.addEventListener,e="wrapper"===b.eventTarget?C.wrapper:C.container;if(C.browser.ie10||C.browser.ie11?(d(e,C.touchEvents.touchStart,p),d(document,C.touchEvents.touchMove,q),d(document,C.touchEvents.touchEnd,r)):(C.support.touch&&(d(e,"touchstart",p),d(e,"touchmove",q),d(e,"touchend",r)),b.simulateTouch&&(d(e,"mousedown",p),d(document,"mousemove",q),d(document,"mouseup",r))),b.autoResize&&d(window,"resize",C.resizeFix),g(),C._wheelEvent=!1,b.mousewheelControl){void 0!==document.onmousewheel&&(C._wheelEvent="mousewheel");try{new WheelEvent("wheel"),C._wheelEvent="wheel"}catch(f){}C._wheelEvent||(C._wheelEvent="DOMMouseScroll"),C._wheelEvent&&d(C.container,C._wheelEvent,j)}if(b.keyboardControl&&d(document,"keydown",i),b.updateOnImagesReady){C.imagesToLoad=c("img",C.container);for(var h=0;h=e&&k[0]<=e+g&&k[1]>=f&&k[1]<=f+h&&(c=!0)}if(!c)return}M?((37===b||39===b)&&(a.preventDefault?a.preventDefault():a.returnValue=!1),39===b&&C.swipeNext(),37===b&&C.swipePrev()):((38===b||40===b)&&(a.preventDefault?a.preventDefault():a.returnValue=!1),40===b&&C.swipeNext(),38===b&&C.swipePrev())}}function j(a){var c=C._wheelEvent,d=0;if(a.detail)d=-a.detail;else if("mousewheel"===c)if(b.mousewheelControlForceToAxis)if(M){if(!(Math.abs(a.wheelDeltaX)>Math.abs(a.wheelDeltaY)))return;d=a.wheelDeltaX}else{if(!(Math.abs(a.wheelDeltaY)>Math.abs(a.wheelDeltaX)))return;d=a.wheelDeltaY}else d=a.wheelDelta;else if("DOMMouseScroll"===c)d=-a.detail;else if("wheel"===c)if(b.mousewheelControlForceToAxis)if(M){if(!(Math.abs(a.deltaX)>Math.abs(a.deltaY)))return;d=-a.deltaX}else{if(!(Math.abs(a.deltaY)>Math.abs(a.deltaX)))return;d=-a.deltaY}else d=Math.abs(a.deltaX)>Math.abs(a.deltaY)?-a.deltaX:-a.deltaY;if(b.freeMode){var f=C.getWrapperTranslate()+d;if(f>0&&(f=0),f<-e()&&(f=-e()),C.setWrapperTransition(0),C.setWrapperTranslate(f),C.updateActiveSlide(f),0===f||f===-e())return}else(new Date).getTime()-U>60&&(0>d?C.swipeNext():C.swipePrev()),U=(new Date).getTime();return b.autoplay&&C.stopAutoplay(!0),a.preventDefault?a.preventDefault():a.returnValue=!1,!1}function k(a){C.allowSlideClick&&(m(a),C.fireCallback(b.onSlideClick,C,a))}function l(a){m(a),C.fireCallback(b.onSlideTouch,C,a)}function m(a){if(a.currentTarget)C.clickedSlide=a.currentTarget;else{var c=a.srcElement;do{if(c.className.indexOf(b.slideClass)>-1)break;c=c.parentNode}while(c);C.clickedSlide=c}C.clickedSlideIndex=C.slides.indexOf(C.clickedSlide),C.clickedSlideLoopIndex=C.clickedSlideIndex-(C.loopedSlides||0)}function n(a){return C.allowLinks?void 0:(a.preventDefault?a.preventDefault():a.returnValue=!1,b.preventLinksPropagation&&"stopPropagation"in a&&a.stopPropagation(),!1)}function o(a){return a.stopPropagation?a.stopPropagation():a.returnValue=!1,!1}function p(a){if(b.preventLinks&&(C.allowLinks=!0),C.isTouched||b.onlyExternal)return!1;if(b.noSwiping&&(a.target||a.srcElement)&&s(a.target||a.srcElement))return!1;if($=!1,C.isTouched=!0,Z="touchstart"===a.type,!Z||1===a.targetTouches.length){C.callPlugins("onTouchStartBegin"),Z||C.isAndroid||(a.preventDefault?a.preventDefault():a.returnValue=!1);var c=Z?a.targetTouches[0].pageX:a.pageX||a.clientX,d=Z?a.targetTouches[0].pageY:a.pageY||a.clientY;C.touches.startX=C.touches.currentX=c,C.touches.startY=C.touches.currentY=d,C.touches.start=C.touches.current=M?c:d,C.setWrapperTransition(0),C.positions.start=C.positions.current=C.getWrapperTranslate(),C.setWrapperTranslate(C.positions.start),C.times.start=(new Date).getTime(),H=void 0,b.moveStartThreshold>0&&(W=!1),b.onTouchStart&&C.fireCallback(b.onTouchStart,C),C.callPlugins("onTouchStartEnd")}}function q(a){if(C.isTouched&&!b.onlyExternal&&(!Z||"mousemove"!==a.type)){var c=Z?a.targetTouches[0].pageX:a.pageX||a.clientX,d=Z?a.targetTouches[0].pageY:a.pageY||a.clientY;if("undefined"==typeof H&&M&&(H=!!(H||Math.abs(d-C.touches.startY)>Math.abs(c-C.touches.startX))),"undefined"!=typeof H||M||(H=!!(H||Math.abs(d-C.touches.startY)0&&b.onResistanceBefore&&C.fireCallback(b.onResistanceBefore,C,C.positions.current),C.positions.current<-e()&&b.onResistanceAfter&&C.fireCallback(b.onResistanceAfter,C,Math.abs(C.positions.current+e())),b.resistance&&"100%"!==b.resistance){var f;if(C.positions.current>0&&(f=1-C.positions.current/I/2,C.positions.current=.5>f?I/2:C.positions.current*f),C.positions.current<-e()){var g=(C.touches.current-C.touches.start)*b.touchRatio+(e()+C.positions.start);f=(I+g)/I;var h=C.positions.current-g*(1-f)/2,i=-e()-I/2;C.positions.current=i>h||0>=f?i:h}}if(b.resistance&&"100%"===b.resistance&&(C.positions.current>0&&(!b.freeMode||b.freeModeFluid)&&(C.positions.current=0),C.positions.current<-e()&&(!b.freeMode||b.freeModeFluid)&&(C.positions.current=-e())),!b.followFinger)return;if(b.moveStartThreshold)if(Math.abs(C.touches.current-C.touches.start)>b.moveStartThreshold||W){if(!W)return W=!0,void(C.touches.start=C.touches.current);C.setWrapperTranslate(C.positions.current)}else C.positions.current=C.positions.start;else C.setWrapperTranslate(C.positions.current);return(b.freeMode||b.watchActiveIndex)&&C.updateActiveSlide(C.positions.current),b.grabCursor&&(C.container.style.cursor="move",C.container.style.cursor="grabbing",C.container.style.cursor="-moz-grabbin",C.container.style.cursor="-webkit-grabbing"),X||(X=C.touches.current),Y||(Y=(new Date).getTime()),C.velocity=(C.touches.current-X)/((new Date).getTime()-Y)/2,Math.abs(C.touches.current-X)<2&&(C.velocity=0),X=C.touches.current,Y=(new Date).getTime(),C.callPlugins("onTouchMoveEnd"),b.onTouchMove&&C.fireCallback(b.onTouchMove,C),!1}}}function r(){if(H&&C.swipeReset(),!b.onlyExternal&&C.isTouched){C.isTouched=!1,b.grabCursor&&(C.container.style.cursor="move",C.container.style.cursor="grab",C.container.style.cursor="-moz-grab",C.container.style.cursor="-webkit-grab"),C.positions.current||0===C.positions.current||(C.positions.current=C.positions.start),b.followFinger&&C.setWrapperTranslate(C.positions.current),C.times.end=(new Date).getTime(),C.touches.diff=C.touches.current-C.touches.start,C.touches.abs=Math.abs(C.touches.diff),C.positions.diff=C.positions.current-C.positions.start,C.positions.abs=Math.abs(C.positions.diff);var a=C.positions.diff,c=C.positions.abs,d=C.times.end-C.times.start;5>c&&300>d&&C.allowLinks===!1&&(b.freeMode||0===c||C.swipeReset(),b.preventLinks&&(C.allowLinks=!0),b.onSlideClick&&(C.allowSlideClick=!0)),setTimeout(function(){b.preventLinks&&(C.allowLinks=!0),b.onSlideClick&&(C.allowSlideClick=!0)},100);var f=e();if(!C.isMoved&&b.freeMode)return C.isMoved=!1,b.onTouchEnd&&C.fireCallback(b.onTouchEnd,C),void C.callPlugins("onTouchEnd");if(!C.isMoved||C.positions.current>0||C.positions.current<-f)return C.swipeReset(),b.onTouchEnd&&C.fireCallback(b.onTouchEnd,C),void C.callPlugins("onTouchEnd");if(C.isMoved=!1,b.freeMode){if(b.freeModeFluid){var g,h=1e3*b.momentumRatio,i=C.velocity*h,j=C.positions.current+i,k=!1,l=20*Math.abs(C.velocity)*b.momentumBounceRatio;-f>j&&(b.momentumBounce&&C.support.transitions?(-l>j+f&&(j=-f-l),g=-f,k=!0,$=!0):j=-f),j>0&&(b.momentumBounce&&C.support.transitions?(j>l&&(j=l),g=0,k=!0,$=!0):j=0),0!==C.velocity&&(h=Math.abs((j-C.positions.current)/C.velocity)),C.setWrapperTranslate(j),C.setWrapperTransition(h),b.momentumBounce&&k&&C.wrapperTransitionEnd(function(){$&&(b.onMomentumBounce&&C.fireCallback(b.onMomentumBounce,C),C.callPlugins("onMomentumBounce"),C.setWrapperTranslate(g),C.setWrapperTransition(300))}),C.updateActiveSlide(j)}return(!b.freeModeFluid||d>=300)&&C.updateActiveSlide(C.positions.current),b.onTouchEnd&&C.fireCallback(b.onTouchEnd,C),void C.callPlugins("onTouchEnd")}G=0>a?"toNext":"toPrev","toNext"===G&&300>=d&&(30>c||!b.shortSwipes?C.swipeReset():C.swipeNext(!0)),"toPrev"===G&&300>=d&&(30>c||!b.shortSwipes?C.swipeReset():C.swipePrev(!0));var m=0;if("auto"===b.slidesPerView){for(var n,o=Math.abs(C.getWrapperTranslate()),p=0,q=0;qo){m=n;break}m>I&&(m=I)}else m=E*b.slidesPerView;"toNext"===G&&d>300&&(c>=m*b.longSwipesRatio?C.swipeNext(!0):C.swipeReset()),"toPrev"===G&&d>300&&(c>=m*b.longSwipesRatio?C.swipePrev(!0):C.swipeReset()),b.onTouchEnd&&C.fireCallback(b.onTouchEnd,C),C.callPlugins("onTouchEnd")}}function s(a){var c=!1;do a.className.indexOf(b.noSwipingClass)>-1&&(c=!0),a=a.parentElement;while(!c&&a.parentElement&&-1===a.className.indexOf(b.wrapperClass));return!c&&a.className.indexOf(b.wrapperClass)>-1&&a.className.indexOf(b.noSwipingClass)>-1&&(c=!0),c}function t(a,b){var c,d=document.createElement("div");return d.innerHTML=b,c=d.firstChild,c.className+=" "+a,c.outerHTML}function u(a,c,d){function e(){var c=+new Date,d=c-g;h+=i*d/(1e3/60),k="toNext"===j?h>a:a>h,k?(C.setWrapperTranslate(Math.round(h)),C._DOMAnimating=!0,window.setTimeout(function(){e()},1e3/60)):(b.onSlideChangeEnd&&C.fireCallback(b.onSlideChangeEnd,C),C.setWrapperTranslate(a),C._DOMAnimating=!1)}var f="to"===c&&d.speed>=0?d.speed:b.speed,g=+new Date;if(C.support.transitions||!b.DOMAnimation)C.setWrapperTranslate(a),C.setWrapperTransition(f);else{var h=C.getWrapperTranslate(),i=Math.ceil((a-h)/f*(1e3/60)),j=h>a?"toNext":"toPrev",k="toNext"===j?h>a:a>h;if(C._DOMAnimating)return;e()}C.updateActiveSlide(a),b.onSlideNext&&"next"===c&&C.fireCallback(b.onSlideNext,C,a),b.onSlidePrev&&"prev"===c&&C.fireCallback(b.onSlidePrev,C,a),b.onSlideReset&&"reset"===c&&C.fireCallback(b.onSlideReset,C,a),("next"===c||"prev"===c||"to"===c&&d.runCallbacks===!0)&&v(c)}function v(a){if(C.callPlugins("onSlideChangeStart"),b.onSlideChangeStart)if(b.queueStartCallbacks&&C.support.transitions){if(C._queueStartCallbacks)return;C._queueStartCallbacks=!0,C.fireCallback(b.onSlideChangeStart,C,a),C.wrapperTransitionEnd(function(){C._queueStartCallbacks=!1})}else C.fireCallback(b.onSlideChangeStart,C,a);if(b.onSlideChangeEnd)if(C.support.transitions)if(b.queueEndCallbacks){if(C._queueEndCallbacks)return;C._queueEndCallbacks=!0,C.wrapperTransitionEnd(function(c){C.fireCallback(b.onSlideChangeEnd,c,a)})}else C.wrapperTransitionEnd(function(c){C.fireCallback(b.onSlideChangeEnd,c,a)});else b.DOMAnimation||setTimeout(function(){C.fireCallback(b.onSlideChangeEnd,C,a)},10)}function w(){var a=C.paginationButtons;if(a)for(var b=0;b0&&0===C.slides.length&&C.loadSlides(),b.loop&&C.createLoop(),C.init(),f(),b.pagination&&C.createPagination(!0),b.loop||b.initialSlide>0?C.swipeTo(b.initialSlide,0,!1):C.updateActiveSlide(0),b.autoplay&&C.startAutoplay(),C.centerIndex=C.activeIndex,b.onSwiperCreated&&C.fireCallback(b.onSwiperCreated,C),C.callPlugins("onSwiperCreated")}if(document.body.__defineGetter__&&HTMLElement){var B=HTMLElement.prototype;B.__defineGetter__&&B.__defineGetter__("outerHTML",function(){return(new XMLSerializer).serializeToString(this)})}if(window.getComputedStyle||(window.getComputedStyle=function(a){return this.el=a,this.getPropertyValue=function(b){var c=/(\-([a-z]){1})/g;return"float"===b&&(b="styleFloat"),c.test(b)&&(b=b.replace(c,function(){return arguments[2].toUpperCase()})),a.currentStyle[b]?a.currentStyle[b]:null},this}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){for(var c=b||0,d=this.length;d>c;c++)if(this[c]===a)return c;return-1}),(document.querySelectorAll||window.jQuery)&&"undefined"!=typeof a&&(a.nodeType||0!==c(a).length)){var C=this;C.touches={start:0,startX:0,startY:0,current:0,currentX:0,currentY:0,diff:0,abs:0},C.positions={start:0,abs:0,diff:0,current:0},C.times={start:0,end:0},C.id=(new Date).getTime(),C.container=a.nodeType?a:c(a)[0],C.isTouched=!1,C.isMoved=!1,C.activeIndex=0,C.centerIndex=0,C.activeLoaderIndex=0,C.activeLoopIndex=0,C.previousIndex=null,C.velocity=0,C.snapGrid=[],C.slidesGrid=[],C.imagesToLoad=[],C.imagesLoaded=0,C.wrapperLeft=0,C.wrapperRight=0,C.wrapperTop=0,C.wrapperBottom=0,C.isAndroid=navigator.userAgent.toLowerCase().indexOf("android")>=0;var D,E,F,G,H,I,J={eventTarget:"wrapper",mode:"horizontal",touchRatio:1,speed:300,freeMode:!1,freeModeFluid:!1,momentumRatio:1,momentumBounce:!0,momentumBounceRatio:1,slidesPerView:1,slidesPerGroup:1,slidesPerViewFit:!0,simulateTouch:!0,followFinger:!0,shortSwipes:!0,longSwipesRatio:.5,moveStartThreshold:!1,onlyExternal:!1,createPagination:!0,pagination:!1,paginationElement:"span",paginationClickable:!1,paginationAsRange:!0,resistance:!0,scrollContainer:!1,preventLinks:!0,preventLinksPropagation:!1,noSwiping:!1,noSwipingClass:"swiper-no-swiping",initialSlide:0,keyboardControl:!1,mousewheelControl:!1,mousewheelControlForceToAxis:!1,useCSS3Transforms:!0,autoplay:!1,autoplayDisableOnInteraction:!0,autoplayStopOnLast:!1,loop:!1,loopAdditionalSlides:0,calculateHeight:!1,cssWidthAndHeight:!1,updateOnImagesReady:!0,releaseFormElements:!0,watchActiveIndex:!1,visibilityFullFit:!1,offsetPxBefore:0,offsetPxAfter:0,offsetSlidesBefore:0,offsetSlidesAfter:0,centeredSlides:!1,queueStartCallbacks:!1,queueEndCallbacks:!1,autoResize:!0,resizeReInit:!1,DOMAnimation:!0,loader:{slides:[],slidesHTMLType:"inner",surroundGroups:1,logic:"reload",loadAllSlides:!1},slideElement:"div",slideClass:"swiper-slide",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideDuplicateClass:"swiper-slide-duplicate",wrapperClass:"swiper-wrapper",paginationElementClass:"swiper-pagination-switch",paginationActiveClass:"swiper-active-switch",paginationVisibleClass:"swiper-visible-switch"};b=b||{};for(var K in J)if(K in b&&"object"==typeof b[K])for(var L in J[K])L in b[K]||(b[K][L]=J[K][L]);else K in b||(b[K]=J[K]);C.params=b,b.scrollContainer&&(b.freeMode=!0,b.freeModeFluid=!0),b.loop&&(b.resistance="100%");var M="horizontal"===b.mode,N=["mousedown","mousemove","mouseup"];C.browser.ie10&&(N=["MSPointerDown","MSPointerMove","MSPointerUp"]),C.browser.ie11&&(N=["pointerdown","pointermove","pointerup"]),C.touchEvents={touchStart:C.support.touch||!b.simulateTouch?"touchstart":N[0],touchMove:C.support.touch||!b.simulateTouch?"touchmove":N[1],touchEnd:C.support.touch||!b.simulateTouch?"touchend":N[2]};for(var O=C.container.childNodes.length-1;O>=0;O--)if(C.container.childNodes[O].className)for(var P=C.container.childNodes[O].className.split(/\s+/),Q=0;Q=0;c--)a===C.slides[c]&&(b=c);return b},a.isActive=function(){return a.index()===C.activeIndex?!0:!1},a.swiperSlideDataStorage||(a.swiperSlideDataStorage={}),a.getData=function(b){return a.swiperSlideDataStorage[b]},a.setData=function(b,c){return a.swiperSlideDataStorage[b]=c,a},a.data=function(b,c){return"undefined"==typeof c?a.getAttribute("data-"+b):(a.setAttribute("data-"+b,c),a)},a.getWidth=function(b){return C.h.getWidth(a,b)},a.getHeight=function(b){return C.h.getHeight(a,b)},a.getOffset=function(){return C.h.getOffset(a)},a},C.calcSlides=function(a){var c=C.slides?C.slides.length:!1;C.slides=[],C.displaySlides=[];for(var d=0;d=0;d--)C._extendSwiperSlide(C.slides[d]);c!==!1&&(c!==C.slides.length||a)&&(h(),g(),C.updateActiveSlide(),C.params.pagination&&C.createPagination(),C.callPlugins("numberOfSlidesChanged"))},C.createSlide=function(a,c,d){c=c||C.params.slideClass,d=d||b.slideElement;var e=document.createElement(d);return e.innerHTML=a||"",e.className=c,C._extendSwiperSlide(e)},C.appendSlide=function(a,b,c){return a?a.nodeType?C._extendSwiperSlide(a).append():C.createSlide(a,b,c).append():void 0},C.prependSlide=function(a,b,c){return a?a.nodeType?C._extendSwiperSlide(a).prepend():C.createSlide(a,b,c).prepend():void 0},C.insertSlideAfter=function(a,b,c,d){return"undefined"==typeof a?!1:b.nodeType?C._extendSwiperSlide(b).insertAfter(a):C.createSlide(b,c,d).insertAfter(a)},C.removeSlide=function(a){if(C.slides[a]){if(b.loop){if(!C.slides[a+C.loopedSlides])return!1;C.slides[a+C.loopedSlides].remove(),C.removeLoopedSlides(),C.calcSlides(),C.createLoop()}else C.slides[a].remove();return!0}return!1},C.removeLastSlide=function(){return C.slides.length>0?(b.loop?(C.slides[C.slides.length-1-C.loopedSlides].remove(),C.removeLoopedSlides(),C.calcSlides(),C.createLoop()):C.slides[C.slides.length-1].remove(),!0):!1},C.removeAllSlides=function(){for(var a=C.slides.length-1;a>=0;a--)C.slides[a].remove()},C.getSlide=function(a){return C.slides[a]},C.getLastSlide=function(){return C.slides[C.slides.length-1]},C.getFirstSlide=function(){return C.slides[0]},C.activeSlide=function(){return C.slides[C.activeIndex]},C.fireCallback=function(){var a=arguments[0];if("[object Array]"===Object.prototype.toString.call(a))for(var c=0;c0&&(m.style.paddingLeft="",m.style.paddingRight="",m.style.paddingTop="",m.style.paddingBottom=""),m.style.width="",m.style.height="",b.offsetPxBefore>0&&(M?C.wrapperLeft=b.offsetPxBefore:C.wrapperTop=b.offsetPxBefore),b.offsetPxAfter>0&&(M?C.wrapperRight=b.offsetPxAfter:C.wrapperBottom=b.offsetPxAfter),b.centeredSlides&&(M?(C.wrapperLeft=(I-this.slides[0].getWidth(!0))/2,C.wrapperRight=(I-C.slides[C.slides.length-1].getWidth(!0))/2):(C.wrapperTop=(I-C.slides[0].getHeight(!0))/2,C.wrapperBottom=(I-C.slides[C.slides.length-1].getHeight(!0))/2)),M?(C.wrapperLeft>=0&&(m.style.paddingLeft=C.wrapperLeft+"px"),C.wrapperRight>=0&&(m.style.paddingRight=C.wrapperRight+"px")):(C.wrapperTop>=0&&(m.style.paddingTop=C.wrapperTop+"px"),C.wrapperBottom>=0&&(m.style.paddingBottom=C.wrapperBottom+"px")),k=0;var p=0;for(C.snapGrid=[],C.slidesGrid=[],h=0,l=0;lI){if(b.slidesPerViewFit)C.snapGrid.push(k+C.wrapperLeft),C.snapGrid.push(k+q-I+C.wrapperLeft);else for(var u=0;u<=Math.floor(q/(I+C.wrapperLeft));u++)C.snapGrid.push(0===u?k+C.wrapperLeft:k+C.wrapperLeft+I*u);C.slidesGrid.push(k+C.wrapperLeft)}else C.snapGrid.push(p),C.slidesGrid.push(p);p+=q/2+t/2}else{if(q>I)if(b.slidesPerViewFit)C.snapGrid.push(k),C.snapGrid.push(k+q-I);else for(var v=0;v<=Math.floor(q/I);v++)C.snapGrid.push(k+I*v);else C.snapGrid.push(k);C.slidesGrid.push(k)}k+=q,n+=f,o+=g}b.calculateHeight&&(C.height=h),M?(F=n+C.wrapperRight+C.wrapperLeft,m.style.width=n+"px",m.style.height=C.height+"px"):(F=o+C.wrapperTop+C.wrapperBottom,m.style.width=C.width+"px",m.style.height=o+"px")}else if(b.scrollContainer)m.style.width="",m.style.height="",i=C.slides[0].getWidth(!0),j=C.slides[0].getHeight(!0),F=M?i:j,m.style.width=i+"px",m.style.height=j+"px",E=M?i:j;else{if(b.calculateHeight){for(h=0,j=0,M||(C.container.style.height=""),m.style.height="",l=0;l0&&(M?C.wrapperLeft=E*b.offsetSlidesBefore:C.wrapperTop=E*b.offsetSlidesBefore),b.offsetSlidesAfter>0&&(M?C.wrapperRight=E*b.offsetSlidesAfter:C.wrapperBottom=E*b.offsetSlidesAfter),b.offsetPxBefore>0&&(M?C.wrapperLeft=b.offsetPxBefore:C.wrapperTop=b.offsetPxBefore),b.offsetPxAfter>0&&(M?C.wrapperRight=b.offsetPxAfter:C.wrapperBottom=b.offsetPxAfter),b.centeredSlides&&(M?(C.wrapperLeft=(I-E)/2,C.wrapperRight=(I-E)/2):(C.wrapperTop=(I-E)/2,C.wrapperBottom=(I-E)/2)),M?(C.wrapperLeft>0&&(m.style.paddingLeft=C.wrapperLeft+"px"),C.wrapperRight>0&&(m.style.paddingRight=C.wrapperRight+"px")):(C.wrapperTop>0&&(m.style.paddingTop=C.wrapperTop+"px"),C.wrapperBottom>0&&(m.style.paddingBottom=C.wrapperBottom+"px")),F=M?i+C.wrapperRight+C.wrapperLeft:j+C.wrapperTop+C.wrapperBottom,b.cssWidthAndHeight||(parseFloat(i)>0&&(m.style.width=i+"px"),parseFloat(j)>0&&(m.style.height=j+"px")),k=0,C.snapGrid=[],C.slidesGrid=[],l=0;l0&&(C.slides[l].style.width=f+"px"),parseFloat(g)>0&&(C.slides[l].style.height=g+"px"))}C.initialized?(C.callPlugins("onInit"),b.onInit&&C.fireCallback(b.onInit,C)):(C.callPlugins("onFirstInit"),b.onFirstInit&&C.fireCallback(b.onFirstInit,C)),C.initialized=!0}},C.reInit=function(a){C.init(!0,a)},C.resizeFix=function(a){C.callPlugins("beforeResizeFix"),C.init(b.resizeReInit||a),b.freeMode?C.getWrapperTranslate()<-e()&&(C.setWrapperTransition(0),C.setWrapperTranslate(-e())):(C.swipeTo(b.loop?C.activeLoopIndex:C.activeIndex,0,!1),b.autoplay&&(C.support.transitions&&"undefined"!=typeof _?"undefined"!=typeof _&&(clearTimeout(_),_=void 0,C.startAutoplay()):"undefined"!=typeof ab&&(clearInterval(ab),ab=void 0,C.startAutoplay()))),C.callPlugins("afterResizeFix")},C.destroy=function(){var a=C.h.removeEventListener,c="wrapper"===b.eventTarget?C.wrapper:C.container;C.browser.ie10||C.browser.ie11?(a(c,C.touchEvents.touchStart,p),a(document,C.touchEvents.touchMove,q),a(document,C.touchEvents.touchEnd,r)):(C.support.touch&&(a(c,"touchstart",p),a(c,"touchmove",q),a(c,"touchend",r)),b.simulateTouch&&(a(c,"mousedown",p),a(document,"mousemove",q),a(document,"mouseup",r))),b.autoResize&&a(window,"resize",C.resizeFix),h(),b.paginationClickable&&w(),b.mousewheelControl&&C._wheelEvent&&a(C.container,C._wheelEvent,j),b.keyboardControl&&a(document,"keydown",i),b.autoplay&&C.stopAutoplay(),C.callPlugins("onDestroy"),C=null},C.disableKeyboardControl=function(){b.keyboardControl=!1,C.h.removeEventListener(document,"keydown",i)},C.enableKeyboardControl=function(){b.keyboardControl=!0,C.h.addEventListener(document,"keydown",i)};var U=(new Date).getTime();if(b.grabCursor){var V=C.container.style;V.cursor="move",V.cursor="grab",V.cursor="-moz-grab",V.cursor="-webkit-grab"}C.allowSlideClick=!0,C.allowLinks=!0;var W,X,Y,Z=!1,$=!0;C.swipeNext=function(a){!a&&b.loop&&C.fixLoop(),!a&&b.autoplay&&C.stopAutoplay(!0),C.callPlugins("onSwipeNext");var c=C.getWrapperTranslate(),d=c;if("auto"===b.slidesPerView){for(var f=0;f=C.snapGrid[f]&&-cC.snapGrid[e]&&-d0&&(c=0),c===d?!1:(u(c,"prev"),!0)},C.swipeReset=function(){C.callPlugins("onSwipeReset");{var a,c=C.getWrapperTranslate(),d=E*b.slidesPerGroup;-e()}if("auto"===b.slidesPerView){a=0;for(var f=0;f=C.snapGrid[f]&&-c0?-C.snapGrid[f+1]:-C.snapGrid[f];break}}-c>=C.snapGrid[C.snapGrid.length-1]&&(a=-C.snapGrid[C.snapGrid.length-1]),c<=-e()&&(a=-e())}else a=0>c?Math.round(c/d)*d:0;return b.scrollContainer&&(a=0>c?c:0),a<-e()&&(a=-e()),b.scrollContainer&&I>E&&(a=0),a===c?!1:(u(a,"reset"),!0)},C.swipeTo=function(a,c,d){a=parseInt(a,10),C.callPlugins("onSwipeTo",{index:a,speed:c}),b.loop&&(a+=C.loopedSlides);var f=C.getWrapperTranslate();if(!(a>C.slides.length-1||0>a)){var g;return g="auto"===b.slidesPerView?-C.slidesGrid[a]:-a*E,g<-e()&&(g=-e()),g===f?!1:(d=d===!1?!1:!0,u(g,"to",{index:a,speed:c,runCallbacks:d}),!0)}},C._queueStartCallbacks=!1,C._queueEndCallbacks=!1,C.updateActiveSlide=function(a){if(C.initialized&&0!==C.slides.length){if(C.previousIndex=C.activeIndex,"undefined"==typeof a&&(a=C.getWrapperTranslate()),a>0&&(a=0),"auto"===b.slidesPerView){if(C.activeIndex=C.slidesGrid.indexOf(-a),C.activeIndex<0){for(var c=0;cC.slidesGrid[c]&&-a=d?c:c+1}}else C.activeIndex=Math[b.visibilityFullFit?"ceil":"round"](-a/E);if(C.activeIndex===C.slides.length&&(C.activeIndex=C.slides.length-1),C.activeIndex<0&&(C.activeIndex=0),C.slides[C.activeIndex]){C.calcVisibleSlides(a);for(var f=new RegExp("\\s*"+b.slideActiveClass),g=new RegExp("\\s*"+b.slideVisibleClass),h=0;h=0&&(C.slides[h].className+=" "+b.slideVisibleClass);if(C.slides[C.activeIndex].className+=" "+b.slideActiveClass,b.loop){var i=C.loopedSlides;C.activeLoopIndex=C.activeIndex-i,C.activeLoopIndex>=C.slides.length-2*i&&(C.activeLoopIndex=C.slides.length-2*i-C.activeLoopIndex),C.activeLoopIndex<0&&(C.activeLoopIndex=C.slides.length-2*i+C.activeLoopIndex),C.activeLoopIndex<0&&(C.activeLoopIndex=0)}else C.activeLoopIndex=C.activeIndex;b.pagination&&C.updatePagination(a)}}},C.createPagination=function(a){if(b.paginationClickable&&C.paginationButtons&&w(),C.paginationContainer=b.pagination.nodeType?b.pagination:c(b.pagination)[0],b.createPagination){var d="",e=C.slides.length,f=e;b.loop&&(f-=2*C.loopedSlides);for(var g=0;f>g;g++)d+="<"+b.paginationElement+' class="'+b.paginationElementClass+'">";C.paginationContainer.innerHTML=d}C.paginationButtons=c("."+b.paginationElementClass,C.paginationContainer),a||C.updatePagination(),C.callPlugins("onCreatePagination"),b.paginationClickable&&x()},C.updatePagination=function(a){if(b.pagination&&!(C.slides.length<1)){var d=c("."+b.paginationActiveClass,C.paginationContainer);if(d){var e=C.paginationButtons;if(0!==e.length){for(var f=0;fj&&(j=C.slides.length-2*C.loopedSlides+j),b.loop&&j>=C.slides.length-2*C.loopedSlides&&(j=C.slides.length-2*C.loopedSlides-j,j=Math.abs(j)),i.push(j)}for(h=0;h0&&(a+=C.wrapperLeft),!M&&C.wrapperTop>0&&(a+=C.wrapperTop); +for(var g=0;g=-a&&-a+I>=f&&(h=!0),-a>=d&&f>=-a+I&&(h=!0)):(f>-a&&-a+I>=f&&(h=!0),d>=-a&&-a+I>d&&(h=!0),-a>d&&f>-a+I&&(h=!0)),h&&c.push(C.slides[g])}0===c.length&&(c=[C.slides[C.activeIndex]]),C.visibleSlides=c};var _,ab;C.startAutoplay=function(){if(C.support.transitions){if("undefined"!=typeof _)return!1;if(!b.autoplay)return;C.callPlugins("onAutoplayStart"),z()}else{if("undefined"!=typeof ab)return!1;if(!b.autoplay)return;C.callPlugins("onAutoplayStart"),ab=setInterval(function(){b.loop?(C.fixLoop(),C.swipeNext(!0)):C.swipeNext(!0)||(b.autoplayStopOnLast?(clearInterval(ab),ab=void 0):C.swipeTo(0))},b.autoplay)}},C.stopAutoplay=function(a){if(C.support.transitions){if(!_)return;_&&clearTimeout(_),_=void 0,a&&!b.autoplayDisableOnInteraction&&C.wrapperTransitionEnd(function(){z()}),C.callPlugins("onAutoplayStop")}else ab&&clearInterval(ab),ab=void 0,C.callPlugins("onAutoplayStop")},C.loopCreated=!1,C.removeLoopedSlides=function(){if(C.loopCreated)for(var a=0;aC.slides.length&&(C.loopedSlides=C.slides.length);var a,c="",d="",e="",f=C.slides.length,g=Math.floor(C.loopedSlides/f),h=C.loopedSlides%f;for(a=0;g*f>a;a++){var i=a;if(a>=f){var j=Math.floor(a/f);i=a-f*j}e+=C.slides[i].outerHTML}for(a=0;h>a;a++)d+=t(b.slideDuplicateClass,C.slides[a].outerHTML);for(a=f-h;f>a;a++)c+=t(b.slideDuplicateClass,C.slides[a].outerHTML);var k=c+e+D.innerHTML+e+d;for(D.innerHTML=k,C.loopCreated=!0,C.calcSlides(),a=0;a=C.slides.length-C.loopedSlides)&&C.slides[a].setData("looped",!0);C.callPlugins("onCreateLoop")}},C.fixLoop=function(){var a;C.activeIndex=2*C.loopedSlides||C.activeIndex>C.slides.length-2*b.slidesPerView)&&(a=-C.slides.length+C.activeIndex+C.loopedSlides,C.swipeTo(a,0,!1))},C.loadSlides=function(){var a="";C.activeLoaderIndex=0;for(var c=b.loader.slides,d=b.loader.loadAllSlides?c.length:b.slidesPerView*(1+b.loader.surroundGroups),e=0;d>e;e++)a+="outer"===b.loader.slidesHTMLType?c[e]:"<"+b.slideElement+' class="'+b.slideClass+'" data-swiperindex="'+e+'">'+c[e]+"";C.wrapper.innerHTML=a,C.calcSlides(!0),b.loader.loadAllSlides||C.wrapperTransitionEnd(C.reloadSlides,!0)},C.reloadSlides=function(){var a=b.loader.slides,c=parseInt(C.activeSlide().data("swiperindex"),10);if(!(0>c||c>a.length-1)){C.activeLoaderIndex=c;var d=Math.max(0,c-b.slidesPerView*b.loader.surroundGroups),e=Math.min(c+b.slidesPerView*(1+b.loader.surroundGroups)-1,a.length-1);if(c>0){var f=-E*(c-d);C.setWrapperTranslate(f),C.setWrapperTransition(0)}var g;if("reload"===b.loader.logic){C.wrapper.innerHTML="";var h="";for(g=d;e>=g;g++)h+="outer"===b.loader.slidesHTMLType?a[g]:"<"+b.slideElement+' class="'+b.slideClass+'" data-swiperindex="'+g+'">'+a[g]+"";C.wrapper.innerHTML=h}else{var i=1e3,j=0;for(g=0;gk||k>e?C.wrapper.removeChild(C.slides[g]):(i=Math.min(k,i),j=Math.max(k,j))}for(g=d;e>=g;g++){var l;i>g&&(l=document.createElement(b.slideElement),l.className=b.slideClass,l.setAttribute("data-swiperindex",g),l.innerHTML=a[g],C.wrapper.insertBefore(l,C.wrapper.firstChild)),g>j&&(l=document.createElement(b.slideElement),l.className=b.slideClass,l.setAttribute("data-swiperindex",g),l.innerHTML=a[g],C.wrapper.appendChild(l))}}C.reInit(!0)}},A()}};Swiper.prototype={plugins:{},wrapperTransitionEnd:function(a,b){"use strict";function c(){if(a(e),e.params.queueEndCallbacks&&(e._queueEndCallbacks=!1),!b)for(d=0;d0)&&(d=a.offsetWidth-parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-left"))-parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-right"))),b&&(d+=parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-left"))+parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-right"))),d},getHeight:function(a,b){"use strict";if(b)return a.offsetHeight;var c=window.getComputedStyle(a,null).getPropertyValue("height"),d=parseFloat(c);return(isNaN(d)||c.indexOf("%")>0)&&(d=a.offsetHeight-parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-top"))-parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-bottom"))),b&&(d+=parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-top"))+parseFloat(window.getComputedStyle(a,null).getPropertyValue("padding-bottom"))),d},getOffset:function(a){"use strict";var b=a.getBoundingClientRect(),c=document.body,d=a.clientTop||c.clientTop||0,e=a.clientLeft||c.clientLeft||0,f=window.pageYOffset||a.scrollTop,g=window.pageXOffset||a.scrollLeft;return document.documentElement&&!window.pageYOffset&&(f=document.documentElement.scrollTop,g=document.documentElement.scrollLeft),{top:b.top+f-d,left:b.left+g-e}},windowWidth:function(){"use strict";return window.innerWidth?window.innerWidth:document.documentElement&&document.documentElement.clientWidth?document.documentElement.clientWidth:void 0},windowHeight:function(){"use strict";return window.innerHeight?window.innerHeight:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientHeight:void 0},windowScroll:function(){"use strict";return"undefined"!=typeof pageYOffset?{left:window.pageXOffset,top:window.pageYOffset}:document.documentElement?{left:document.documentElement.scrollLeft,top:document.documentElement.scrollTop}:void 0},addEventListener:function(a,b,c,d){"use strict";"undefined"==typeof d&&(d=!1),a.addEventListener?a.addEventListener(b,c,d):a.attachEvent&&a.attachEvent("on"+b,c)},removeEventListener:function(a,b,c,d){"use strict";"undefined"==typeof d&&(d=!1),a.removeEventListener?a.removeEventListener(b,c,d):a.detachEvent&&a.detachEvent("on"+b,c)}},setTransform:function(a,b){"use strict";var c=a.style;c.webkitTransform=c.MsTransform=c.msTransform=c.MozTransform=c.OTransform=c.transform=b},setTranslate:function(a,b){"use strict";var c=a.style,d={x:b.x||0,y:b.y||0,z:b.z||0},e=this.support.transforms3d?"translate3d("+d.x+"px,"+d.y+"px,"+d.z+"px)":"translate("+d.x+"px,"+d.y+"px)";c.webkitTransform=c.MsTransform=c.msTransform=c.MozTransform=c.OTransform=c.transform=e,this.support.transforms||(c.left=d.x+"px",c.top=d.y+"px")},setTransition:function(a,b){"use strict";var c=a.style;c.webkitTransitionDuration=c.MsTransitionDuration=c.msTransitionDuration=c.MozTransitionDuration=c.OTransitionDuration=c.transitionDuration=b+"ms"},support:{touch:window.Modernizr&&Modernizr.touch===!0||function(){"use strict";return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)}(),transforms3d:window.Modernizr&&Modernizr.csstransforms3d===!0||function(){"use strict";var a=document.createElement("div").style;return"webkitPerspective"in a||"MozPerspective"in a||"OPerspective"in a||"MsPerspective"in a||"perspective"in a}(),transforms:window.Modernizr&&Modernizr.csstransforms===!0||function(){"use strict";var a=document.createElement("div").style;return"transform"in a||"WebkitTransform"in a||"MozTransform"in a||"msTransform"in a||"MsTransform"in a||"OTransform"in a}(),transitions:window.Modernizr&&Modernizr.csstransitions===!0||function(){"use strict";var a=document.createElement("div").style;return"transition"in a||"WebkitTransition"in a||"MozTransition"in a||"msTransition"in a||"MsTransition"in a||"OTransition"in a}()},browser:{ie8:function(){"use strict";var a=-1;if("Microsoft Internet Explorer"===navigator.appName){var b=navigator.userAgent,c=new RegExp(/MSIE ([0-9]{1,}[\.0-9]{0,})/);null!==c.exec(b)&&(a=parseFloat(RegExp.$1))}return-1!==a&&9>a}(),ie10:window.navigator.msPointerEnabled,ie11:window.navigator.pointerEnabled}},(window.jQuery||window.Zepto)&&!function(a){"use strict";a.fn.swiper=function(b){var c=new Swiper(a(this)[0],b);return a(this).data("swiper",c),c}}(window.jQuery||window.Zepto),"undefined"!=typeof module&&(module.exports=Swiper),"function"==typeof define&&define.amd&&define([],function(){"use strict";return Swiper}); \ No newline at end of file diff --git a/package.json b/package.json index c5259ad01..b11732921 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Swiper", - "version": "2.4.3", + "version": "2.5.0", "description": "Mobile touch slider and framework with hardware accelerated transitions", "main": "dist/idangerous.swiper.js", "repository": {