diff --git a/README.md b/README.md
index 6d0a90a6e..0872b7677 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,23 @@
About
Swiper - is the free and ultra lightweight mobile touch slider with hardware accelerated transitions (where supported) and amazing native behavior. It is intended to use in mobile websites, mobile web apps, and mobile native apps. Designed mostly for iOS, but also works on Android and latest Desktop browsers. Swiper is created by iDangero.us
Change Log
+Swiper 1.9 - Updated on March 16, 2013
+
+ - Added support for devices that can use both mouse and touch "pointers" at the same time, like many of Windows 8 tablets and notebooks
+ - New API features:
+
+ - New feature to set "group sliding" with
slidesPerGroup
parameter
+ - Now you can hardcode resize event (for example "resize" instead of "orientationchange" for mobiles) with
resizeEvent
parameter
+
+
+ - Fixes:
+
+ - Fixed situation when slider can get stuck between slides when tapped during transition
+ - Now clickedSlide will return correct slide in loop mode
+
+
+ - Minor fixes
+
Swiper 1.8.8 - Updated on March 4, 2013
- Improved cursors usablity with autmatic grab cursors for container and drag cursor for scrollbar
diff --git a/dev/idangerous.swiper.js b/dev/idangerous.swiper.js
index 4fc00159d..be247de00 100644
--- a/dev/idangerous.swiper.js
+++ b/dev/idangerous.swiper.js
@@ -1,5 +1,5 @@
/*
- * Swiper 1.8.8+ - Mobile Touch Slider
+ * Swiper 1.9+ - Mobile Touch Slider
* http://www.idangero.us/sliders/swiper/
*
* Copyright 2012-2013, Vladimir Kharlampidi
@@ -8,678 +8,752 @@
*
* Licensed under GPL & MIT
*
- * Updated on: March 4, 2013
+ * Updated on: March 16, 2013
*/
-Swiper = function(selector, params, callback) {
-
- /*=========================
- A little bit dirty but required part for IE8 and old FF support
- ===========================*/
- if (!window.addEventListener) {
- if (!window.Element)
- Element = function () { };
-
- Element.prototype.addEventListener = HTMLDocument.prototype.addEventListener = addEventListener = function (type, listener, useCapture) { this.attachEvent('on' + type, listener); }
- Element.prototype.removeEventListener = HTMLDocument.prototype.removeEventListener = removeEventListener = function (type, listener, useCapture) { this.detachEvent('on' + type, listener); }
- }
-
- if (document.body.__defineGetter__) {
- if (HTMLElement) {
- var element = HTMLElement.prototype;
- if (element.__defineGetter__)
- element.__defineGetter__("outerHTML", function () { return new XMLSerializer().serializeToString(this); } );
- }
- }
-
- if (!window.getComputedStyle) {
- window.getComputedStyle = function (el, pseudo) {
- this.el = el;
- this.getPropertyValue = function (prop) {
- var re = /(\-([a-z]){1})/g;
- if (prop == 'float') prop = 'styleFloat';
- if (re.test(prop)) {
- prop = prop.replace(re, function () {
- return arguments[2].toUpperCase();
- });
- }
- return el.currentStyle[prop] ? el.currentStyle[prop] : null;
- }
- return this;
- }
- }
-
- /* End Of Polyfills*/
- if(!(selector.nodeType))
- if (!document.querySelectorAll||document.querySelectorAll(selector).length==0) return;
-
- function dQ(s) {
- return document.querySelectorAll(s)
- }
- var _this = this
- _this.touches = {};
- _this.positions = {
- current : 0
- };
- _this.id = (new Date()).getTime();
- _this.container = (selector.nodeType) ? selector : dQ(selector)[0];
- _this.times = {};
- _this.isTouched = false;
- _this.realIndex = 0;
- _this.activeSlide = 0;
+var Swiper = function (selector, params, callback) {
+ /*=========================
+ A little bit dirty but required part for IE8 and old FF support
+ ===========================*/
+ if (!window.addEventListener) {
+ if (!window.Element)
+ Element = function () { };
+
+ Element.prototype.addEventListener = HTMLDocument.prototype.addEventListener = addEventListener = function (type, listener, useCapture) { this.attachEvent('on' + type, listener); }
+ Element.prototype.removeEventListener = HTMLDocument.prototype.removeEventListener = removeEventListener = function (type, listener, useCapture) { this.detachEvent('on' + type, listener); }
+ }
+
+ if (document.body.__defineGetter__) {
+ if (HTMLElement) {
+ var element = HTMLElement.prototype;
+ if (element.__defineGetter__)
+ element.__defineGetter__("outerHTML", function () { return new XMLSerializer().serializeToString(this); } );
+ }
+ }
+
+ if (!window.getComputedStyle) {
+ window.getComputedStyle = function (el, pseudo) {
+ this.el = el;
+ this.getPropertyValue = function (prop) {
+ var re = /(\-([a-z]){1})/g;
+ if (prop == 'float') prop = 'styleFloat';
+ if (re.test(prop)) {
+ prop = prop.replace(re, function () {
+ return arguments[2].toUpperCase();
+ });
+ }
+ return el.currentStyle[prop] ? el.currentStyle[prop] : null;
+ }
+ return this;
+ }
+ }
+
+ /* End Of Polyfills*/
+ if(!(selector.nodeType))
+ if (!document.querySelectorAll||document.querySelectorAll(selector).length==0) return;
+
+ function dQ(s) {
+ return document.querySelectorAll(s)
+ }
+ var _this = this
+ _this.touches = {};
+ _this.positions = {
+ current : 0
+ };
+ _this.id = (new Date()).getTime();
+ _this.container = (selector.nodeType) ? selector : dQ(selector)[0];
+ _this.times = {};
+ _this.isTouched = false;
+ _this.realIndex = 0;
+ _this.activeSlide = 0;
_this.previousSlide = null;
- _this.langDirection = window.getComputedStyle(_this.container, null).getPropertyValue('direction')
- /*=========================
- New Support Object
- ===========================*/
- _this.support = {
- touch : _this.isSupportTouch(),
- threeD : _this.isSupport3D()
- }
- //For fallback with older versions
- _this.use3D = _this.support.threeD;
-
-
- /*=========================
- Default Parameters
- ===========================*/
- var defaults = {
- mode : 'horizontal',
- ratio : 1,
- speed : 300,
- freeMode : false,
- freeModeFluid : false,
- slidesPerSlide : 1,
- simulateTouch : true,
- followFinger : true,
- autoPlay:false,
- onlyExternal : false,
- createPagination : true,
- pagination : false,
- resistance : true,
- scrollContainer : false,
- preventLinks : true,
- initialSlide: 0,
- keyboardControl: false,
- mousewheelControl : false,
- //Namespace
- slideClass : 'swiper-slide',
- wrapperClass : 'swiper-wrapper',
- paginationClass: 'swiper-pagination-switch' ,
- paginationActiveClass : 'swiper-active-switch'
- }
- params = params || {};
- for (var prop in defaults) {
- if (! (prop in params)) {
- params[prop] = defaults[prop]
- }
- }
- _this.params = params;
- if (params.scrollContainer) {
- params.freeMode = true;
- params.freeModeFluid = true;
- }
- var _widthFromCSS = false
- if (params.slidesPerSlide=='auto') {
- _widthFromCSS = true;
- params.slidesPerSlide = 1;
- }
-
- //Default Vars
- var wrapper, isHorizontal,
- slideSize, numOfSlides, wrapperSize, direction, isScrolling, containerSize;
-
- //Define wrapper
- for (var i = _this.container.childNodes.length - 1; i >= 0; i--) {
-
- if (_this.container.childNodes[i].className) {
+ _this.langDirection = window.getComputedStyle(_this.container, null).getPropertyValue('direction')
+ /*=========================
+ New Support Object
+ ===========================*/
+ _this.support = {
+ touch : _this.isSupportTouch(),
+ threeD : _this.isSupport3D()
+ }
+ //For fallback with older versions
+ _this.use3D = _this.support.threeD;
+
+
+ /*=========================
+ Default Parameters
+ ===========================*/
+ var defaults = {
+ mode : 'horizontal',
+ ratio : 1,
+ speed : 300,
+ freeMode : false,
+ freeModeFluid : false,
+ slidesPerSlide : 1,
+ slidesPerGroup : 1,
+ simulateTouch : true,
+ followFinger : true,
+ autoPlay:false,
+ onlyExternal : false,
+ createPagination : true,
+ pagination : false,
+ resistance : true,
+ scrollContainer : false,
+ preventLinks : true,
+ initialSlide: 0,
+ keyboardControl: false,
+ mousewheelControl : false,
+ resizeEvent : 'auto', //or 'resize' or 'orientationchange'
+ //Namespace
+ slideClass : 'swiper-slide',
+ wrapperClass : 'swiper-wrapper',
+ paginationClass: 'swiper-pagination-switch' ,
+ paginationActiveClass : 'swiper-active-switch'
+ }
+ params = params || {};
+ for (var prop in defaults) {
+ if (! (prop in params)) {
+ params[prop] = defaults[prop]
+ }
+ }
+ _this.params = params;
+ if (params.scrollContainer) {
+ params.freeMode = true;
+ params.freeModeFluid = true;
+ }
+ var _widthFromCSS = false
+ if (params.slidesPerSlide=='auto') {
+ _widthFromCSS = true;
+ params.slidesPerSlide = 1;
+ }
+
+ //Default Vars
+ var wrapper, isHorizontal,
+ slideSize, numOfSlides, wrapperSize, direction, isScrolling, containerSize;
+
+ //Define wrapper
+ for (var i = _this.container.childNodes.length - 1; i >= 0; i--) {
+
+ if (_this.container.childNodes[i].className) {
- var _wrapperClasses = _this.container.childNodes[i].className.split(' ')
+ var _wrapperClasses = _this.container.childNodes[i].className.split(' ')
- for (var j = 0; j < _wrapperClasses.length; j++) {
- if (_wrapperClasses[j]===params.wrapperClass) {
- wrapper = _this.container.childNodes[i]
- }
- };
- }
- };
+ for (var j = 0; j < _wrapperClasses.length; j++) {
+ if (_wrapperClasses[j]===params.wrapperClass) {
+ wrapper = _this.container.childNodes[i]
+ }
+ };
+ }
+ };
- _this.wrapper = wrapper;
- //Mode
- isHorizontal = params.mode == 'horizontal';
-
- //Define Touch Events
- _this.touchEvents = {
- touchStart : _this.support.touch || !params.simulateTouch ? 'touchstart' : (_this.ie10 ? 'MSPointerDown' : 'mousedown'),
- touchMove : _this.support.touch || !params.simulateTouch ? 'touchmove' : (_this.ie10 ? 'MSPointerMove' : 'mousemove'),
- touchEnd : _this.support.touch || !params.simulateTouch ? 'touchend' : (_this.ie10 ? 'MSPointerUp' : 'mouseup')
- };
-
- /*=========================
- Slide API
- ===========================*/
- _this._extendSwiperSlide = function (el) {
- el.append = function () {
- _this.wrapper.appendChild(el);
- _this.reInit();
- return el;
- }
- el.prepend = function () {
- _this.wrapper.insertBefore(el, _this.wrapper.firstChild)
- _this.reInit();
- return el;
- }
- el.insertAfter = function (index) {
- if(typeof index === undefined) return false;
- var beforeSlide = _this.slides[index+1]
- _this.wrapper.insertBefore(el, beforeSlide)
- _this.reInit();
- return el;
- }
- el.clone = function () {
- return _this._extendSwiperSlide(el.cloneNode(true))
- }
- el.remove = function () {
- _this.wrapper.removeChild(el);
- _this.reInit()
- }
- el.html = function (html) {
- if (typeof html == undefined) {
- return el.innerHTML
- }
- else {
- el.innerHTML = html;
- return el;
- }
- }
- el.index = function () {
- var index
- for (var i = _this.slides.length - 1; i >= 0; i--) {
- if(el==_this.slides[i]) index = i
- };
- return index;
- }
- el.isActive = function () {
- if (el.index() == _this.activeSlide) return true;
- else return false;
- }
- if (!el.swiperSlideDataStorage) el.swiperSlideDataStorage={};
- el.getData = function (name) {
- return el.swiperSlideDataStorage[name]
- }
- el.setData = function (name, value) {
- el.swiperSlideDataStorage[name] = value;
- return el;
- }
- el.data = function (name, value) {
- if (!value) {
- return el.getAttribute('data-'+name);
- }
- else {
- el.setAttribute('data-'+name,value);
- return el;
- }
- }
- return el;
- }
+ _this.wrapper = wrapper;
+ //Mode
+ isHorizontal = params.mode == 'horizontal';
+
+ //Define Touch Events
+ _this.touchEvents = {
+ touchStart : _this.support.touch || !params.simulateTouch ? 'touchstart' : (_this.ie10 ? 'MSPointerDown' : 'mousedown'),
+ touchMove : _this.support.touch || !params.simulateTouch ? 'touchmove' : (_this.ie10 ? 'MSPointerMove' : 'mousemove'),
+ touchEnd : _this.support.touch || !params.simulateTouch ? 'touchend' : (_this.ie10 ? 'MSPointerUp' : 'mouseup')
+ };
+
+ /*=========================
+ Slide API
+ ===========================*/
+ _this._extendSwiperSlide = function (el) {
+ el.append = function () {
+ _this.wrapper.appendChild(el);
+ _this.reInit();
+ return el;
+ }
+ el.prepend = function () {
+ _this.wrapper.insertBefore(el, _this.wrapper.firstChild)
+ _this.reInit();
+ return el;
+ }
+ el.insertAfter = function (index) {
+ if(typeof index === undefined) return false;
+ var beforeSlide = _this.slides[index+1]
+ _this.wrapper.insertBefore(el, beforeSlide)
+ _this.reInit();
+ return el;
+ }
+ el.clone = function () {
+ return _this._extendSwiperSlide(el.cloneNode(true))
+ }
+ el.remove = function () {
+ _this.wrapper.removeChild(el);
+ _this.reInit()
+ }
+ el.html = function (html) {
+ if (typeof html === undefined) {
+ return el.innerHTML
+ }
+ else {
+ el.innerHTML = html;
+ return el;
+ }
+ }
+ el.index = function () {
+ var index
+ for (var i = _this.slides.length - 1; i >= 0; i--) {
+ if(el==_this.slides[i]) index = i
+ };
+ return index;
+ }
+ el.isActive = function () {
+ if (el.index() == _this.activeSlide) return true;
+ else return false;
+ }
+ if (!el.swiperSlideDataStorage) el.swiperSlideDataStorage={};
+ el.getData = function (name) {
+ return el.swiperSlideDataStorage[name]
+ }
+ el.setData = function (name, value) {
+ el.swiperSlideDataStorage[name] = value;
+ return el;
+ }
+ el.data = function (name, value) {
+ if (!value) {
+ return el.getAttribute('data-'+name);
+ }
+ else {
+ el.setAttribute('data-'+name,value);
+ return el;
+ }
+ }
+ return el;
+ }
- //Calculate information about slides
- _this._calcSlides = function () {
- var oldNumber = _this.slides ? _this.slides.length : false;
- _this.slides = []
- for (var i = 0; i < _this.wrapper.childNodes.length; i++) {
- if (_this.wrapper.childNodes[i].className) {
- var _slideClasses = _this.wrapper.childNodes[i].className.split(' ')
- for (var j = 0; j < _slideClasses.length; j++) {
- if(_slideClasses[j]===params.slideClass) _this.slides.push(_this.wrapper.childNodes[i])
- };
- }
- };
- for (var i = _this.slides.length - 1; i >= 0; i--) {
- _this._extendSwiperSlide(_this.slides[i]);
- };
- if (!oldNumber) return;
- if(oldNumber!=_this.slides.length && _this.createPagination) {
- // Number of slides has been changed
- _this.createPagination();
- _this.callPlugins('numberOfSlidesChanged')
- }
- /*
- if (_this.langDirection=='rtl') {
- for (var i = 0; i < _this.slides.length; i++) {
- _this.slides[i].style.float="right"
- };
- }
- */
- }
- _this._calcSlides();
+ //Calculate information about slides
+ _this._calcSlides = function () {
+ var oldNumber = _this.slides ? _this.slides.length : false;
+ _this.slides = []
+ for (var i = 0; i < _this.wrapper.childNodes.length; i++) {
+ if (_this.wrapper.childNodes[i].className) {
+ var _slideClasses = _this.wrapper.childNodes[i].className.split(' ')
+ for (var j = 0; j < _slideClasses.length; j++) {
+ if(_slideClasses[j]===params.slideClass) _this.slides.push(_this.wrapper.childNodes[i])
+ };
+ }
+ };
+ for (var i = _this.slides.length - 1; i >= 0; i--) {
+ _this._extendSwiperSlide(_this.slides[i]);
+ };
+ if (!oldNumber) return;
+ if(oldNumber!=_this.slides.length && _this.createPagination) {
+ // Number of slides has been changed
+ _this.createPagination();
+ _this.callPlugins('numberOfSlidesChanged')
+ }
+ /*
+ if (_this.langDirection=='rtl') {
+ for (var i = 0; i < _this.slides.length; i++) {
+ _this.slides[i].style.float="right"
+ };
+ }
+ */
+ }
+ _this._calcSlides();
- //Create Slide
- _this.createSlide = function (html, slideClassList, el) {
- var slideClassList = slideClassList || _this.params.slideClass;
- var el = el||'div';
- var newSlide = document.createElement(el)
- newSlide.innerHTML = html||'';
- newSlide.className = slideClassList;
- return _this._extendSwiperSlide(newSlide);
- }
+ //Create Slide
+ _this.createSlide = function (html, slideClassList, el) {
+ var slideClassList = slideClassList || _this.params.slideClass;
+ var el = el||'div';
+ var newSlide = document.createElement(el)
+ newSlide.innerHTML = html||'';
+ newSlide.className = slideClassList;
+ return _this._extendSwiperSlide(newSlide);
+ }
- //Append Slide
- _this.appendSlide = function (html, slideClassList, el) {
- if (!html) return;
- if (html.nodeType) {
- return _this._extendSwiperSlide(html).append()
- }
- else {
- return _this.createSlide(html, slideClassList, el).append()
- }
- }
- _this.prependSlide = function (html, slideClassList, el) {
- if (!html) return;
- if (html.nodeType) {
- return _this._extendSwiperSlide(html).prepend()
- }
- else {
- return _this.createSlide(html, slideClassList, el).prepend()
- }
- }
- _this.insertSlideAfter = function (index, html, slideClassList, el) {
- if (!index) return false;
- if (index.nodeType) {
- return _this._extendSwiperSlide(index).insertAfter(index)
- }
- else {
- return _this.createSlide(html, slideClassList, el).insertAfter(index)
- }
- }
- _this.removeSlide = function (index) {
- if (_this.slides[index]) {
- _this.slides[index].remove()
- return true;
- }
- else return false;
- }
- _this.removeLastSlide = function () {
- if (_this.slides.length>0) {
- _this.slides[ (_this.slides.length-1) ].remove();
- return true
- }
- else {
- return false
- }
- }
- _this.removeAllSlides = function () {
- for (var i = _this.slides.length - 1; i >= 0; i--) {
- _this.slides[i].remove()
- };
- }
- _this.getSlide = function (index) {
- return _this.slides[index]
- }
- _this.getLastSlide = function () {
- return _this.slides[ _this.slides.length-1 ]
- }
- _this.getFirstSlide = function () {
- return _this.slides[0]
- }
+ //Append Slide
+ _this.appendSlide = function (html, slideClassList, el) {
+ if (!html) return;
+ if (html.nodeType) {
+ return _this._extendSwiperSlide(html).append()
+ }
+ else {
+ return _this.createSlide(html, slideClassList, el).append()
+ }
+ }
+ _this.prependSlide = function (html, slideClassList, el) {
+ if (!html) return;
+ if (html.nodeType) {
+ return _this._extendSwiperSlide(html).prepend()
+ }
+ else {
+ return _this.createSlide(html, slideClassList, el).prepend()
+ }
+ }
+ _this.insertSlideAfter = function (index, html, slideClassList, el) {
+ if (!index) return false;
+ if (index.nodeType) {
+ return _this._extendSwiperSlide(index).insertAfter(index)
+ }
+ else {
+ return _this.createSlide(html, slideClassList, el).insertAfter(index)
+ }
+ }
+ _this.removeSlide = function (index) {
+ if (_this.slides[index]) {
+ _this.slides[index].remove()
+ return true;
+ }
+ else return false;
+ }
+ _this.removeLastSlide = function () {
+ if (_this.slides.length>0) {
+ _this.slides[ (_this.slides.length-1) ].remove();
+ return true
+ }
+ else {
+ return false
+ }
+ }
+ _this.removeAllSlides = function () {
+ for (var i = _this.slides.length - 1; i >= 0; i--) {
+ _this.slides[i].remove()
+ };
+ }
+ _this.getSlide = function (index) {
+ return _this.slides[index]
+ }
+ _this.getLastSlide = function () {
+ return _this.slides[ _this.slides.length-1 ]
+ }
+ _this.getFirstSlide = function () {
+ return _this.slides[0]
+ }
- //Currently Active Slide
- _this.currentSlide = function () {
- return _this.slides[_this.activeSlide]
- }
-
- /*=========================
- Find All Plugins
- !!! Plugins API is in beta !!!
- ===========================*/
- var _plugins = [];
- for (var plugin in _this.plugins) {
- if (params[plugin]) {
- var p = _this.plugins[plugin](_this, params[plugin])
- if (p)
- _plugins.push( p )
- }
- }
-
- _this.callPlugins = function(method, args) {
- if (!args) args = {}
- for (var i=0; i<_plugins.length; i++) {
- if (method in _plugins[i]) {
- _plugins[i][method](args);
- }
+ //Currently Active Slide
+ _this.currentSlide = function () {
+ return _this.slides[_this.activeSlide]
+ }
+
+ /*=========================
+ Find All Plugins
+ !!! Plugins API is in beta !!!
+ ===========================*/
+ var _plugins = [];
+ for (var plugin in _this.plugins) {
+ if (params[plugin]) {
+ var p = _this.plugins[plugin](_this, params[plugin])
+ if (p)
+ _plugins.push( p )
+ }
+ }
+
+ _this.callPlugins = function(method, args) {
+ if (!args) args = {}
+ for (var i=0; i<_plugins.length; i++) {
+ if (method in _plugins[i]) {
+ _plugins[i][method](args);
+ }
- }
-
- }
+ }
+
+ }
- /*=========================
- WP8 Fix
- ===========================*/
- if (_this.ie10 && !params.onlyExternal) {
- if (isHorizontal) _this.wrapper.classList.add('swiper-wp8-horizontal')
- else _this.wrapper.classList.add('swiper-wp8-vertical')
- }
-
- /*=========================
- Loop
- ===========================*/
- if (params.loop) {
- (function(){
- numOfSlides = _this.slides.length
- var slideFirstHTML = '';
- var slideLastHTML = '';
- //Grab First Slides
- for (var i=0; i0) ) {
- newWidth = _this.container.offsetWidth - parseInt(window.getComputedStyle(_this.container, null).getPropertyValue('padding-left'),10) - parseInt(window.getComputedStyle(_this.container, null).getPropertyValue('padding-right'),10)
- }
- if(isNaN(newHeight) || _this.ie8 && (_height.indexOf('%')>0) ) {
- newHeight = _this.container.offsetHeight - parseInt(window.getComputedStyle(_this.container, null).getPropertyValue('padding-top'),10) - parseInt(window.getComputedStyle(_this.container, null).getPropertyValue('padding-bottom'),10)
- }
-
- if (!reInit) {
- if (_this.width==newWidth && _this.height==newHeight) return
- }
- if (reInit || firstInit) {
- _this._calcSlides();
- if (params.pagination) {
- _this.updatePagination()
- }
- }
- _this.width = newWidth;
- _this.height = newHeight;
-
- var dividerVertical = isHorizontal ? 1 : params.slidesPerSlide,
- dividerHorizontal = isHorizontal ? params.slidesPerSlide : 1,
- slideWidth, slideHeight, wrapperWidth, wrapperHeight;
+ _this.init = function(reInit) {
+ var _width = window.getComputedStyle(_this.container, null).getPropertyValue('width')
+ var _height = window.getComputedStyle(_this.container, null).getPropertyValue('height')
+ var newWidth = parseInt(_width,10);
+ var newHeight = parseInt(_height,10);
+
+ //IE8 Fixes
+ if(isNaN(newWidth) || _this.ie8 && (_width.indexOf('%')>0) ) {
+ newWidth = _this.container.offsetWidth - parseInt(window.getComputedStyle(_this.container, null).getPropertyValue('padding-left'),10) - parseInt(window.getComputedStyle(_this.container, null).getPropertyValue('padding-right'),10)
+ }
+ if(isNaN(newHeight) || _this.ie8 && (_height.indexOf('%')>0) ) {
+ newHeight = _this.container.offsetHeight - parseInt(window.getComputedStyle(_this.container, null).getPropertyValue('padding-top'),10) - parseInt(window.getComputedStyle(_this.container, null).getPropertyValue('padding-bottom'),10)
+ }
+
+ if (!reInit) {
+ if (_this.width==newWidth && _this.height==newHeight) return
+ }
+ if (reInit || firstInit) {
+ _this._calcSlides();
+ if (params.pagination) {
+ _this.updatePagination()
+ }
+ }
+ _this.width = newWidth;
+ _this.height = newHeight;
+
+ var dividerVertical = isHorizontal ? 1 : params.slidesPerSlide,
+ dividerHorizontal = isHorizontal ? params.slidesPerSlide : 1,
+ slideWidth, slideHeight, wrapperWidth, wrapperHeight;
- numOfSlides = _this.slides.length
- if (!params.scrollContainer) {
- if (!_widthFromCSS) {
- slideWidth = _this.width/dividerHorizontal;
- slideHeight = _this.height/dividerVertical;
- }
- else {
- slideWidth = _this.slides[0].offsetWidth;
- slideHeight = _this.slides[0].offsetHeight;
- }
- containerSize = isHorizontal ? _this.width : _this.height;
- slideSize = isHorizontal ? slideWidth : slideHeight;
- wrapperWidth = isHorizontal ? numOfSlides * slideWidth : _this.width;
- wrapperHeight = isHorizontal ? _this.height : numOfSlides*slideHeight;
- if (_widthFromCSS) {
- //Re-Calc sps for pagination
- params.slidesPerSlide = Math.round(containerSize/slideSize)
- }
- }
- else {
- //Unset dimensions in vertical scroll container mode to recalculate slides
- if (!isHorizontal) {
- wrapper.style.width='';
- wrapper.style.height='';
- _this.slides[0].style.width='';
- _this.slides[0].style.height='';
- }
-
- slideWidth = _this.slides[0].offsetWidth;
- slideHeight = _this.slides[0].offsetHeight;
- containerSize = isHorizontal ? _this.width : _this.height;
-
- slideSize = isHorizontal ? slideWidth : slideHeight;
- wrapperWidth = slideWidth;
- wrapperHeight = slideHeight;
- }
+ numOfSlides = _this.slides.length
+ if (!params.scrollContainer) {
+ if (!_widthFromCSS) {
+ slideWidth = _this.width/dividerHorizontal;
+ slideHeight = _this.height/dividerVertical;
+ }
+ else {
+ slideWidth = _this.slides[0].offsetWidth;
+ slideHeight = _this.slides[0].offsetHeight;
+ }
+ containerSize = isHorizontal ? _this.width : _this.height;
+ slideSize = isHorizontal ? slideWidth : slideHeight;
+ wrapperWidth = isHorizontal ? numOfSlides * slideWidth : _this.width;
+ wrapperHeight = isHorizontal ? _this.height : numOfSlides*slideHeight;
+ if (_widthFromCSS) {
+ //Re-Calc sps for pagination
+ params.slidesPerSlide = Math.round(containerSize/slideSize)
+ }
+ }
+ else {
+ //Unset dimensions in vertical scroll container mode to recalculate slides
+ if (!isHorizontal) {
+ wrapper.style.width='';
+ wrapper.style.height='';
+ _this.slides[0].style.width='';
+ _this.slides[0].style.height='';
+ }
+
+ slideWidth = _this.slides[0].offsetWidth;
+ slideHeight = _this.slides[0].offsetHeight;
+ containerSize = isHorizontal ? _this.width : _this.height;
+
+ slideSize = isHorizontal ? slideWidth : slideHeight;
+ wrapperWidth = slideWidth;
+ wrapperHeight = slideHeight;
+ }
- wrapperSize = isHorizontal ? wrapperWidth : wrapperHeight;
-
- for (var i=0; i<_this.slides.length; i++ ) {
- var el = _this.slides[i];
- if (!_widthFromCSS) {
- el.style.width=slideWidth+"px"
- el.style.height=slideHeight+"px"
- }
- if (params.onSlideInitialize) {
- params.onSlideInitialize(_this, el);
- }
- }
- wrapper.style.width = wrapperWidth+"px";
- wrapper.style.height = wrapperHeight+"px";
-
- // Set Initial Slide Position
- if(params.initialSlide > 0 && params.initialSlide < numOfSlides && !firstInit) {
- _this.realIndex = _this.activeSlide = params.initialSlide;
-
- if (params.loop) {
+ wrapperSize = isHorizontal ? wrapperWidth : wrapperHeight;
+
+ for (var i=0; i<_this.slides.length; i++ ) {
+ var el = _this.slides[i];
+ if (!_widthFromCSS) {
+ el.style.width=slideWidth+"px"
+ el.style.height=slideHeight+"px"
+ }
+ if (params.onSlideInitialize) {
+ params.onSlideInitialize(_this, el);
+ }
+ }
+ wrapper.style.width = wrapperWidth+"px";
+ wrapper.style.height = wrapperHeight+"px";
+
+ // Set Initial Slide Position
+ if(params.initialSlide > 0 && params.initialSlide < numOfSlides && !firstInit) {
+ _this.realIndex = _this.activeSlide = params.initialSlide;
+
+ if (params.loop) {
_this.activeSlide = _this.realIndex-params.slidesPerSlide
}
-
- if (isHorizontal) {
- _this.positions.current = -params.initialSlide * slideWidth;
- _this.setTransform( _this.positions.current, 0, 0);
- }
- else {
- _this.positions.current = -params.initialSlide * slideHeight;
- _this.setTransform( 0, _this.positions.current, 0);
- }
- }
-
- // if (params.slidesPerSlide && params.slidesPerSlide > 1) {
- // slideSize = slideSize/params.slidesPerSlide
- // }
- // slideSize = 150;
- if (!firstInit) _this.callPlugins('onFirstInit');
- else _this.callPlugins('onInit');
-
- firstInit = true;
- }
- _this.init()
+
+ if (isHorizontal) {
+ _this.positions.current = -params.initialSlide * slideWidth;
+ _this.setTransform( _this.positions.current, 0, 0);
+ }
+ else {
+ _this.positions.current = -params.initialSlide * slideHeight;
+ _this.setTransform( 0, _this.positions.current, 0);
+ }
+ }
+
+ if (!firstInit) _this.callPlugins('onFirstInit');
+ else _this.callPlugins('onInit');
+ firstInit = true;
+ }
+ _this.init()
- //ReInitizize function. Good to use after dynamically changes of Swiper, like after add/remove slides
- _this.reInit = function () {
- _this.init(true)
- }
-
-
+ //ReInitizize function. Good to use after dynamically changes of Swiper, like after add/remove slides
+ _this.reInit = function () {
+ _this.init(true)
+ }
+
+ //Get Max And Min Positions
+ function maxPos() {
+ var a = (wrapperSize - containerSize);
+ if (params.loop) a = a - containerSize;
+ if (params.scrollContainer) {
+ a = slideSize - containerSize;
+ if (a<0) a = 0;
+ }
+ if (params.slidesPerSlide > _this.slides.length) a = 0;
+ return a;
+ }
+ function minPos() {
+ var a = 0;
+ if (params.loop) a = containerSize;
+ return a;
+ }
+
+ /*=========================
+ Pagination
+ ===========================*/
+ _this.updatePagination = function() {
+ if (_this.slides.length<2) return;
+ var activeSwitch = dQ(params.pagination+' .'+params.paginationActiveClass)
+ if(!activeSwitch) return
+ for (var i=0; i < activeSwitch.length; i++) {
+ activeSwitch.item(i).className = params.paginationClass
+ }
+ var pagers = dQ(params.pagination+' .'+params.paginationClass).length;
+ var minPagerIndex = params.loop ? _this.realIndex-params.slidesPerSlide : _this.realIndex;
+ var maxPagerIndex = minPagerIndex + (params.slidesPerSlide-1);
+ for (var i = minPagerIndex; i <= maxPagerIndex; i++ ) {
+ var j = i;
+ if (j>=pagers) j=j-pagers;
+ if (j<0) j = pagers + j;
+ if (j