Skip to content

Commit

Permalink
Make smoother swipe animation
Browse files Browse the repository at this point in the history
supportClassList to support.classList
  • Loading branch information
Dongseok.Paeng committed Mar 12, 2014
1 parent 13006be commit 4e2069c
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions lib/idangerous.swiper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1973,17 +1973,30 @@ var Swiper = function (selector, params) {
_this.calcVisibleSlides(position);

// Mark visible and active slides with additonal classes
var activeClassRegexp = new RegExp('\\s*' + params.slideActiveClass);
var inViewClassRegexp = new RegExp('\\s*' + params.slideVisibleClass);

for (var j = 0; j < _this.slides.length; j++) {
_this.slides[j].className = _this.slides[j].className.replace(activeClassRegexp, '').replace(inViewClassRegexp, '');
if (_this.visibleSlides.indexOf(_this.slides[j]) >= 0) {
_this.slides[j].className += ' ' + params.slideVisibleClass;
if (_this.support.classList) {
var slide;
for (var i = 0; i < _this.slides.length; i++) {
slide = _this.slides[i];
slide.classList.remove(params.slideActiveClass);
if ( _this.visibleSlides.indexOf( slide )>=0 ) {
slide.classList.add(params.slideVisibleClass);
} else {
slide.classList.remove(params.slideVisibleClass);
}
}
_this.slides[ _this.activeIndex ].classList.add(params.slideActiveClass);
} else {
var activeClassRegexp = new RegExp( "\\s*" + params.slideActiveClass );
var inViewClassRegexp = new RegExp( "\\s*" + params.slideVisibleClass );

for (var i = 0; i < _this.slides.length; i++) {
_this.slides[ i ].className = _this.slides[ i ].className.replace( activeClassRegexp, '' ).replace( inViewClassRegexp, '' );
if ( _this.visibleSlides.indexOf( _this.slides[ i ] )>=0 ) {
_this.slides[ i ].className += ' ' + params.slideVisibleClass;
}
}
_this.slides[ _this.activeIndex ].className += ' ' + params.slideActiveClass;
}
_this.slides[_this.activeIndex].className += ' ' + params.slideActiveClass;

//Update loop index
if (params.loop) {
Expand Down Expand Up @@ -2689,6 +2702,10 @@ Swiper.prototype = {
'use strict';
var div = document.createElement('div').style;
return ('transition' in div || 'WebkitTransition' in div || 'MozTransition' in div || 'msTransition' in div || 'MsTransition' in div || 'OTransition' in div);
})(),

classList : (function() {
return 'classList' in document.body;
})()
},

Expand Down

0 comments on commit 4e2069c

Please sign in to comment.