PageSourceSearch

https://www.zampiva.it/wp-content/themes/grecko/js/swiper/idangerous.swiper-2.6.js

js zampiva.it collected 2026-10-04 01:57:22 UTC 112,926 bytes, 2,806 lines download raw bytes

1/*
2 * Swiper 2.6.1
3 * Mobile touch slider and framework with hardware accelerated transitions
4 *
5 * http://www.idangero.us/sliders/swiper/
6 *
7 * Copyright 2010-2014, Vladimir Kharlampidi
8 * The iDangero.us
9 * http://www.idangero.us/
10 *
11 * Licensed under GPL & MIT
12 *
13 * Released on: May 6, 2014
14*/
15var Swiper = function (selector, params) {
16    'use strict';
17
18    /*=========================
19      A little bit dirty but required part for IE8 and old FF support
20      ===========================*/
21    if (document.body.__defineGetter__) {
22        if (HTMLElement) {
23            var element = HTMLElement.prototype;
24            if (element.__defineGetter__) {
25                element.__defineGetter__('outerHTML', function () { return new XMLSerializer().serializeToString(this); });
26            }
27        }
28    }
29
30    if (!window.getComputedStyle) {
31        window.getComputedStyle = function (el, pseudo) {
32            this.el = el;
33            this.getPropertyValue = function (prop) {
34                var re = /(\-([a-z]){1})/g;
35                if (prop === 'float') prop = 'styleFloat';
36                if (re.test(prop)) {
37                    prop = prop.replace(re, function () {
38                        return arguments[2].toUpperCase();
39                    });
40                }
41                return el.currentStyle[prop] ? el.currentStyle[prop] : null;
42            };
43            return this;
44        };
45    }
46    if (!Array.prototype.indexOf) {
47        Array.prototype.indexOf = function (obj, start) {
48            for (var i = (start || 0), j = this.length; i < j; i++) {
49                if (this[i] === obj) { return i; }
50            }
51            return -1;
52        };
53    }
54    if (!document.querySelectorAll) {
55        if (!window.jQuery) return;
56    }
57    function $$(selector, context) {
58        if (document.querySelectorAll)
59            return (context || document).querySelectorAll(selector);
60        else
61            return jQuery(selector, context);
62    }
63
64    /*=========================
65      Check for correct selector
66      ===========================*/
67    if (typeof selector === 'undefined') return;
68
69    if (!(selector.nodeType)) {
70        if ($$(selector).length === 0) return;
71    }
72
73     /*=========================
74      _this
75      ===========================*/
76    var _this = this;
77
78     /*=========================
79      Default Flags and vars
80      ===========================*/
81    _this.touches = {
82        start: 0,
83        startX: 0,
84        startY: 0,
85        current: 0,
86        currentX: 0,
87        currentY: 0,
88        diff: 0,
89        abs: 0
90    };
91    _this.positions = {
92        start: 0,
93        abs: 0,
94        diff: 0,
95        current: 0
96    };
97    _this.times = {
98        start: 0,
99        end: 0
100    };
101
102    _this.id = (new Date()).getTime();
103    _this.container = (selector.nodeType) ? selector : $$(selector)[0];
104    _this.isTouched = false;
105    _this.isMoved = false;
106    _this.activeIndex = 0;
107    _this.centerIndex = 0;
108    _this.activeLoaderIndex = 0;
109    _this.activeLoopIndex = 0;
110    _this.previousIndex = null;
111    _this.velocity = 0;
112    _this.snapGrid = [];
113    _this.slidesGrid = [];
114    _this.imagesToLoad = [];
115    _this.imagesLoaded = 0;
116    _this.wrapperLeft = 0;
117    _this.wrapperRight = 0;
118    _this.wrapperTop = 0;
119    _this.wrapperBottom = 0;
120    _this.isAndroid = navigator.userAgent.toLowerCase().indexOf('android') >= 0;
121    var wrapper, slideSize, wrapperSize, direction, isScrolling, containerSize;
122
123    /*=========================
124      Default Parameters
125      ===========================*/
126    var defaults = {
127        eventTarget: 'wrapper', // or 'container'
128        mode : 'horizontal', // or 'vertical'
129        touchRatio : 1,
130        speed : 300,
131        freeMode : false,
132        freeModeFluid : false,
133        momentumRatio: 1,
134        momentumBounce: true,
135        momentumBounceRatio: 1,
136        slidesPerView : 1,
137        slidesPerGroup : 1,
138        slidesPerViewFit: true, //Fit to slide when spv "auto" and slides larger than container
139        simulateTouch : true,
140        followFinger : true,
141        shortSwipes : true,
142        longSwipesRatio: 0.5,
143        moveStartThreshold: false,
144        onlyExternal : false,
145        createPagination : true,
146        pagination : false,
147        paginationElement: 'span',
148        paginationClickable: false,
149        paginationAsRange: true,
150        resistance : true, // or false or 100%
151        scrollContainer : false,
152        preventLinks : true,
153        preventLinksPropagation: false,
154        noSwiping : false, // or class
155        noSwipingClass : 'swiper-no-swiping', //:)
156        initialSlide: 0,
157        keyboardControl: false,
158        mousewheelControl : false,
159        mousewheelControlForceToAxis : false,
160        mousewheelAccelerator: 1,		// Accelerator for FireFox 4+ by ThemeREX
161        useCSS3Transforms : true,
162        // Autoplay
163        autoplay: false,
164        autoplayDisableOnInteraction: true,
165        autoplayStopOnLast: false,
166        //Loop mode
167        loop: false,
168        loopAdditionalSlides: 0,
169        // Round length values
170        roundLengths: false,
171        //Auto Height
172        calculateHeight: false,
173        cssWidthAndHeight: false,
174        //Images Preloader
175        updateOnImagesReady : true,
176        //Form elements
177        releaseFormElements : true,
178        //Watch for active slide, useful when use effects on different slide states
179        watchActiveIndex: false,
180        //Slides Visibility Fit
181        visibilityFullFit : false,
182        //Slides Offset
183        offsetPxBefore : 0,
184        offsetPxAfter : 0,
185        offsetSlidesBefore : 0,
186        offsetSlidesAfter : 0,
187        centeredSlides: false,
188        //Queue callbacks
189        queueStartCallbacks : false,
190        queueEndCallbacks : false,
191        //Auto Resize
192        autoResize : true,
193        resizeReInit : false,
194        //DOMAnimation
195        DOMAnimation : true,
196        //Slides Loader
197        loader: {
198            slides: [], //array with slides
199            slidesHTMLType: 'inner', // or 'outer'
200            surroundGroups: 1, //keep preloaded slides groups around view
201            logic: 'reload', //or 'change'
202            loadAllSlides: false
203        },
204        //Namespace
205        slideElement: 'div',
206        slideClass: 'swiper-slide',
207        slideActiveClass: 'swiper-slide-active',
208        slideVisibleClass: 'swiper-slide-visible',
209        slideDuplicateClass: 'swiper-slide-duplicate',
210        wrapperClass: 'swiper-wrapper',
211        paginationElementClass: 'swiper-pagination-switch',
212        paginationActiveClass: 'swiper-active-switch',
213        paginationVisibleClass: 'swiper-visible-switch'
214    };
215    params = params || {};
216    for (var prop in defaults) {
217        if (prop in params && typeof params[prop] === 'object') {
218            for (var subProp in defaults[prop]) {
219                if (! (subProp in params[prop])) {
220                    params[prop][subProp] = defaults[prop][subProp];
221                }
222            }
223        }
224        else if (! (prop in params)) {
225            params[prop] = defaults[prop];
226        }
227    }
228    _this.params = params;
229    if (params.scrollContainer) {
230        params.freeMode = true;
231        params.freeModeFluid = true;
232    }
233    if (params.loop) {
234        params.resistance = '100%';
235    }
236    var isH = params.mode === 'horizontal';
237
238    /*=========================
239      Define Touch Events
240      ===========================*/
241    var desktopEvents = ['mousedown', 'mousemove', 'mouseup'];
242    if (_this.browser.ie10) desktopEvents = ['MSPointerDown', 'MSPointerMove', 'MSPointerUp'];
243    if (_this.browser.ie11) desktopEvents = ['pointerdown', 'pointermove', 'pointerup'];
244
245    _this.touchEvents = {
246        touchStart : _this.support.touch || !params.simulateTouch  ? 'touchstart' : desktopEvents[0],
247        touchMove : _this.support.touch || !params.simulateTouch ? 'touchmove' : desktopEvents[1],
248        touchEnd : _this.support.touch || !params.simulateTouch ? 'touchend' : desktopEvents[2]
249    };
250
251    /*=========================
252      Wrapper
253      ===========================*/
254    for (var i = _this.container.childNodes.length - 1; i >= 0; i--) {
255        if (_this.container.childNodes[i].className) {
256            var _wrapperClasses = _this.container.childNodes[i].className.split(/\s+/);
257            for (var j = 0; j < _wrapperClasses.length; j++) {
258                if (_wrapperClasses[j] === params.wrapperClass) {
259                    wrapper = _this.container.childNodes[i];
260                }
261            }
262        }
263    }
264
265    _this.wrapper = wrapper;
266    /*=========================
267      Slide API
268      ===========================*/
269    _this._extendSwiperSlide = function  (el) {
270        el.append = function () {
271            if (params.loop) {
272                el.insertAfter(_this.slides.length - _this.loopedSlides);
273            }
274            else {
275                _this.wrapper.appendChild(el);
276                _this.reInit();
277            }
278
279            return el;
280        };
281        el.prepend = function () {
282            if (params.loop) {
283                _this.wrapper.insertBefore(el, _this.slides[_this.loopedSlides]);
284                _this.removeLoopedSlides();
285                _this.calcSlides();
286                _this.createLoop();
287            }
288            else {
289                _this.wrapper.insertBefore(el, _this.wrapper.firstChild);
290            }
291            _this.reInit();
292            return el;
293        };
294        el.insertAfter = function (index) {
295            if (typeof index === 'undefined') return false;
296            var beforeSlide;
297
298            if (params.loop) {
299                beforeSlide = _this.slides[index + 1 + _this.loopedSlides];
300                if (beforeSlide) {
301                    _this.wrapper.insertBefore(el, beforeSlide);
302                }
303                else {
304                    _this.wrapper.appendChild(el);
305                }
306                _this.removeLoopedSlides();
307                _this.calcSlides();
308                _this.createLoop();
309            }
310            else {
311                beforeSlide = _this.slides[index + 1];
312                _this.wrapper.insertBefore(el, beforeSlide);
313            }
314            _this.reInit();
315            return el;
316        };
317        el.clone = function () {
318            return _this._extendSwiperSlide(el.cloneNode(true));
319        };
320        el.remove = function () {
321            _this.wrapper.removeChild(el);
322            _this.reInit();
323        };
324        el.html = function (html) {
325            if (typeof html === 'undefined') {
326                return el.innerHTML;
327            }
328            else {
329                el.innerHTML = html;
330                return el;
331            }
332        };
333        el.index = function () {
334            var index;
335            for (var i = _this.slides.length - 1; i >= 0; i--) {
336                if (el === _this.slides[i]) index = i;
337            }
338            return index;
339        };
340        el.isActive = function () {
341            if (el.index() === _this.activeIndex) return true;
342            else return false;
343        };
344        if (!el.swiperSlideDataStorage) el.swiperSlideDataStorage = {};
345        el.getData = function (name) {
346            return el.swiperSlideDataStorage[name];
347        };
348        el.setData = function (name, value) {
349            el.swiperSlideDataStorage[name] = value;
350            return el;
351        };
352        el.data = function (name, value) {
353            if (typeof value === 'undefined') {
354                return el.getAttribute('data-' + name);
355            }
356            else {
357                el.setAttribute('data-' + name, value);
358                return el;
359            }
360        };
361        el.getWidth = function (outer, round) {
362            return _this.h.getWidth(el, outer, round);
363        };
364        el.getHeight = function (outer, round) {
365            return _this.h.getHeight(el, outer, round);
366        };
367        el.getOffset = function () {
368            return _this.h.getOffset(el);
369        };
370        return el;
371    };
372
373    //Calculate information about number of slides
374    _this.calcSlides = function (forceCalcSlides) {
375        var oldNumber = _this.slides ? _this.slides.length : false;
376        _this.slides = [];
377        _this.displaySlides = [];
378        for (var i = 0; i < _this.wrapper.childNodes.length; i++) {
379            if (_this.wrapper.childNodes[i].className) {
380                var _className = _this.wrapper.childNodes[i].className;
381                var _slideClasses = _className.split(/\s+/);
382                for (var j = 0; j < _slideClasses.length; j++) {
383                    if (_slideClasses[j] === params.slideClass) {
384                        _this.slides.push(_this.wrapper.childNodes[i]);
385                    }
386                }
387            }
388        }
389        for (i = _this.slides.length - 1; i >= 0; i--) {
390            _this._extendSwiperSlide(_this.slides[i]);
391        }
392        if (oldNumber === false) return;
393        if (oldNumber !== _this.slides.length || forceCalcSlides) {
394
395            // Number of slides has been changed
396            removeSlideEvents();
397            addSlideEvents();
398            _this.updateActiveSlide();
399            if (_this.params.pagination) _this.createPagination();
400            _this.callPlugins('numberOfSlidesChanged');
401        }
402    };
403
404    //Create Slide
405    _this.createSlide = function (html, slideClassList, el) {
406        slideClassList = slideClassList || _this.params.slideClass;
407        el = el || params.slideElement;
408        var newSlide = document.createElement(el);
409        newSlide.innerHTML = html || '';
410        newSlide.className = slideClassList;
411        return _this._extendSwiperSlide(newSlide);
412    };
413
414    //Append Slide
415    _this.appendSlide = function (html, slideClassList, el) {
416        if (!html) return;
417        if (html.nodeType) {
418            return _this._extendSwiperSlide(html).append();
419        }
420        else {
421            return _this.createSlide(html, slideClassList, el).append();
422        }
423    };
424    _this.prependSlide = function (html, slideClassList, el) {
425        if (!html) return;
426        if (html.nodeType) {
427            return _this._extendSwiperSlide(html).prepend();
428        }
429        else {
430            return _this.createSlide(html, slideClassList, el).prepend();
431        }
432    };
433    _this.insertSlideAfter = function (index, html, slideClassList, el) {
434        if (typeof index === 'undefined') return false;
435        if (html.nodeType) {
436            return _this._extendSwiperSlide(html).insertAfter(index);
437        }
438        else {
439            return _this.createSlide(html, slideClassList, el).insertAfter(index);
440        }
441    };
442    _this.removeSlide = function (index) {
443        if (_this.slides[index]) {
444            if (params.loop) {
445                if (!_this.slides[index + _this.loopedSlides]) return false;
446                _this.slides[index + _this.loopedSlides].remove();
447                _this.removeLoopedSlides();
448                _this.calcSlides();
449                _this.createLoop();
450            }
451            else _this.slides[index].remove();
452            return true;
453        }
454        else return false;
455    };
456    _this.removeLastSlide = function () {
457        if (_this.slides.length > 0) {
458            if (params.loop) {
459                _this.slides[_this.slides.length - 1 - _this.loopedSlides].remove();
460                _this.removeLoopedSlides();
461                _this.calcSlides();
462                _this.createLoop();
463            }
464            else _this.slides[_this.slides.length - 1].remove();
465            return true;
466        }
467        else {
468            return false;
469        }
470    };
471    _this.removeAllSlides = function () {
472        for (var i = _this.slides.length - 1; i >= 0; i--) {
473            _this.slides[i].remove();
474        }
475    };
476    _this.getSlide = function (index) {
477        return _this.slides[index];
478    };
479    _this.getLastSlide = function () {
480        return _this.slides[_this.slides.length - 1];
481    };
482    _this.getFirstSlide = function () {
483        return _this.slides[0];
484    };
485
486    //Currently Active Slide
487    _this.activeSlide = function () {
488        return _this.slides[_this.activeIndex];
489    };
490
491    /*=========================
492     Wrapper for Callbacks : Allows additive callbacks via function arrays
493     ===========================*/
494    _this.fireCallback = function () {
495        var callback = arguments[0];
496        if (Object.prototype.toString.call(callback) === '[object Array]') {
497            for (var i = 0; i < callback.length; i++) {
498                if (typeof callback[i] === 'function') {
499                    callback[i](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
500                }
501            }
502        } else if (Object.prototype.toString.call(callback) === '[object String]') {
503            if (params['on' + callback]) _this.fireCallback(params['on' + callback], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
504        } else {
505            callback(arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
506        }
507    };
508    function isArray(obj) {
509        if (Object.prototype.toString.apply(obj) === '[object Array]') return true;
510        return false;
511    }
512
513    /**
514     * Allows user to add callbacks, rather than replace them
515     * @param callback
516     * @param func
517     * @return {*}
518     */
519    _this.addCallback = function (callback, func) {
520        var _this = this, tempFunc;
521        if (_this.params['on' + callback]) {
522            if (isArray(this.params['on' + callback])) {
523                return this.params['on' + callback].push(func);
524            } else if (typeof this.params['on' + callback] === 'function') {
525                tempFunc = this.params['on' + callback];
526                this.params['on' + callback] = [];
527                this.params['on' + callback].push(tempFunc);
528                return this.params['on' + callback].push(func);
529            }
530        } else {
531            this.params['on' + callback] = [];
532            return this.params['on' + callback].push(func);
533        }
534    };
535    _this.removeCallbacks = function (callback) {
536        if (_this.params['on' + callback]) {
537            _this.params['on' + callback] = null;
538        }
539    };
540
541    /*=========================
542      Plugins API
543      ===========================*/
544    var _plugins = [];
545    for (var plugin in _this.plugins) {
546        if (params[plugin]) {
547            var p = _this.plugins[plugin](_this, params[plugin]);
548            if (p) _plugins.push(p);
549        }
550    }
551    _this.callPlugins = function (method, args) {
552        if (!args) args = {};
553        for (var i = 0; i < _plugins.length; i++) {
554            if (method in _plugins[i]) {
555                _plugins[i][method](args);
556            }
557        }
558    };
559
560    /*=========================
561      Windows Phone 8 Fix
562      ===========================*/
563    if ((_this.browser.ie10 || _this.browser.ie11) && !params.onlyExternal) {
564        _this.wrapper.classList.add('swiper-wp8-' + (isH ? 'horizontal' : 'vertical'));
565    }
566
567    /*=========================
568      Free Mode Class
569      ===========================*/
570    if (params.freeMode) {
571        _this.container.className += ' swiper-free-mode';
572    }
573
574    /*==================================================
575        Init/Re-init/Resize Fix
576    ====================================================*/
577    _this.initialized = false;
578    _this.init = function (force, forceCalcSlides) {
579        var _width = _this.h.getWidth(_this.container, false, params.roundLengths);
580        var _height = _this.h.getHeight(_this.container, false, params.roundLengths);
581        if (_width === _this.width && _height === _this.height && !force) return;
582        
583        _this.width = _width;
584        _this.height = _height;
585
586        var slideWidth, slideHeight, slideMaxHeight, wrapperWidth, wrapperHeight, slideLeft;
587        var i; // loop index variable to avoid JSHint W004 / W038
588        containerSize = isH ? _width : _height;
589        var wrapper = _this.wrapper;
590
591        if (force) {
592            _this.calcSlides(forceCalcSlides);
593        }
594
595        if (params.slidesPerView === 'auto') {
596            //Auto mode
597            var slidesWidth = 0;
598            var slidesHeight = 0;
599
600            //Unset Styles
601            if (params.slidesOffset > 0) {
602                wrapper.style.paddingLeft = '';
603                wrapper.style.paddingRight = '';
604                wrapper.style.paddingTop = '';
605                wrapper.style.paddingBottom = '';
606            }
607            wrapper.style.width = '';
608            wrapper.style.height = '';
609            if (params.offsetPxBefore > 0) {
610                if (isH) _this.wrapperLeft = params.offsetPxBefore;
611                else _this.wrapperTop = params.offsetPxBefore;
612            }
613            if (params.offsetPxAfter > 0) {
614                if (isH) _this.wrapperRight = params.offsetPxAfter;
615                else _this.wrapperBottom = params.offsetPxAfter;
616            }
617
618            if (params.centeredSlides) {
619                if (isH) {
620                    _this.wrapperLeft = (containerSize - this.slides[0].getWidth(true, params.roundLengths)) / 2;
621                    _this.wrapperRight = (containerSize - _this.slides[_this.slides.length - 1].getWidth(true, params.roundLengths)) / 2;
622                }
623                else {
624                    _this.wrapperTop = (containerSize - _this.slides[0].getHeight(true, params.roundLengths)) / 2;
625                    _this.wrapperBottom = (containerSize - _this.slides[_this.slides.length - 1].getHeight(true, params.roundLengths)) / 2;
626                }
627            }
628
629            if (isH) {
630                if (_this.wrapperLeft >= 0) wrapper.style.paddingLeft = _this.wrapperLeft + 'px';
631                if (_this.wrapperRight >= 0) wrapper.style.paddingRight = _this.wrapperRight + 'px';
632            }
633            else {
634                if (_this.wrapperTop >= 0) wrapper.style.paddingTop = _this.wrapperTop + 'px';
635                if (_this.wrapperBottom >= 0) wrapper.style.paddingBottom = _this.wrapperBottom + 'px';
636            }
637            slideLeft = 0;
638            var centeredSlideLeft = 0;
639            _this.snapGrid = [];
640            _this.slidesGrid = [];
641
642            slideMaxHeight = 0;
643            for (i = 0; i < _this.slides.length; i++) {
644                slideWidth = _this.slides[i].getWidth(true, params.roundLengths);
645                slideHeight = _this.slides[i].getHeight(true, params.roundLengths);
646                if (params.calculateHeight) {
647                    slideMaxHeight = Math.max(slideMaxHeight, slideHeight);
648                }
649                var _slideSize = isH ? slideWidth : slideHeight;
650                if (params.centeredSlides) {
651                    var nextSlideWidth = i === _this.slides.length - 1 ? 0 : _this.slides[i + 1].getWidth(true, params.roundLengths);
652                    var nextSlideHeight = i === _this.slides.length - 1 ? 0 : _this.slides[i + 1].getHeight(true, params.roundLengths);
653                    var nextSlideSize = isH ? nextSlideWidth : nextSlideHeight;
654                    if (_slideSize > containerSize) {
655                        if (params.slidesPerViewFit) {
656                            _this.snapGrid.push(slideLeft + _this.wrapperLeft);
657                            _this.snapGrid.push(slideLeft + _slideSize - containerSize + _this.wrapperLeft);
658                        }
659                        else {
660                            for (var j = 0; j <= Math.floor(_slideSize / (containerSize + _this.wrapperLeft)); j++) {
661                                if (j === 0) _this.snapGrid.push(slideLeft + _this.wrapperLeft);
662                                else _this.snapGrid.push(slideLeft + _this.wrapperLeft + containerSize * j);
663                            }
664                        }
665                        _this.slidesGrid.push(slideLeft + _this.wrapperLeft);
666                    }
667                    else {
668                        _this.snapGrid.push(centeredSlideLeft);
669                        _this.slidesGrid.push(centeredSlideLeft);
670                    }
671                    centeredSlideLeft += _slideSize / 2 + nextSlideSize / 2;
672                }
673                else {
674                    if (_slideSize > containerSize) {
675                        if (params.slidesPerViewFit) {
676                            _this.snapGrid.push(slideLeft);
677                            _this.snapGrid.push(slideLeft + _slideSize - containerSize);
678                        }
679                        else {
680                            if (containerSize !== 0) {
681                                for (var k = 0; k <= Math.floor(_slideSize / containerSize); k++) {
682                                    _this.snapGrid.push(slideLeft + containerSize * k);
683                                }
684                            }
685                            else {
686                                _this.snapGrid.push(slideLeft);
687                            }
688                        }
689                            
690                    }
691                    else {
692                        _this.snapGrid.push(slideLeft);
693                    }
694                    _this.slidesGrid.push(slideLeft);
695                }
696
697                slideLeft += _slideSize;
698
699                slidesWidth += slideWidth;
700                slidesHeight += slideHeight;
701            }
702            if (params.calculateHeight) _this.height = slideMaxHeight;
703            if (isH) {
704                wrapperSize = slidesWidth + _this.wrapperRight + _this.wrapperLeft;
705                wrapper.style.width = (slidesWidth) + 'px';
706                wrapper.style.height = (_this.height) + 'px';
707            }
708            else {
709                wrapperSize = slidesHeight + _this.wrapperTop + _this.wrapperBottom;
710                wrapper.style.width = (_this.width) + 'px';
711                wrapper.style.height = (slidesHeight) + 'px';
712            }
713
714        }
715        else if (params.scrollContainer) {
716            //Scroll Container
717            wrapper.style.width = '';
718            wrapper.style.height = '';
719            wrapperWidth = _this.slides[0].getWidth(true, params.roundLengths);
720            wrapperHeight = _this.slides[0].getHeight(true, params.roundLengths);
721            wrapperSize = isH ? wrapperWidth : wrapperHeight;
722            wrapper.style.width = wrapperWidth + 'px';
723            wrapper.style.height = wrapperHeight + 'px';
724            slideSize = isH ? wrapperWidth : wrapperHeight;
725
726        }
727        else {
728            //For usual slides
729            if (params.calculateHeight) {
730                slideMaxHeight = 0;
731                wrapperHeight = 0;
732                //ResetWrapperSize
733                if (!isH) _this.container.style.height = '';
734                wrapper.style.height = '';
735
736                for (i = 0; i < _this.slides.length; i++) {
737                    //ResetSlideSize
738                    _this.slides[i].style.height = '';
739                    slideMaxHeight = Math.max(_this.slides[i].getHeight(true), slideMaxHeight);
740                    if (!isH) wrapperHeight += _this.slides[i].getHeight(true);
741                }
742                slideHeight = slideMaxHeight;
743                _this.height = slideHeight;
744
745                if (isH) wrapperHeight = slideHeight;
746                else {
747                    containerSize = slideHeight;
748                    _this.container.style.height = containerSize + 'px';
749                }
750            }
751            else {
752                slideHeight = isH ? _this.height : _this.height / params.slidesPerView;
753                if (params.roundLengths) slideHeight = Math.round(slideHeight);
754                wrapperHeight = isH ? _this.height : _this.slides.length * slideHeight;
755            }
756            slideWidth = isH ? _this.width / params.slidesPerView : _this.width;
757            if (params.roundLengths) slideWidth = Math.round(slideWidth);
758            wrapperWidth = isH ? _this.slides.length * slideWidth : _this.width;
759            slideSize = isH ? slideWidth : slideHeight;
760
761            if (params.offsetSlidesBefore > 0) {
762                if (isH) _this.wrapperLeft = slideSize * params.offsetSlidesBefore;
763                else _this.wrapperTop = slideSize * params.offsetSlidesBefore;
764            }
765            if (params.offsetSlidesAfter > 0) {
766                if (isH) _this.wrapperRight = slideSize * params.offsetSlidesAfter;
767                else _this.wrapperBottom = slideSize * params.offsetSlidesAfter;
768            }
769            if (params.offsetPxBefore > 0) {
770                if (isH) _this.wrapperLeft = params.offsetPxBefore;
771                else _this.wrapperTop = params.offsetPxBefore;
772            }
773            if (params.offsetPxAfter > 0) {
774                if (isH) _this.wrapperRight = params.offsetPxAfter;
775                else _this.wrapperBottom = params.offsetPxAfter;
776            }
777            if (params.centeredSlides) {
778                if (isH) {
779                    _this.wrapperLeft = (containerSize - slideSize) / 2;
780                    _this.wrapperRight = (containerSize - slideSize) / 2;
781                }
782                else {
783                    _this.wrapperTop = (containerSize - slideSize) / 2;
784                    _this.wrapperBottom = (containerSize - slideSize) / 2;
785                }
786            }
787            if (isH) {
788                if (_this.wrapperLeft > 0) wrapper.style.paddingLeft = _this.wrapperLeft + 'px';
789                if (_this.wrapperRight > 0) wrapper.style.paddingRight = _this.wrapperRight + 'px';
790            }
791            else {
792                if (_this.wrapperTop > 0) wrapper.style.paddingTop = _this.wrapperTop + 'px';
793                if (_this.wrapperBottom > 0) wrapper.style.paddingBottom = _this.wrapperBottom + 'px';
794            }
795
796            wrapperSize = isH ? wrapperWidth + _this.wrapperRight + _this.wrapperLeft : wrapperHeight + _this.wrapperTop + _this.wrapperBottom;
797            if (!params.cssWidthAndHeight) {
798                if (parseFloat(wrapperWidth) > 0) {
799                    wrapper.style.width = wrapperWidth + 'px';
800                }
801                if (parseFloat(wrapperHeight) > 0) {
802                    wrapper.style.height = wrapperHeight + 'px';
803                }
804            }
805            slideLeft = 0;
806            _this.snapGrid = [];
807            _this.slidesGrid = [];
808            for (i = 0; i < _this.slides.length; i++) {
809                _this.snapGrid.push(slideLeft);
810                _this.slidesGrid.push(slideLeft);
811                slideLeft += slideSize;
812                if (!params.cssWidthAndHeight) {
813                    if (parseFloat(slideWidth) > 0) {
814                        _this.slides[i].style.width = slideWidth + 'px';
815                    }
816                    if (parseFloat(slideHeight) > 0) {
817                        _this.slides[i].style.height = slideHeight + 'px';
818                    }
819                }
820            }
821
822        }
823
824        if (!_this.initialized) {
825            _this.callPlugins('onFirstInit');
826            if (params.onFirstInit) _this.fireCallback(params.onFirstInit, _this);
827        }
828        else {
829            _this.callPlugins('onInit');
830            if (params.onInit) _this.fireCallback(params.onInit, _this);
831        }
832        _this.initialized = true;
833    };
834
835    _this.reInit = function (forceCalcSlides) {
836        _this.init(true, forceCalcSlides);
837    };
838
839    _this.resizeFix = function (reInit) {
840        _this.callPlugins('beforeResizeFix');
841
842        _this.init(params.resizeReInit || reInit);
843
844        // swipe to active slide in fixed mode
845        if (!params.freeMode) {
846            _this.swipeTo((params.loop ? _this.activeLoopIndex : _this.activeIndex), 0, false);
847            // Fix autoplay
848            if (params.autoplay) {
849                if (_this.support.transitions && typeof autoplayTimeoutId !== 'undefined') {
850                    if (typeof autoplayTimeoutId !== 'undefined') {
851                        clearTimeout(autoplayTimeoutId);
852                        autoplayTimeoutId = undefined;
853                        _this.startAutoplay();
854                    }
855                }
856                else {
857                    if (typeof autoplayIntervalId !== 'undefined') {
858                        clearInterval(autoplayIntervalId);
859                        autoplayIntervalId = undefined;
860                        _this.startAutoplay();
861                    }
862                }
863            }
864        }
865        // move wrapper to the beginning in free mode
866        else if (_this.getWrapperTranslate() < -maxWrapperPosition()) {
867            _this.setWrapperTransition(0);
868            _this.setWrapperTranslate(-maxWrapperPosition());
869        }
870
871        _this.callPlugins('afterResizeFix');
872    };
873
874    /*==========================================
875        Max and Min Positions
876    ============================================*/
877    function maxWrapperPosition() {
878        var a = (wrapperSize - containerSize);
879        if (params.freeMode) {
880            a = wrapperSize - containerSize;
881        }
882        // if (params.loop) a -= containerSize;
883        if (params.slidesPerView > _this.slides.length && !params.centeredSlides) {
884            a = 0;
885        }
886        if (a < 0) a = 0;
887        return a;
888    }
889
890    /*==========================================
891        Event Listeners
892    ============================================*/
893    function initEvents() {
894        var bind = _this.h.addEventListener;
895        var eventTarget = params.eventTarget === 'wrapper' ? _this.wrapper : _this.container;
896        //Touch Events
897        if (! (_this.browser.ie10 || _this.browser.ie11)) {
898            if (_this.support.touch) {
899                bind(eventTarget, 'touchstart', onTouchStart);
900                bind(eventTarget, 'touchmove', onTouchMove);
901                bind(eventTarget, 'touchend', onTouchEnd);
902            }
903            if (params.simulateTouch) {
904                bind(eventTarget, 'mousedown', onTouchStart);
905                bind(document, 'mousemove', onTouchMove);
906                bind(document, 'mouseup', onTouchEnd);
907            }
908        }
909        else {
910            bind(eventTarget, _this.touchEvents.touchStart, onTouchStart);
911            bind(document, _this.touchEvents.touchMove, onTouchMove);
912            bind(document, _this.touchEvents.touchEnd, onTouchEnd);
913        }
914
915        //Resize Event
916        if (params.autoResize) {
917            bind(window, 'resize', _this.resizeFix);
918        }
919        //Slide Events
920        addSlideEvents();
921        //Mousewheel
922        _this._wheelEvent = false;
923        if (params.mousewheelControl) {
924            if (document.onmousewheel !== undefined) {
925                _this._wheelEvent = 'mousewheel';
926            }
927            if (!_this._wheelEvent) {
928                try {
929                    new WheelEvent('wheel');
930                    _this._wheelEvent = 'wheel';
931                } catch (e) {}
932            }
933            if (!_this._wheelEvent) {
934                _this._wheelEvent = 'DOMMouseScroll';
935            }
936            if (_this._wheelEvent) {
937                bind(_this.container, _this._wheelEvent, handleMousewheel);
938            }
939        }
940
941        //Keyboard
942        function _loadImage(src) {
943            var image = new Image();
944            image.onload = function () {
945                if (_this && _this.imagesLoaded !== undefined) _this.imagesLoaded++;
946                if (_this.imagesLoaded === _this.imagesToLoad.length) {
947                    _this.reInit();
948                    if (params.onImagesReady) _this.fireCallback(params.onImagesReady, _this);
949                }
950            };
951            image.src = src;
952        }
953
954        if (params.keyboardControl) {
955            bind(document, 'keydown', handleKeyboardKeys);
956        }
957        if (params.updateOnImagesReady) {
958            _this.imagesToLoad = $$('img', _this.container);
959
960            for (var i = 0; i < _this.imagesToLoad.length; i++) {
961                _loadImage(_this.imagesToLoad[i].getAttribute('src'));
962            }
963        }
964    }
965
966    //Remove Event Listeners
967    _this.destroy = function () {
968        var unbind = _this.h.removeEventListener;
969        var eventTarget = params.eventTarget === 'wrapper' ? _this.wrapper : _this.container;
970        //Touch Events
971        if (! (_this.browser.ie10 || _this.browser.ie11)) {
972            if (_this.support.touch) {
973                unbind(eventTarget, 'touchstart', onTouchStart);
974                unbind(eventTarget, 'touchmove', onTouchMove);
975                unbind(eventTarget, 'touchend', onTouchEnd);
976            }
977            if (params.simulateTouch) {
978                unbind(eventTarget, 'mousedown', onTouchStart);
979                unbind(document, 'mousemove', onTouchMove);
980                unbind(document, 'mouseup', onTouchEnd);
981            }
982        }
983        else {
984            unbind(eventTarget, _this.touchEvents.touchStart, onTouchStart);
985            unbind(document, _this.touchEvents.touchMove, onTouchMove);
986            unbind(document, _this.touchEvents.touchEnd, onTouchEnd);
987        }
988
989        //Resize Event
990        if (params.autoResize) {
991            unbind(window, 'resize', _this.resizeFix);
992        }
993
994        //Init Slide Events
995        removeSlideEvents();
996
997        //Pagination
998        if (params.paginationClickable) {
999            removePaginationEvents();
1000        }
1001
1002        //Mousewheel
1003        if (params.mousewheelControl && _this._wheelEvent) {
1004            unbind(_this.container, _this._wheelEvent, handleMousewheel);
1005        }
1006
1007        //Keyboard
1008        if (params.keyboardControl) {
1009            unbind(document, 'keydown', handleKeyboardKeys);
1010        }
1011
1012        //Stop autoplay
1013        if (params.autoplay) {
1014            _this.stopAutoplay();
1015        }
1016        _this.callPlugins('onDestroy');
1017
1018        //Destroy variable
1019        _this = null;
1020    };
1021
1022    function addSlideEvents() {
1023        var bind = _this.h.addEventListener,
1024            i;
1025
1026        //Prevent Links Events
1027        if (params.preventLinks) {
1028            var links = $$('a', _this.container);
1029            for (i = 0; i < links.length; i++) {
1030                bind(links[i], 'click', preventClick);
1031            }
1032        }
1033        //Release Form Elements
1034        if (params.releaseFormElements) {
1035            var formElements = $$('input, textarea, select', _this.container);
1036            for (i = 0; i < formElements.length; i++) {
1037                bind(formElements[i], _this.touchEvents.touchStart, releaseForms, true);
1038            }
1039        }
1040
1041        //Slide Clicks & Touches
1042        if (params.onSlideClick) {
1043            for (i = 0; i < _this.slides.length; i++) {
1044                bind(_this.slides[i], 'click', slideClick);
1045            }
1046        }
1047        if (params.onSlideTouch) {
1048            for (i = 0; i < _this.slides.length; i++) {
1049                bind(_this.slides[i], _this.touchEvents.touchStart, slideTouch);
1050            }
1051        }
1052    }
1053    function removeSlideEvents() {
1054        var unbind = _this.h.removeEventListener,
1055            i;
1056
1057        //Slide Clicks & Touches
1058        if (params.onSlideClick) {
1059            for (i = 0; i < _this.slides.length; i++) {
1060                unbind(_this.slides[i], 'click', slideClick);
1061            }
1062        }
1063        if (params.onSlideTouch) {
1064            for (i = 0; i < _this.slides.length; i++) {
1065                unbind(_this.slides[i], _this.touchEvents.touchStart, slideTouch);
1066            }
1067        }
1068        //Release Form Elements
1069        if (params.releaseFormElements) {
1070            var formElements = $$('input, textarea, select', _this.container);
1071            for (i = 0; i < formElements.length; i++) {
1072                unbind(formElements[i], _this.touchEvents.touchStart, releaseForms, true);
1073            }
1074        }
1075        //Prevent Links Events
1076        if (params.preventLinks) {
1077            var links = $$('a', _this.container);
1078            for (i = 0; i < links.length; i++) {
1079                unbind(links[i], 'click', preventClick);
1080            }
1081        }
1082    }
1083    /*==========================================
1084        Keyboard Control
1085    ============================================*/
1086    function handleKeyboardKeys(e) {
1087        var kc = e.keyCode || e.charCode;
1088        if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) return;
1089        if (kc === 37 || kc === 39 || kc === 38 || kc === 40) {
1090            var inView = false;
1091            //Check that swiper should be inside of visible area of window
1092            var swiperOffset = _this.h.getOffset(_this.container);
1093            var scrollLeft = _this.h.windowScroll().left;
1094            var scrollTop = _this.h.windowScroll().top;
1095            var windowWidth = _this.h.windowWidth();
1096            var windowHeight = _this.h.windowHeight();
1097            var swiperCoord = [
1098                [swiperOffset.left, swiperOffset.top],
1099                [swiperOffset.left + _this.width, swiperOffset.top],
1100                [swiperOffset.left, swiperOffset.top + _this.height],
1101                [swiperOffset.left + _this.width, swiperOffset.top + _this.height]
1102            ];
1103            for (var i = 0; i < swiperCoord.length; i++) {
1104                var point = swiperCoord[i];
1105                if (
1106                    point[0] >= scrollLeft && point[0] <= scrollLeft + windowWidth &&
1107                    point[1] >= scrollTop && point[1] <= scrollTop + windowHeight
1108                ) {
1109                    inView = true;
1110                }
1111
1112            }
1113            if (!inView) return;
1114        }
1115        if (isH) {
1116            if (kc === 37 || kc === 39) {
1117                if (e.preventDefault) e.preventDefault();
1118                else e.returnValue = false;
1119            }
1120            if (kc === 39) _this.swipeNext();
1121            if (kc === 37) _this.swipePrev();
1122        }
1123        else {
1124            if (kc === 38 || kc === 40) {
1125                if (e.preventDefault) e.preventDefault();
1126                else e.returnValue = false;
1127            }
1128            if (kc === 40) _this.swipeNext();
1129            if (kc === 38) _this.swipePrev();
1130        }
1131    }
1132
1133    _this.disableKeyboardControl = function () {
1134        params.keyboardControl = false;
1135        _this.h.removeEventListener(document, 'keydown', handleKeyboardKeys);
1136    };
1137
1138    _this.enableKeyboardControl = function () {
1139        params.keyboardControl = true;
1140        _this.h.addEventListener(document, 'keydown', handleKeyboardKeys);
1141    };
1142
1143    /*==========================================
1144        Mousewheel Control
1145    ============================================*/
1146    var lastScrollTime = (new Date()).getTime();
1147    function handleMousewheel(e) {
1148        var we = _this._wheelEvent;
1149        var delta = 0;
1150
1151        //Opera & IE
1152        if (e.detail) delta = -e.detail;
1153        //WebKits
1154        else if (we === 'mousewheel') {
1155            if (params.mousewheelControlForceToAxis) {
1156                if (isH) {
1157                    if (Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX;
1158                    else return;
1159                }
1160                else {
1161                    if (Math.abs(e.wheelDeltaY) > Math.abs(e.wheelDeltaX)) delta = e.wheelDeltaY;
1162                    else return;
1163                }
1164            }
1165            else {
1166                delta = e.wheelDelta;
1167            }
1168        }
1169        //Old FireFox
1170        else if (we === 'DOMMouseScroll') delta = -e.detail;
1171        //New FireFox
1172        else if (we === 'wheel') {
1173            if (params.mousewheelControlForceToAxis) {
1174                if (isH) {
1175                    if (Math.abs(e.deltaX) > Math.abs(e.deltaY)) delta = -e.deltaX;
1176                    else return;
1177                }
1178                else {
1179                    if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) delta = -e.deltaY;
1180                    else return;
1181                }
1182            }
1183            else {
1184                delta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? - e.deltaX : - e.deltaY;
1185            }
1186            // Accelerate mouse wheel by ThemeREX
1187            delta *= params.mousewheelAccelerator;
1188        }
1189
1190        if (!params.freeMode) {
1191            if ((new Date()).getTime() - lastScrollTime > 60) {
1192                if (delta < 0) _this.swipeNext();
1193                else _this.swipePrev();
1194            }
1195            lastScrollTime = (new Date()).getTime();
1196
1197        }
1198        else {
1199            //Freemode or scrollContainer:
1200            var position = _this.getWrapperTranslate() + delta;
1201
1202            if (position > 0) position = 0;
1203            if (position < -maxWrapperPosition()) position = -maxWrapperPosition();
1204
1205            _this.setWrapperTransition(0);
1206            _this.setWrapperTranslate(position);
1207            _this.updateActiveSlide(position);
1208
1209            // Return page scroll on edge positions
1210            if (position === 0 || position === -maxWrapperPosition()) return;
1211        }
1212        if (params.autoplay) _this.stopAutoplay(true);
1213
1214        if (e.preventDefault) e.preventDefault();
1215        else e.returnValue = false;
1216        return false;
1217    }
1218    _this.disableMousewheelControl = function () {
1219        if (!_this._wheelEvent) return false;
1220        params.mousewheelControl = false;
1221        _this.h.removeEventListener(_this.container, _this._wheelEvent, handleMousewheel);
1222        return true;
1223    };
1224
1225    _this.enableMousewheelControl = function () {
1226        if (!_this._wheelEvent) return false;
1227        params.mousewheelControl = true;
1228        _this.h.addEventListener(_this.container, _this._wheelEvent, handleMousewheel);
1229        return true;
1230    };
1231
1232    /*=========================
1233      Grab Cursor
1234      ===========================*/
1235    if (params.grabCursor) {
1236        var containerStyle = _this.container.style;
1237        containerStyle.cursor = 'move';
1238        containerStyle.cursor = 'grab';
1239        containerStyle.cursor = '-moz-grab';
1240        containerStyle.cursor = '-webkit-grab';
1241    }
1242
1243    /*=========================
1244      Slides Events Handlers
1245      ===========================*/
1246
1247    _this.allowSlideClick = true;
1248    function slideClick(event) {
1249        if (_this.allowSlideClick) {
1250            setClickedSlide(event);
1251            _this.fireCallback(params.onSlideClick, _this, event);
1252        }
1253    }
1254
1255    function slideTouch(event) {
1256        setClickedSlide(event);
1257        _this.fireCallback(params.onSlideTouch, _this, event);
1258    }
1259
1260    function setClickedSlide(event) {
1261
1262        // IE 6-8 support
1263        if (!event.currentTarget) {
1264            var element = event.srcElement;
1265            do {
1266                if (element.className.indexOf(params.slideClass) > -1) {
1267                    break;
1268                }
1269                element = element.parentNode;
1270            } while (element);
1271            _this.clickedSlide = element;
1272        }
1273        else {
1274            _this.clickedSlide = event.currentTarget;
1275        }
1276
1277        _this.clickedSlideIndex     = _this.slides.indexOf(_this.clickedSlide);
1278        _this.clickedSlideLoopIndex = _this.clickedSlideIndex - (_this.loopedSlides || 0);
1279    }
1280
1281    _this.allowLinks = true;
1282    function preventClick(e) {
1283        if (!_this.allowLinks) {
1284            if (e.preventDefault) e.preventDefault();
1285            else e.returnValue = false;
1286            if (params.preventLinksPropagation && 'stopPropagation' in e) {
1287                e.stopPropagation();
1288            }
1289            return false;
1290        }
1291    }
1292    function releaseForms(e) {
1293        if (e.stopPropagation) e.stopPropagation();
1294        else e.returnValue = false;
1295        return false;
1296
1297    }
1298
1299    /*==================================================
1300        Event Handlers
1301    ====================================================*/
1302    var isTouchEvent = false;
1303    var allowThresholdMove;
1304    var allowMomentumBounce = true;
1305    function onTouchStart(event) {
1306        if (params.preventLinks) _this.allowLinks = true;
1307        //Exit if slider is already was touched
1308        if (_this.isTouched || params.onlyExternal) {
1309            return false;
1310        }
1311
1312        if (params.noSwiping && (event.target || event.srcElement) && noSwipingSlide(event.target || event.srcElement)) return false;
1313        allowMomentumBounce = false;
1314        //Check For Nested Swipers
1315        _this.isTouched = true;
1316        isTouchEvent = event.type === 'touchstart';
1317
1318        if (!isTouchEvent || event.targetTouches.length === 1) {
1319            _this.callPlugins('onTouchStartBegin');
1320
1321            if (!isTouchEvent && !_this.isAndroid) {
1322                if (event.preventDefault) event.preventDefault();
1323                else event.returnValue = false;
1324      
1324      }
1325
1326            var pageX = isTouchEvent ? event.targetTouches[0].pageX : (event.pageX || event.clientX);
1327            var pageY = isTouchEvent ? event.targetTouches[0].pageY : (event.pageY || event.clientY);
1328
1329            //Start Touches to check the scrolling
1330            _this.touches.startX = _this.touches.currentX = pageX;
1331            _this.touches.startY = _this.touches.currentY = pageY;
1332
1333            _this.touches.start = _this.touches.current = isH ? pageX : pageY;
1334
1335            //Set Transition Time to 0
1336            _this.setWrapperTransition(0);
1337
1338            //Get Start Translate Position
1339            _this.positions.start = _this.positions.current = _this.getWrapperTranslate();
1340
1341            //Set Transform
1342            _this.setWrapperTranslate(_this.positions.start);
1343
1344            //TouchStartTime
1345            _this.times.start = (new Date()).getTime();
1346
1347            //Unset Scrolling
1348            isScrolling = undefined;
1349
1350            //Set Treshold
1351            if (params.moveStartThreshold > 0) {
1352                allowThresholdMove = false;
1353            }
1354
1355            //CallBack
1356            if (params.onTouchStart) _this.fireCallback(params.onTouchStart, _this, event);
1357            _this.callPlugins('onTouchStartEnd');
1358
1359        }
1360    }
1361    var velocityPrevPosition, velocityPrevTime;
1362    function onTouchMove(event) {
1363        // If slider is not touched - exit
1364        if (!_this.isTouched || params.onlyExternal) return;
1365        if (isTouchEvent && event.type === 'mousemove') return;
1366
1367        var pageX = isTouchEvent ? event.targetTouches[0].pageX : (event.pageX || event.clientX);
1368        var pageY = isTouchEvent ? event.targetTouches[0].pageY : (event.pageY || event.clientY);
1369
1370        //check for scrolling
1371        if (typeof isScrolling === 'undefined' && isH) {
1372            isScrolling = !!(isScrolling || Math.abs(pageY - _this.touches.startY) > Math.abs(pageX - _this.touches.startX));
1373        }
1374        if (typeof isScrolling === 'undefined' && !isH) {
1375            isScrolling = !!(isScrolling || Math.abs(pageY - _this.touches.startY) < Math.abs(pageX - _this.touches.startX));
1376        }
1377        if (isScrolling) {
1378            _this.isTouched = false;
1379            return;
1380        }
1381
1382        //Check For Nested Swipers
1383        if (event.assignedToSwiper) {
1384            _this.isTouched = false;
1385            return;
1386        }
1387        event.assignedToSwiper = true;
1388
1389        //Block inner links
1390        if (params.preventLinks) {
1391            _this.allowLinks = false;
1392        }
1393        if (params.onSlideClick) {
1394            _this.allowSlideClick = false;
1395        }
1396
1397        //Stop AutoPlay if exist
1398        if (params.autoplay) {
1399            _this.stopAutoplay(true);
1400        }
1401        if (!isTouchEvent || event.touches.length === 1) {
1402
1403            //Moved Flag
1404            if (!_this.isMoved) {
1405                _this.callPlugins('onTouchMoveStart');
1406
1407                if (params.loop) {
1408                    _this.fixLoop();
1409                    _this.positions.start = _this.getWrapperTranslate();
1410                }
1411                if (params.onTouchMoveStart) _this.fireCallback(params.onTouchMoveStart, _this);
1412            }
1413            _this.isMoved = true;
1414
1415            // cancel event
1416            if (event.preventDefault) event.preventDefault();
1417            else event.returnValue = false;
1418
1419            _this.touches.current = isH ? pageX : pageY;
1420
1421            _this.positions.current = (_this.touches.current - _this.touches.start) * params.touchRatio + _this.positions.start;
1422
1423            //Resistance Callbacks
1424            if (_this.positions.current > 0 && params.onResistanceBefore) {
1425                _this.fireCallback(params.onResistanceBefore, _this, _this.positions.current);
1426            }
1427            if (_this.positions.current < -maxWrapperPosition() && params.onResistanceAfter) {
1428                _this.fireCallback(params.onResistanceAfter, _this, Math.abs(_this.positions.current + maxWrapperPosition()));
1429            }
1430            //Resistance
1431            if (params.resistance && params.resistance !== '100%') {
1432                var resistance;
1433                //Resistance for Negative-Back sliding
1434                if (_this.positions.current > 0) {
1435                    resistance = 1 - _this.positions.current / containerSize / 2;
1436                    if (resistance < 0.5)
1437                        _this.positions.current = (containerSize / 2);
1438                    else
1439                        _this.positions.current = _this.positions.current * resistance;
1440                }
1441                //Resistance for After-End Sliding
1442                if (_this.positions.current < -maxWrapperPosition()) {
1443
1444                    var diff = (_this.touches.current - _this.touches.start) * params.touchRatio + (maxWrapperPosition() + _this.positions.start);
1445                    resistance = (containerSize + diff) / (containerSize);
1446                    var newPos = _this.positions.current - diff * (1 - resistance) / 2;
1447                    var stopPos = -maxWrapperPosition() - containerSize / 2;
1448
1449                    if (newPos < stopPos || resistance <= 0)
1450                        _this.positions.current = stopPos;
1451                    else
1452                        _this.positions.current = newPos;
1453                }
1454            }
1455            if (params.resistance && params.resistance === '100%') {
1456                //Resistance for Negative-Back sliding
1457                if (_this.positions.current > 0 && !(params.freeMode && !params.freeModeFluid)) {
1458                    _this.positions.current = 0;
1459                }
1460                //Resistance for After-End Sliding
1461                if (_this.positions.current < -maxWrapperPosition() && !(params.freeMode && !params.freeModeFluid)) {
1462                    _this.positions.current = -maxWrapperPosition();
1463                }
1464            }
1465            //Move Slides
1466            if (!params.followFinger) return;
1467
1468            if (!params.moveStartThreshold) {
1469                _this.setWrapperTranslate(_this.positions.current);
1470            }
1471            else {
1472                if (Math.abs(_this.touches.current - _this.touches.start) > params.moveStartThreshold || allowThresholdMove) {
1473                    if (!allowThresholdMove) {
1474                        allowThresholdMove = true;
1475                        _this.touches.start = _this.touches.current;
1476                        return;
1477                    }
1478                    _this.setWrapperTranslate(_this.positions.current);
1479                }
1480                else {
1481                    _this.positions.current = _this.positions.start;
1482                }
1483            }
1484
1485            if (params.freeMode || params.watchActiveIndex) {
1486                _this.updateActiveSlide(_this.positions.current);
1487            }
1488
1489            //Grab Cursor
1490            if (params.grabCursor) {
1491                _this.container.style.cursor = 'move';
1492                _this.container.style.cursor = 'grabbing';
1493                _this.container.style.cursor = '-moz-grabbin';
1494                _this.container.style.cursor = '-webkit-grabbing';
1495            }
1496            //Velocity
1497            if (!velocityPrevPosition) velocityPrevPosition = _this.touches.current;
1498            if (!velocityPrevTime) velocityPrevTime = (new Date()).getTime();
1499            _this.velocity = (_this.touches.current - velocityPrevPosition) / ((new Date()).getTime() - velocityPrevTime) / 2;
1500            if (Math.abs(_this.touches.current - velocityPrevPosition) < 2) _this.velocity = 0;
1501            velocityPrevPosition = _this.touches.current;
1502            velocityPrevTime = (new Date()).getTime();
1503            //Callbacks
1504            _this.callPlugins('onTouchMoveEnd');
1505            if (params.onTouchMove) _this.fireCallback(params.onTouchMove, _this, event);
1506
1507            return false;
1508        }
1509    }
1510    function onTouchEnd(event) {
1511        //Check For scrolling
1512        if (isScrolling) {
1513            _this.swipeReset();
1514        }
1515        // If slider is not touched exit
1516        if (params.onlyExternal || !_this.isTouched) return;
1517        _this.isTouched = false;
1518
1519        //Return Grab Cursor
1520        if (params.grabCursor) {
1521            _this.container.style.cursor = 'move';
1522            _this.container.style.cursor = 'grab';
1523            _this.container.style.cursor = '-moz-grab';
1524            _this.container.style.cursor = '-webkit-grab';
1525        }
1526
1527        //Check for Current Position
1528        if (!_this.positions.current && _this.positions.current !== 0) {
1529            _this.positions.current = _this.positions.start;
1530        }
1531
1532        //For case if slider touched but not moved
1533        if (params.followFinger) {
1534            _this.setWrapperTranslate(_this.positions.current);
1535        }
1536
1537        // TouchEndTime
1538        _this.times.end = (new Date()).getTime();
1539
1540        //Difference
1541        _this.touches.diff = _this.touches.current - _this.touches.start;
1542        _this.touches.abs = Math.abs(_this.touches.diff);
1543
1544        _this.positions.diff = _this.positions.current - _this.positions.start;
1545        _this.positions.abs = Math.abs(_this.positions.diff);
1546
1547        var diff = _this.positions.diff;
1548        var diffAbs = _this.positions.abs;
1549        var timeDiff = _this.times.end - _this.times.start;
1550
1551        if (diffAbs < 5 && (timeDiff) < 300 && _this.allowLinks === false) {
1552            if (!params.freeMode && diffAbs !== 0) _this.swipeReset();
1553            //Release inner links
1554            if (params.preventLinks) {
1555                _this.allowLinks = true;
1556            }
1557            if (params.onSlideClick) {
1558                _this.allowSlideClick = true;
1559            }
1560        }
1561
1562        setTimeout(function () {
1563            //Release inner links
1564            if (params.preventLinks) {
1565                _this.allowLinks = true;
1566            }
1567            if (params.onSlideClick) {
1568                _this.allowSlideClick = true;
1569            }
1570        }, 100);
1571
1572        var maxPosition = maxWrapperPosition();
1573
1574        //Not moved or Prevent Negative Back Sliding/After-End Sliding
1575        if (!_this.isMoved && params.freeMode) {
1576            _this.isMoved = false;
1577            if (params.onTouchEnd) _this.fireCallback(params.onTouchEnd, _this, event);
1578            _this.callPlugins('onTouchEnd');
1579            return;
1580        }
1581        if (!_this.isMoved || _this.positions.current > 0 || _this.positions.current < -maxPosition) {
1582            _this.swipeReset();
1583            if (params.onTouchEnd) _this.fireCallback(params.onTouchEnd, _this, event);
1584            _this.callPlugins('onTouchEnd');
1585            return;
1586        }
1587
1588        _this.isMoved = false;
1589
1590        //Free Mode
1591        if (params.freeMode) {
1592            if (params.freeModeFluid) {
1593                var momentumDuration = 1000 * params.momentumRatio;
1594                var momentumDistance = _this.velocity * momentumDuration;
1595                var newPosition = _this.positions.current + momentumDistance;
1596                var doBounce = false;
1597                var afterBouncePosition;
1598                var bounceAmount = Math.abs(_this.velocity) * 20 * params.momentumBounceRatio;
1599                if (newPosition < -maxPosition) {
1600                    if (params.momentumBounce && _this.support.transitions) {
1601                        if (newPosition + maxPosition < -bounceAmount) newPosition = -maxPosition - bounceAmount;
1602                        afterBouncePosition = -maxPosition;
1603                        doBounce = true;
1604                        allowMomentumBounce = true;
1605                    }
1606                    else newPosition = -maxPosition;
1607                }
1608                if (newPosition > 0) {
1609                    if (params.momentumBounce && _this.support.transitions) {
1610                        if (newPosition > bounceAmount) newPosition = bounceAmount;
1611                        afterBouncePosition = 0;
1612                        doBounce = true;
1613                        allowMomentumBounce = true;
1614                    }
1615                    else newPosition = 0;
1616                }
1617                //Fix duration
1618                if (_this.velocity !== 0) momentumDuration = Math.abs((newPosition - _this.positions.current) / _this.velocity);
1619
1620                _this.setWrapperTranslate(newPosition);
1621
1622                _this.setWrapperTransition(momentumDuration);
1623
1624                if (params.momentumBounce && doBounce) {
1625                    _this.wrapperTransitionEnd(function () {
1626                        if (!allowMomentumBounce) return;
1627                        if (params.onMomentumBounce) _this.fireCallback(params.onMomentumBounce, _this);
1628                        _this.callPlugins('onMomentumBounce');
1629
1630                        _this.setWrapperTranslate(afterBouncePosition);
1631                        _this.setWrapperTransition(300);
1632                    });
1633                }
1634
1635                _this.updateActiveSlide(newPosition);
1636            }
1637            if (!params.freeModeFluid || timeDiff >= 300) _this.updateActiveSlide(_this.positions.current);
1638
1639            if (params.onTouchEnd) _this.fireCallback(params.onTouchEnd, _this, event);
1640            _this.callPlugins('onTouchEnd');
1641            return;
1642        }
1643
1644        //Direction
1645        direction = diff < 0 ? 'toNext' : 'toPrev';
1646
1647        //Short Touches
1648        if (direction === 'toNext' && (timeDiff <= 300)) {
1649            if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset();
1650            else _this.swipeNext(true);
1651        }
1652
1653        if (direction === 'toPrev' && (timeDiff <= 300)) {
1654            if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset();
1655            else _this.swipePrev(true);
1656        }
1657
1658        //Long Touches
1659        var targetSlideSize = 0;
1660        if (params.slidesPerView === 'auto') {
1661            //Define current slide's width
1662            var currentPosition = Math.abs(_this.getWrapperTranslate());
1663            var slidesOffset = 0;
1664            var _slideSize;
1665            for (var i = 0; i < _this.slides.length; i++) {
1666                _slideSize = isH ? _this.slides[i].getWidth(true, params.roundLengths) : _this.slides[i].getHeight(true, params.roundLengths);
1667                slidesOffset += _slideSize;
1668                if (slidesOffset > currentPosition) {
1669                    targetSlideSize = _slideSize;
1670                    break;
1671                }
1672            }
1673            if (targetSlideSize > containerSize) targetSlideSize = containerSize;
1674        }
1675        else {
1676            targetSlideSize = slideSize * params.slidesPerView;
1677        }
1678        if (direction === 'toNext' && (timeDiff > 300)) {
1679            if (diffAbs >= targetSlideSize * params.longSwipesRatio) {
1680                _this.swipeNext(true);
1681            }
1682            else {
1683                _this.swipeReset();
1684            }
1685        }
1686        if (direction === 'toPrev' && (timeDiff > 300)) {
1687            if (diffAbs >= targetSlideSize * params.longSwipesRatio) {
1688                _this.swipePrev(true);
1689            }
1690            else {
1691                _this.swipeReset();
1692            }
1693        }
1694        if (params.onTouchEnd) _this.fireCallback(params.onTouchEnd, _this, event);
1695        _this.callPlugins('onTouchEnd');
1696    }
1697
1698
1699    /*==================================================
1700        noSwiping Bubble Check by Isaac Strack
1701    ====================================================*/
1702    function noSwipingSlide(el) {
1703        /*This function is specifically designed to check the parent elements for the noSwiping class, up to the wrapper.
1704        We need to check parents because while onTouchStart bubbles, _this.isTouched is checked in onTouchStart, which stops the bubbling.
1705        So, if a text box, for example, is the initial target, and the parent slide container has the noSwiping class, the _this.isTouched
1706        check will never find it, and what was supposed to be noSwiping is able to be swiped.
1707        This function will iterate up and check for the noSwiping class in parents, up through the wrapperClass.*/
1708
1709        // First we create a truthy variable, which is that swiping is allowd (noSwiping = false)
1710        var noSwiping = false;
1711
1712        // Now we iterate up (parentElements) until we reach the node with the wrapperClass.
1713        do {
1714
1715            // Each time, we check to see if there's a 'swiper-no-swiping' class (noSwipingClass).
1716            if (el.className.indexOf(params.noSwipingClass) > -1)
1717            {
1718                noSwiping = true; // If there is, we set noSwiping = true;
1719            }
1720
1721            el = el.parentElement;  // now we iterate up (parent node)
1722
1723        } while (!noSwiping && el.parentElement && el.className.indexOf(params.wrapperClass) === -1); // also include el.parentElement truthy, just in case.
1724
1725        // because we didn't check the wrapper itself, we do so now, if noSwiping is false:
1726        if (!noSwiping && el.className.indexOf(params.wrapperClass) > -1 && el.className.indexOf(params.noSwipingClass) > -1)
1727            noSwiping = true; // if the wrapper has the noSwipingClass, we set noSwiping = true;
1728
1729        return noSwiping;
1730    }
1731
1732    function addClassToHtmlString(klass, outerHtml) {
1733        var par = document.createElement('div');
1734        var child;
1735
1736        par.innerHTML = outerHtml;
1737        child = par.firstChild;
1738        child.className += ' ' + klass;
1739
1740        return child.outerHTML;
1741    }
1742
1743
1744    /*==================================================
1745        Swipe Functions
1746    ====================================================*/
1747    _this.swipeNext = function (internal) {
1748        if (!internal && params.loop) _this.fixLoop();
1749        if (!internal && params.autoplay) _this.stopAutoplay(true);
1750        _this.callPlugins('onSwipeNext');
1751        var currentPosition = _this.getWrapperTranslate();
1752        var newPosition = currentPosition;
1753        if (params.slidesPerView === 'auto') {
1754            for (var i = 0; i < _this.snapGrid.length; i++) {
1755                if (-currentPosition >= _this.snapGrid[i] && -currentPosition < _this.snapGrid[i + 1]) {
1756                    newPosition = -_this.snapGrid[i + 1];
1757                    break;
1758                }
1759            }
1760        }
1761        else {
1762            var groupSize = slideSize * params.slidesPerGroup;
1763            newPosition = -(Math.floor(Math.abs(currentPosition) / Math.floor(groupSize)) * groupSize + groupSize);
1764        }
1765        if (newPosition < -maxWrapperPosition()) {
1766            newPosition = -maxWrapperPosition();
1767        }
1768        if (newPosition === currentPosition) return false;
1769        swipeToPosition(newPosition, 'next');
1770        return true;
1771    };
1772    _this.swipePrev = function (internal) {
1773        if (!internal && params.loop) _this.fixLoop();
1774        if (!internal && params.autoplay) _this.stopAutoplay(true);
1775        _this.callPlugins('onSwipePrev');
1776
1777        var currentPosition = Math.ceil(_this.getWrapperTranslate());
1778        var newPosition;
1779        if (params.slidesPerView === 'auto') {
1780            newPosition = 0;
1781            for (var i = 1; i < _this.snapGrid.length; i++) {
1782                if (-currentPosition === _this.snapGrid[i]) {
1783                    newPosition = -_this.snapGrid[i - 1];
1784                    break;
1785                }
1786                if (-currentPosition > _this.snapGrid[i] && -currentPosition < _this.snapGrid[i + 1]) {
1787                    newPosition = -_this.snapGrid[i];
1788                    break;
1789                }
1790            }
1791        }
1792        else {
1793            var groupSize = slideSize * params.slidesPerGroup;
1794            newPosition = -(Math.ceil(-currentPosition / groupSize) - 1) * groupSize;
1795        }
1796
1797        if (newPosition > 0) newPosition = 0;
1798
1799        if (newPosition === currentPosition) return false;
1800        swipeToPosition(newPosition, 'prev');
1801        return true;
1802
1803    };
1804    _this.swipeReset = function () {
1805        _this.callPlugins('onSwipeReset');
1806        var currentPosition = _this.getWrapperTranslate();
1807        var groupSize = slideSize * params.slidesPerGroup;
1808        var newPosition;
1809        var maxPosition = -maxWrapperPosition();
1810        if (params.slidesPerView === 'auto') {
1811            newPosition = 0;
1812            for (var i = 0; i < _this.snapGrid.length; i++) {
1813                if (-currentPosition === _this.snapGrid[i]) return;
1814                if (-currentPosition >= _this.snapGrid[i] && -currentPosition < _this.snapGrid[i + 1]) {
1815                    if (_this.positions.diff > 0) newPosition = -_this.snapGrid[i + 1];
1816                    else newPosition = -_this.snapGrid[i];
1817                    break;
1818                }
1819            }
1820            if (-currentPosition >= _this.snapGrid[_this.snapGrid.length - 1]) newPosition = -_this.snapGrid[_this.snapGrid.length - 1];
1821            if (currentPosition <= -maxWrapperPosition()) newPosition = -maxWrapperPosition();
1822        }
1823        else {
1824            newPosition = currentPosition < 0 ? Math.round(currentPosition / groupSize) * groupSize : 0;
1825        }
1826        if (params.scrollContainer)  {
1827            newPosition = currentPosition < 0 ? currentPosition : 0;
1828        }
1829        if (newPosition < -maxWrapperPosition()) {
1830            newPosition = -maxWrapperPosition();
1831        }
1832        if (params.scrollContainer && (containerSize > slideSize)) {
1833            newPosition = 0;
1834        }
1835
1836        if (newPosition === currentPosition) return false;
1837
1838        swipeToPosition(newPosition, 'reset');
1839        return true;
1840    };
1841
1842    _this.swipeTo = function (index, speed, runCallbacks) {
1843        index = parseInt(index, 10);
1844        _this.callPlugins('onSwipeTo', {index: index, speed: speed});
1845        if (params.loop) index = index + _this.loopedSlides;
1846        var currentPosition = _this.getWrapperTranslate();
1847        if (index > (_this.slides.length - 1) || index < 0) return;
1848        var newPosition;
1849        if (params.slidesPerView === 'auto') {
1850            newPosition = -_this.slidesGrid[index];
1851        }
1852        else {
1853            newPosition = -index * slideSize;
1854        }
1855        if (newPosition < - maxWrapperPosition()) {
1856            newPosition = - maxWrapperPosition();
1857        }
1858
1859        if (newPosition === currentPosition) return false;
1860
1861        runCallbacks = runCallbacks === false ? false : true;
1862        swipeToPosition(newPosition, 'to', {index: index, speed: speed, runCallbacks: runCallbacks});
1863        return true;
1864    };
1865
1866    function swipeToPosition(newPosition, action, toOptions) {
1867        var speed = (action === 'to' && toOptions.speed >= 0) ? toOptions.speed : params.speed;
1868        var timeOld = + new Date();
1869
1870        function anim() {
1871            var timeNew = + new Date();
1872            var time = timeNew - timeOld;
1873            currentPosition += animationStep * time / (1000 / 60);
1874            condition = direction === 'toNext' ? currentPosition > newPosition : currentPosition < newPosition;
1875            if (condition) {
1876                _this.setWrapperTranslate(Math.round(currentPosition));
1877                _this._DOMAnimating = true;
1878                window.setTimeout(function () {
1879                    anim();
1880                }, 1000 / 60);
1881            }
1882            else {
1883                if (params.onSlideChangeEnd) {
1884                    if (action === 'to') {
1885                        if (toOptions.runCallbacks === true) _this.fireCallback(params.onSlideChangeEnd, _this);
1886                    }
1887                    else {
1888                        _this.fireCallback(params.onSlideChangeEnd, _this);
1889                    }
1890                    
1891                }
1892                _this.setWrapperTranslate(newPosition);
1893                _this._DOMAnimating = false;
1894            }
1895        }
1896
1897        if (_this.support.transitions || !params.DOMAnimation) {
1898            _this.setWrapperTranslate(newPosition);
1899            _this.setWrapperTransition(speed);
1900        }
1901        else {
1902            //Try the DOM animation
1903            var currentPosition = _this.getWrapperTranslate();
1904            var animationStep = Math.ceil((newPosition - currentPosition) / speed * (1000 / 60));
1905            var direction = currentPosition > newPosition ? 'toNext' : 'toPrev';
1906            var condition = direction === 'toNext' ? currentPosition > newPosition : currentPosition < newPosition;
1907            if (_this._DOMAnimating) return;
1908
1909            anim();
1910        }
1911
1912        //Update Active Slide Index
1913        _this.updateActiveSlide(newPosition);
1914
1915        //Callbacks
1916        if (params.onSlideNext && action === 'next') {
1917            _this.fireCallback(params.onSlideNext, _this, newPosition);
1918        }
1919        if (params.onSlidePrev && action === 'prev') {
1920            _this.fireCallback(params.onSlidePrev, _this, newPosition);
1921        }
1922        //'Reset' Callback
1923        if (params.onSlideReset && action === 'reset') {
1924            _this.fireCallback(params.onSlideReset, _this, newPosition);
1925        }
1926
1927        //'Next', 'Prev' and 'To' Callbacks
1928        if (action === 'next' || action === 'prev' || (action === 'to' && toOptions.runCallbacks === true))
1929            slideChangeCallbacks(action);
1930    }
1931    /*==================================================
1932        Transition Callbacks
1933    ====================================================*/
1934    //Prevent Multiple Callbacks
1935    _this._queueStartCallbacks = false;
1936    _this._queueEndCallbacks = false;
1937    function slideChangeCallbacks(direction) {
1938        //Transition Start Callback
1939        _this.callPlugins('onSlideChangeStart');
1940        if (params.onSlideChangeStart) {
1941            if (params.queueStartCallbacks && _this.support.transitions) {
1942                if (_this._queueStartCallbacks) return;
1943                _this._queueStartCallbacks = true;
1944                _this.fireCallback(params.onSlideChangeStart, _this, direction);
1945                _this.wrapperTransitionEnd(function () {
1946                    _this._queueStartCallbacks = false;
1947                });
1948            }
1949            else _this.fireCallback(params.onSlideChangeStart, _this, direction);
1950        }
1951        //Transition End Callback
1952        if (params.onSlideChangeEnd) {
1953            if (_this.support.transitions) {
1954                if (params.queueEndCallbacks) {
1955                    if (_this._queueEndCallbacks) return;
1956                    _this._queueEndCallbacks = true;
1957                    _this.wrapperTransitionEnd(function (swiper) {
1958                        _this.fireCallback(params.onSlideChangeEnd, swiper, direction);
1959                    });
1960                }
1961                else {
1962                    _this.wrapperTransitionEnd(function (swiper) {
1963                        _this.fireCallback(params.onSlideChangeEnd, swiper, direction);
1964                    });
1965                }
1966            }
1967            else {
1968                if (!params.DOMAnimation) {
1969                    setTimeout(function () {
1970                        _this.fireCallback(params.onSlideChangeEnd, _this, direction);
1971                    }, 10);
1972                }
1973            }
1974        }
1975    }
1976
1977    /*==================================================
1978        Update Active Slide Index
1979    ====================================================*/
1980    _this.updateActiveSlide = function (position) {
1981        if (!_this.initialized) return;
1982        if (_this.slides.length === 0) return;
1983        _this.previousIndex = _this.activeIndex;
1984        if (typeof position === 'undefined') position = _this.getWrapperTranslate();
1985        if (position > 0) position = 0;
1986        var i;
1987        if (params.slidesPerView === 'auto') {
1988            var slidesOffset = 0;
1989            _this.activeIndex = _this.slidesGrid.indexOf(-position);
1990            if (_this.activeIndex < 0) {
1991                for (i = 0; i < _this.slidesGrid.length - 1; i++) {
1992                    if (-position > _this.slidesGrid[i] && -position < _this.slidesGrid[i + 1]) {
1993                        break;
1994                    }
1995                }
1996                var leftDistance = Math.abs(_this.slidesGrid[i] + position);
1997                var rightDistance = Math.abs(_this.slidesGrid[i + 1] + position);
1998                if (leftDistance <= rightDistance) _this.activeIndex = i;
1999                else _this.activeIndex = i + 1;
2000            }
2001        }
2002        else {
2003            _this.activeIndex = Math[params.visibilityFullFit ? 'ceil' : 'round'](-position / slideSize);
2004        }
2005
2006        if (_this.activeIndex === _this.slides.length) _this.activeIndex = _this.slides.length - 1;
2007        if (_this.activeIndex < 0) _this.activeIndex = 0;
2008
2009        // Check for slide
2010        if (!_this.slides[_this.activeIndex]) return;
2011
2012        // Calc Visible slides
2013        _this.calcVisibleSlides(position);
2014
2015        // Mark visible and active slides with additonal classes
2016        if (_this.support.classList) {
2017            var slide;
2018            for (i = 0; i < _this.slides.length; i++) {
2019                slide = _this.slides[i];
2020                slide.classList.remove(params.slideActiveClass);
2021                if (_this.visibleSlides.indexOf(slide) >= 0) {
2022                    slide.classList.add(params.slideVisibleClass);
2023                } else {
2024                    slide.classList.remove(params.slideVisibleClass);
2025                }
2026            }
2027            _this.slides[_this.activeIndex].classList.add(params.slideActiveClass);
2028        } else {
2029            var activeClassRegexp = new RegExp('\\s*' + params.slideActiveClass);
2030            var inViewClassRegexp = new RegExp('\\s*' + params.slideVisibleClass);
2031
2032            for (i = 0; i < _this.slides.length; i++) {
2033                _this.slides[i].className = _this.slides[i].className.replace(activeClassRegexp, '').replace(inViewClassRegexp, '');
2034                if (_this.visibleSlides.indexOf(_this.slides[i]) >= 0) {
2035                    _this.slides[i].className += ' ' + params.slideVisibleClass;
2036                }
2037            }
2038            _this.slides[_this.activeIndex].className += ' ' + params.slideActiveClass;
2039        }
2040
2041        //Update loop index
2042        if (params.loop) {
2043            var ls = _this.loopedSlides;
2044            _this.activeLoopIndex = _this.activeIndex - ls;
2045            if (_this.activeLoopIndex >= _this.slides.length - ls * 2) {
2046                _this.activeLoopIndex = _this.slides.length - ls * 2 - _this.activeLoopIndex;
2047            }
2048            if (_this.activeLoopIndex < 0) {
2049                _this.activeLoopIndex = _this.slides.length - ls * 2 + _this.activeLoopIndex;
2050            }
2051            if (_this.activeLoopIndex < 0) _this.activeLoopIndex = 0;
2052        }
2053        else {
2054            _this.activeLoopIndex = _this.activeIndex;
2055        }
2056        //Update Pagination
2057        if (params.pagination) {
2058            _this.updatePagination(position);
2059        }
2060    };
2061    /*==================================================
2062        Pagination
2063    ====================================================*/
2064    _this.createPagination = function (firstInit) {
2065        if (params.paginationClickable && _this.paginationButtons) {
2066            removePaginationEvents();
2067        }
2068        _this.paginationContainer = params.pagination.nodeType ? params.pagination : $$(params.pagination)[0];
2069        if (params.createPagination) {
2070            var paginationHTML = '';
2071            var numOfSlides = _this.slides.length;
2072            var numOfButtons = numOfSlides;
2073            if (params.loop) numOfButtons -= _this.loopedSlides * 2;
2074            for (var i = 0; i < numOfButtons; i++) {
2075                paginationHTML += '<' + params.paginationElement + ' class="' + params.paginationElementClass + '"></' + params.paginationElement + '>';
2076            }
2077            _this.paginationContainer.innerHTML = paginationHTML;
2078        }
2079        _this.paginationButtons = $$('.' + params.paginationElementClass, _this.paginationContainer);
2080        if (!firstInit) _this.updatePagination();
2081        _this.callPlugins('onCreatePagination');
2082        if (params.paginationClickable) {
2083            addPaginationEvents();
2084        }
2085    };
2086    function removePaginationEvents() {
2087        var pagers = _this.paginationButtons;
2088        if (pagers) {
2089            for (var i = 0; i < pagers.length; i++) {
2090                _this.h.removeEventListener(pagers[i], 'click', paginationClick);
2091            }
2092        }
2093    }
2094    function addPaginationEvents() {
2095        var pagers = _this.paginationButtons;
2096        if (pagers) {
2097            for (var i = 0; i < pagers.length; i++) {
2098                _this.h.addEventListener(pagers[i], 'click', paginationClick);
2099            }
2100        }
2101    }
2102    function paginationClick(e) {
2103        var index;
2104        var target = e.target || e.srcElement;
2105        var pagers = _this.paginationButtons;
2106        for (var i = 0; i < pagers.length; i++) {
2107            if (target === pagers[i]) index = i;
2108        }
2109        _this.swipeTo(index);
2110    }
2111    _this.updatePagination = function (position) {
2112        if (!params.pagination) return;
2113        if (_this.slides.length < 1) return;
2114        var activePagers = $$('.' + params.paginationActiveClass, _this.paginationContainer);
2115        if (!activePagers) return;
2116
2117        //Reset all Buttons' class to not active
2118        var pagers = _this.paginationButtons;
2119        if (pagers.length === 0) return;
2120        for (var i = 0; i < pagers.length; i++) {
2121            pagers[i].className = params.paginationElementClass;
2122        }
2123
2124        var indexOffset = params.loop ? _this.loopedSlides : 0;
2125        if (params.paginationAsRange) {
2126            if (!_this.visibleSlides) _this.calcVisibleSlides(position);
2127            //Get Visible Indexes
2128            var visibleIndexes = [];
2129            var j; // lopp index - avoid JSHint W004 / W038
2130            for (j = 0; j < _this.visibleSlides.length; j++) {
2131                var visIndex = _this.slides.indexOf(_this.visibleSlides[j]) - indexOffset;
2132
2133                if (params.loop && visIndex < 0) {
2134                    visIndex = _this.slides.length - _this.loopedSlides * 2 + visIndex;
2135                }
2136                if (params.loop && visIndex >= _this.slides.length - _this.loopedSlides * 2) {
2137                    visIndex = _this.slides.length - _this.loopedSlides * 2 - visIndex;
2138                    visIndex = Math.abs(visIndex);
2139                }
2140                visibleIndexes.push(visIndex);
2141            }
2142
2143            for (j = 0; j < visibleIndexes.length; j++) {
2144                if (pagers[visibleIndexes[j]]) pagers[visibleIndexes[j]].className += ' ' + params.paginationVisibleClass;
2145            }
2146
2147            if (params.loop) {
2148                if (pagers[_this.activeLoopIndex] !== undefined) {
2149                    pagers[_this.activeLoopIndex].className += ' ' + params.paginationActiveClass;
2150                }
2151            }
2152            else {
2153                pagers[_this.activeIndex].className += ' ' + params.paginationActiveClass;
2154            }
2155        }
2156        else {
2157            if (params.loop) {
2158                if (pagers[_this.activeLoopIndex]) pagers[_this.activeLoopIndex].className += ' ' + params.paginationActiveClass + ' ' + params.paginationVisibleClass;
2159            }
2160            else {
2161                pagers[_this.activeIndex].className += ' ' + params.paginationActiveClass + ' ' + params.paginationVisibleClass;
2162            }
2163        }
2164    };
2165    _this.calcVisibleSlides = function (position) {
2166        var visibleSlides = [];
2167        var _slideLeft = 0, _slideSize = 0, _slideRight = 0;
2168        if (isH && _this.wrapperLeft > 0) position = position + _this.wrapperLeft;
2169        if (!isH && _this.wrapperTop > 0) position = position + _this.wrapperTop;
2170
2171        for (var i = 0; i < _this.slides.length; i++) {
2172            _slideLeft += _slideSize;
2173            if (params.slidesPerView === 'auto')
2174                _slideSize  = isH ? _this.h.getWidth(_this.slides[i], true, params.roundLengths) : _this.h.getHeight(_this.slides[i], true, params.roundLengths);
2175            else _slideSize = slideSize;
2176
2177            _slideRight = _slideLeft + _slideSize;
2178            var isVisibile = false;
2179            if (params.visibilityFullFit) {
2180                if (_slideLeft >= -position && _slideRight <= -position + containerSize) isVisibile = true;
2181                if (_slideLeft <= -position && _slideRight >= -position + containerSize) isVisibile = true;
2182            }
2183            else {
2184                if (_slideRight > -position && _slideRight <= ((-position + containerSize))) isVisibile = true;
2185                if (_slideLeft >= -position && _slideLeft < ((-position + containerSize))) isVisibile = true;
2186                if (_slideLeft < -position && _slideRight > ((-position + containerSize))) isVisibile = true;
2187            }
2188
2189            if (isVisibile) visibleSlides.push(_this.slides[i]);
2190
2191        }
2192        if (visibleSlides.length === 0) visibleSlides = [_this.slides[_this.activeIndex]];
2193
2194        _this.visibleSlides = visibleSlides;
2195    };
2196
2197    /*==========================================
2198        Autoplay
2199    ============================================*/
2200    var autoplayTimeoutId, autoplayIntervalId;
2201    _this.startAutoplay = function () {
2202        if (_this.support.transitions) {
2203            if (typeof autoplayTimeoutId !== 'undefined') return false;
2204            if (!params.autoplay) return;
2205            _this.callPlugins('onAutoplayStart');
2206            if (params.onAutoplayStart) _this.fireCallback(params.onAutoplayStart, _this);
2207            autoplay();
2208        }
2209        else {
2210            if (typeof autoplayIntervalId !== 'undefined') return false;
2211            if (!params.autoplay) return;
2212            _this.callPlugins('onAutoplayStart');
2213            if (params.onAutoplayStart) _this.fireCallback(params.onAutoplayStart, _this);
2214            autoplayIntervalId = setInterval(function () {
2215                if (params.loop) {
2216                    _this.fixLoop();
2217                    _this.swipeNext(true);
2218                }
2219                else if (!_this.swipeNext(true)) {
2220                    if (!params.autoplayStopOnLast) _this.swipeTo(0);
2221                    else {
2222                        clearInterval(autoplayIntervalId);
2223                        autoplayIntervalId = undefined;
2224                    }
2225                }
2226            }, params.autoplay);
2227        }
2228    };
2229    _this.stopAutoplay = function (internal) {
2230        if (_this.support.transitions) {
2231            if (!autoplayTimeoutId) return;
2232            if (autoplayTimeoutId) clearTimeout(autoplayTimeoutId);
2233            autoplayTimeoutId = undefined;
2234            if (internal && !params.autoplayDisableOnInteraction) {
2235                _this.wrapperTransitionEnd(function () {
2236                    autoplay();
2237                });
2238            }
2239            _this.callPlugins('onAutoplayStop');
2240            if (params.onAutoplayStop) _this.fireCallback(params.onAutoplayStop, _this);
2241        }
2242        else {
2243            if (autoplayIntervalId) clearInterval(autoplayIntervalId);
2244            autoplayIntervalId = undefined;
2245            _this.callPlugins('onAutoplayStop');
2246            if (params.onAutoplayStop) _this.fireCallback(params.onAutoplayStop, _this);
2247        }
2248    };
2249    function autoplay() {
2250        autoplayTimeoutId = setTimeout(function () {
2251            if (params.loop) {
2252                _this.fixLoop();
2253                _this.swipeNext(true);
2254            }
2255            else if (!_this.swipeNext(true)) {
2256                if (!params.autoplayStopOnLast) _this.swipeTo(0);
2257                else {
2258                    clearTimeout(autoplayTimeoutId);
2259                    autoplayTimeoutId = undefined;
2260                }
2261            }
2262            _this.wrapperTransitionEnd(function () {
2263                if (typeof autoplayTimeoutId !== 'undefined') autoplay();
2264            });
2265        }, params.autoplay);
2266    }
2267    /*==================================================
2268        Loop
2269    ====================================================*/
2270    _this.loopCreated = false;
2271    _this.removeLoopedSlides = function () {
2272        if (_this.loopCreated) {
2273            for (var i = 0; i < _this.slides.length; i++) {
2274                if (_this.slides[i].getData('looped') === true) _this.wrapper.removeChild(_this.slides[i]);
2275            }
2276        }
2277    };
2278
2279    _this.createLoop = function () {
2280        if (_this.slides.length === 0) return;
2281        if (params.slidesPerView === 'auto') {
2282            _this.loopedSlides = params.loopedSlides || 1;
2283        }
2284        else {
2285            _this.loopedSlides = params.slidesPerView + params.loopAdditionalSlides;
2286        }
2287
2288        if (_this.loopedSlides > _this.slides.length) {
2289            _this.loopedSlides = _this.slides.length;
2290        }
2291
2292        var slideFirstHTML = '',
2293            slideLastHTML = '',
2294            i;
2295        var slidesSetFullHTML = '';
2296        /**
2297                loopedSlides is too large if loopAdditionalSlides are set.
2298                Need to divide the slides by maximum number of slides existing.
2299
2300                @author        Tomaz Lovrec <[email protected]>
2301        */
2302        var numSlides = _this.slides.length;
2303        var fullSlideSets = Math.floor(_this.loopedSlides / numSlides);
2304        var remainderSlides = _this.loopedSlides % numSlides;
2305        // assemble full sets of slides
2306        for (i = 0; i < (fullSlideSets * numSlides); i++) {
2307            var j = i;
2308            if (i >= numSlides) {
2309                var over = Math.floor(i / numSlides);
2310                j = i - (numSlides * over);
2311            }
2312            slidesSetFullHTML += _this.slides[j].outerHTML;
2313        }
2314        // assemble remainder slides
2315        // assemble remainder appended to existing slides
2316        for (i = 0; i < remainderSlides;i++) {
2317            slideLastHTML += addClassToHtmlString(params.slideDuplicateClass, _this.slides[i].outerHTML);
2318        }
2319        // assemble slides that get preppended to existing slides
2320        for (i = numSlides - remainderSlides; i < numSlides;i++) {
2321            slideFirstHTML += addClassToHtmlString(params.slideDuplicateClass, _this.slides[i].outerHTML);
2322        }
2323        // assemble all slides
2324        var slides = slideFirstHTML + slidesSetFullHTML + wrapper.innerHTML + slidesSetFullHTML + slideLastHTML;
2325        // set the slides
2326        wrapper.innerHTML = slides;
2327
2328        _this.loopCreated = true;
2329        _this.calcSlides();
2330
2331        //Update Looped Slides with special class
2332        for (i = 0; i < _this.slides.length; i++) {
2333            if (i < _this.loopedSlides || i >= _this.slides.length - _this.loopedSlides) _this.slides[i].setData('looped', true);
2334        }
2335        _this.callPlugins('onCreateLoop');
2336
2337    };
2338
2339    _this.fixLoop = function () {
2340        var newIndex;
2341        //Fix For Negative Oversliding
2342        if (_this.activeIndex < _this.loopedSlides) {
2343            newIndex = _this.slides.length - _this.loopedSlides * 3 + _this.activeIndex;
2344            _this.swipeTo(newIndex, 0, false);
2345        }
2346        //Fix For Positive Oversliding
2347        else if ((params.slidesPerView === 'auto' && _this.activeIndex >= _this.loopedSlides * 2) || (_this.activeIndex > _this.slides.length - params.slidesPerView * 2)) {
2348            newIndex = -_this.slides.length + _this.activeIndex + _this.loopedSlides;
2349            _this.swipeTo(newIndex, 0, false);
2350        }
2351    };
2352
2353    /*==================================================
2354        Slides Loader
2355    ====================================================*/
2356    _this.loadSlides = function () {
2357        var slidesHTML = '';
2358        _this.activeLoaderIndex = 0;
2359        var slides = params.loader.slides;
2360        var slidesToLoad = params.loader.loadAllSlides ? slides.length : params.slidesPerView * (1 + params.loader.surroundGroups);
2361        for (var i = 0; i < slidesToLoad; i++) {
2362            if (params.loader.slidesHTMLType === 'outer') slidesHTML += slides[i];
2363            else {
2364                slidesHTML += '<' + params.slideElement + ' class="' + params.slideClass + '" data-swiperindex="' + i + '">' + slides[i] + '</' + params.slideElement + '>';
2365            }
2366        }
2367        _this.wrapper.innerHTML = slidesHTML;
2368        _this.calcSlides(true);
2369        //Add permanent transitionEnd callback
2370        if (!params.loader.loadAllSlides) {
2371            _this.wrapperTransitionEnd(_this.reloadSlides, true);
2372        }
2373    };
2374
2375    _this.reloadSlides = function () {
2376        var slides = params.loader.slides;
2377        var newActiveIndex = parseInt(_this.activeSlide().data('swiperindex'), 10);
2378        if (newActiveIndex < 0 || newActiveIndex > slides.length - 1) return; //<-- Exit
2379        _this.activeLoaderIndex = newActiveIndex;
2380        var firstIndex = Math.max(0, newActiveIndex - params.slidesPerView * params.loader.surroundGroups);
2381        var lastIndex = Math.min(newActiveIndex + params.slidesPerView * (1 + params.loader.surroundGroups) - 1, slides.length - 1);
2382        //Update Transforms
2383        if (newActiveIndex > 0) {
2384            var newTransform = -slideSize * (newActiveIndex - firstIndex);
2385            _this.setWrapperTranslate(newTransform);
2386            _this.setWrapperTransition(0);
2387        }
2388        var i; // loop index
2389        //New Slides
2390        if (params.loader.logic === 'reload') {
2391            _this.wrapper.innerHTML = '';
2392            var slidesHTML = '';
2393            for (i = firstIndex; i <= lastIndex; i++) {
2394                slidesHTML += params.loader.slidesHTMLType === 'outer' ? slides[i] : '<' + params.slideElement + ' class="' + params.slideClass + '" data-swiperindex="' + i + '">' + slides[i] + '</' + params.slideElement + '>';
2395            }
2396            _this.wrapper.innerHTML = slidesHTML;
2397        }
2398        else {
2399            var minExistIndex = 1000;
2400            var maxExistIndex = 0;
2401
2402            for (i = 0; i < _this.slides.length; i++) {
2403                var index = _this.slides[i].data('swiperindex');
2404                if (index < firstIndex || index > lastIndex) {
2405                    _this.wrapper.removeChild(_this.slides[i]);
2406                }
2407                else {
2408                    minExistIndex = Math.min(index, minExistIndex);
2409                    maxExistIndex = Math.max(index, maxExistIndex);
2410                }
2411            }
2412            for (i = firstIndex; i <= lastIndex; i++) {
2413                var newSlide;
2414                if (i < minExistIndex) {
2415                    newSlide = document.createElement(params.slideElement);
2416                    newSlide.className = params.slideClass;
2417                    newSlide.setAttribute('data-swiperindex', i);
2418                    newSlide.innerHTML = slides[i];
2419                    _this.wrapper.insertBefore(newSlide, _this.wrapper.firstChild);
2420                }
2421                if (i > maxExistIndex) {
2422                    newSlide = document.createElement(params.slideElement);
2423                    newSlide.className = params.slideClass;
2424                    newSlide.setAttribute('data-swiperindex', i);
2425                    newSlide.innerHTML = slides[i];
2426                    _this.wrapper.appendChild(newSlide);
2427                }
2428            }
2429        }
2430        //reInit
2431        _this.reInit(true);
2432    };
2433
2434    /*==================================================
2435        Make Swiper
2436    ====================================================*/
2437    function makeSwiper() {
2438        _this.calcSlides();
2439        if (params.loader.slides.length > 0 && _this.slides.length === 0) {
2440            _this.loadSlides();
2441        }
2442        if (params.loop) {
2443            _this.createLoop();
2444        }
2445        _this.init();
2446        initEvents();
2447        if (params.pagination) {
2448            _this.createPagination(true);
2449        }
2450
2451        if (params.loop || params.initialSlide > 0) {
2452            _this.swipeTo(params.initialSlide, 0, false);
2453        }
2454        else {
2455            _this.updateActiveSlide(0);
2456        }
2457        if (params.autoplay) {
2458            _this.startAutoplay();
2459        }
2460        /**
2461         * Set center slide index.
2462         *
2463         * @author        Tomaz Lovrec <[email protected]>
2464         */
2465        _this.centerIndex = _this.activeIndex;
2466
2467        // Callbacks
2468        if (params.onSwiperCreated) _this.fireCallback(params.onSwiperCreated, _this);
2469        _this.callPlugins('onSwiperCreated');
2470    }
2471
2472    makeSwiper();
2473};
2474
2475Swiper.prototype = {
2476    plugins : {},
2477
2478    /*==================================================
2479        Wrapper Operations
2480    ====================================================*/
2481    wrapperTransitionEnd : function (callback, permanent) {
2482        'use strict';
2483        var a = this,
2484            el = a.wrapper,
2485            events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'],
2486            i;
2487
2488        function fireCallBack() {
2489            callback(a);
2490            if (a.params.queueEndCallbacks) a._queueEndCallbacks = false;
2491            if (!permanent) {
2492                for (i = 0; i < events.length; i++) {
2493                    a.h.removeEventListener(el, events[i], fireCallBack);
2494                }
2495            }
2496        }
2497
2498        if (callback) {
2499            for (i = 0; i < events.length; i++) {
2500                a.h.addEventListener(el, events[i], fireCallBack);
2501            }
2502        }
2503    },
2504
2505    getWrapperTranslate : function (axis) {
2506        'use strict';
2507        var el = this.wrapper,
2508            matrix, curTransform, curStyle, transformMatrix;
2509
2510        // automatic axis detection
2511        if (typeof axis === 'undefined') {
2512            axis = this.params.mode === 'horizontal' ? 'x' : 'y';
2513        }
2514
2515        if (this.support.transforms && this.params.useCSS3Transforms) {
2516            curStyle = window.getComputedStyle(el, null);
2517            if (window.WebKitCSSMatrix) {
2518                // Some old versions of Webkit choke when 'none' is passed; pass
2519                // empty string instead in this case
2520                transformMatrix = new WebKitCSSMatrix(curStyle.webkitTransform === 'none' ? '' : curStyle.webkitTransform);
2521            }
2522            else {
2523                transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform  || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
2524                matrix = transformMatrix.toString().split(',');
2525            }
2526
2527            if (axis === 'x') {
2528                //Latest Chrome and webkits Fix
2529                if (window.WebKitCSSMatrix)
2530                    curTransform = transformMatrix.m41;
2531                //Crazy IE10 Matrix
2532                else if (matrix.length === 16)
2533                    curTransform = parseFloat(matrix[12]);
2534                //Normal Browsers
2535                else
2536                    curTransform = parseFloat(matrix[4]);
2537            }
2538            if (axis === 'y') {
2539                //Latest Chrome and webkits Fix
2540                if (window.WebKitCSSMatrix)
2541                    curTransform = transformMatrix.m42;
2542                //Crazy IE10 Matrix
2543                else if (matrix.length === 16)
2544                    curTransform = parseFloat(matrix[13]);
2545                //Normal Browsers
2546                else
2547                    curTransform = parseFloat(matrix[5]);
2548            }
2549        }
2550        else {
2551            if (axis === 'x') curTransform = parseFloat(el.style.left, 10) || 0;
2552            if (axis === 'y') curTransform = parseFloat(el.style.top, 10) || 0;
2553        }
2554        return curTransform || 0;
2555    },
2556
2557    setWrapperTranslate : function (x, y, z) {
2558        'use strict';
2559        var es = this.wrapper.style,
2560            coords = {x: 0, y: 0, z: 0},
2561            translate;
2562
2563        // passed all coordinates
2564        if (arguments.length === 3) {
2565            coords.x = x;
2566            coords.y = y;
2567            coords.z = z;
2568        }
2569
2570        // passed one coordinate and optional axis
2571        else {
2572            if (typeof y === 'undefined') {
2573                y = this.params.mode === 'horizontal' ? 'x' : 'y';
2574            }
2575            coords[y] = x;
2576        }
2577
2578        if (this.support.transforms && this.params.useCSS3Transforms) {
2579            translate = this.support.transforms3d ? 'translate3d(' + coords.x + 'px, ' + coords.y + 'px, ' + coords.z + 'px)' : 'translate(' + coords.x + 'px, ' + coords.y + 'px)';
2580            es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = translate;
2581        }
2582        else {
2583            es.left = coords.x + 'px';
2584            es.top  = coords.y + 'px';
2585        }
2586        this.callPlugins('onSetWrapperTransform', coords);
2587        if (this.params.onSetWrapperTransform) this.fireCallback(this.params.onSetWrapperTransform, this, coords);
2588    },
2589
2590    setWrapperTransition : function (duration) {
2591        'use strict';
2592        var es = this.wrapper.style;
2593        es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = (duration / 1000) + 's';
2594        this.callPlugins('onSetWrapperTransition', {duration: duration});
2595        if (this.params.onSetWrapperTransition) this.fireCallback(this.params.onSetWrapperTransition, this, duration);
2596
2597    },
2598
2599    /*==================================================
2600        Helpers
2601    ====================================================*/
2602    h : {
2603        getWidth: function (el, outer, round) {
2604            'use strict';
2605            var width = window.getComputedStyle(el, null).getPropertyValue('width');
2606            var returnWidth = parseFloat(width);
2607            //IE Fixes
2608            if (isNaN(returnWidth) || width.indexOf('%') > 0) {
2609                returnWidth = el.offsetWidth - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right'));
2610            }
2611            if (outer) returnWidth += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right'));
2612            if (round) return Math.round(returnWidth);
2613            else return returnWidth;
2614        },
2615        getHeight: function (el, outer, round) {
2616            'use strict';
2617            if (outer) return el.offsetHeight;
2618
2619            var height = window.getComputedStyle(el, null).getPropertyValue('height');
2620            var returnHeight = parseFloat(height);
2621            //IE Fixes
2622            if (isNaN(returnHeight) || height.indexOf('%') > 0) {
2623                returnHeight = el.offsetHeight - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom'));
2624            }
2625            if (outer) returnHeight += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom'));
2626            if (round) return Math.round(returnHeight);
2627            else return returnHeight;
2628        },
2629        getOffset: function (el) {
2630            'use strict';
2631            var box = el.getBoundingClientRect();
2632            var body = document.body;
2633            var clientTop  = el.clientTop  || body.clientTop  || 0;
2634            var clientLeft = el.clientLeft || body.clientLeft || 0;
2635            var scrollTop  = window.pageYOffset || el.scrollTop;
2636            var scrollLeft = window.pageXOffset || el.scrollLeft;
2637            if (document.documentElement && !window.pageYOffset) {
2638                //IE7-8
2639                scrollTop  = document.documentElement.scrollTop;
2640                scrollLeft = document.documentElement.scrollLeft;
2641            }
2642            return {
2643                top: box.top  + scrollTop  - clientTop,
2644                left: box.left + scrollLeft - clientLeft
2645            };
2646        },
2647        windowWidth : function () {
2648            'use strict';
2649            if (window.innerWidth) return window.innerWidth;
2650            else if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth;
2651        },
2652        windowHeight : function () {
2653            'use strict';
2654            if (window.innerHeight) return window.innerHeight;
2655            else if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight;
2656        },
2657        windowScroll : function () {
2658            'use strict';
2659            if (typeof pageYOffset !== 'undefined') {
2660                return {
2661                    left: window.pageXOffset,
2662                    top: window.pageYOffset
2663                };
2664            }
2665            else if (document.documentElement) {
2666                return {
2667                    left: document.documentElement.scrollLeft,
2668                    top: document.documentElement.scrollTop
2669                };
2670            }
2671        },
2672
2673        addEventListener : function (el, event, listener, useCapture) {
2674            'use strict';
2675            if (typeof useCapture === 'undefined') {
2676                useCapture = false;
2677            }
2678
2679            if (el.addEventListener) {
2680                el.addEventListener(event, listener, useCapture);
2681            }
2682            else if (el.attachEvent) {
2683                el.attachEvent('on' + event, listener);
2684            }
2685        },
2686
2687        removeEventListener : function (el, event, listener, useCapture) {
2688            'use strict';
2689            if (typeof useCapture === 'undefined') {
2690                useCapture = false;
2691            }
2692
2693            if (el.removeEventListener) {
2694                el.removeEventListener(event, listener, useCapture);
2695            }
2696            else if (el.detachEvent) {
2697                el.detachEvent('on' + event, listener);
2698            }
2699        }
2700    },
2701    setTransform : function (el, transform) {
2702        'use strict';
2703        var es = el.style;
2704        es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = transform;
2705    },
2706    setTranslate : function (el, translate) {
2707        'use strict';
2708        var es = el.style;
2709        var pos = {
2710            x : translate.x || 0,
2711            y : translate.y || 0,
2712            z : translate.z || 0
2713        };
2714        var transformString = this.support.transforms3d ? 'translate3d(' + (pos.x) + 'px,' + (pos.y) + 'px,' + (pos.z) + 'px)' : 'translate(' + (pos.x) + 'px,' + (pos.y) + 'px)';
2715        es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = transformString;
2716        if (!this.support.transforms) {
2717            es.left = pos.x + 'px';
2718            es.top = pos.y + 'px';
2719        }
2720    },
2721    setTransition : function (el, duration) {
2722        'use strict';
2723        var es = el.style;
2724        es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = duration + 'ms';
2725    },
2726    /*==================================================
2727        Feature Detection
2728    ====================================================*/
2729    support: {
2730
2731        touch : (window.Modernizr && Modernizr.touch === true) || (function () {
2732            'use strict';
2733            return !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch);
2734        })(),
2735
2736        transforms3d : (window.Modernizr && Modernizr.csstransforms3d === true) || (function () {
2737            'use strict';
2738            var div = document.createElement('div').style;
2739            return ('webkitPerspective' in div || 'MozPerspective' in div || 'OPerspective' in div || 'MsPerspective' in div || 'perspective' in div);
2740        })(),
2741
2742        transforms : (window.Modernizr && Modernizr.csstransforms === true) || (function () {
2743            'use strict';
2744            var div = document.createElement('div').style;
2745            return ('transform' in div || 'WebkitTransform' in div || 'MozTransform' in div || 'msTransform' in div || 'MsTransform' in div || 'OTransform' in div);
2746        })(),
2747
2748        transitions : (window.Modernizr && Modernizr.csstransitions === true) || (function () {
2749            'use strict';
2750            var div = document.createElement('div').style;
2751            return ('transition' in div || 'WebkitTransition' in div || 'MozTransition' in div || 'msTransition' in div || 'MsTransition' in div || 'OTransition' in div);
2752        })(),
2753
2754        classList : (function () {
2755            'use strict';
2756            var div = document.createElement('div').style;
2757            return 'classList' in div;
2758        })()
2759    },
2760
2761    browser : {
2762
2763        ie8 : (function () {
2764            'use strict';
2765            var rv = -1; // Return value assumes failure.
2766            if (navigator.appName === 'Microsoft Internet Explorer') {
2767                var ua = navigator.userAgent;
2768                var re = new RegExp(/MSIE ([0-9]{1,}[\.0-9]{0,})/);
2769                if (re.exec(ua) !== null)
2770                    rv = parseFloat(RegExp.$1);
2771            }
2772            return rv !== -1 && rv < 9;
2773        })(),
2774
2775        ie10 : window.navigator.msPointerEnabled,
2776        ie11 : window.navigator.pointerEnabled
2777    }
2778};
2779
2780/*=========================
2781  jQuery & Zepto Plugins
2782  ===========================*/
2783if (window.jQuery || window.Zepto) {
2784    (function ($) {
2785        'use strict';
2786        $.fn.swiper = function (params) {
2787            var s = new Swiper($(this)[0], params);
2788            $(this).data('swiper', s);
2789            return s;
2790        };
2791    })(window.jQuery || window.Zepto);
2792}
2793
2794// component
2795if (typeof(module) !== 'undefined')
2796{
2797    module.exports = Swiper;
2798}
2799
2800// requirejs support
2801if (typeof define === 'function' && define.amd) {
2802    define([], function () {
2803        'use strict';
2804        return Swiper;
2805    });
vendor: 3 bytes, line 2806
2806}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.