Skip to content

Commit

Permalink
Added directional classes in gotoSlide()
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbitron committed Sep 9, 2014
1 parent b8e9778 commit 018c87f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion ideal-image-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,8 @@ var IdealImageSlider = (function() {
this._attributes.currentSlide.setAttribute('aria-hidden', 'true');

index--; // Index should be 1-indexed
var slides = this._attributes.slides;
var slides = this._attributes.slides,
oldIndex = slides.indexOf(this._attributes.currentSlide);
this._attributes.previousSlide = slides[index-1];
this._attributes.currentSlide = slides[index];
this._attributes.nextSlide = slides[index+1];
Expand All @@ -616,6 +617,18 @@ var IdealImageSlider = (function() {
_addClass(this._attributes.nextSlide, this.settings.classes.nextSlide);
this._attributes.currentSlide.setAttribute('aria-hidden', 'false');

if(index < oldIndex){
_addClass(this._attributes.container, this.settings.classes.directionPrevious);
setTimeout(function(){
_removeClass(this._attributes.container, this.settings.classes.directionPrevious);
}.bind(this), this.settings.transitionDuration);
} else {
_addClass(this._attributes.container, this.settings.classes.directionNext);
setTimeout(function(){
_removeClass(this._attributes.container, this.settings.classes.directionNext);
}.bind(this), this.settings.transitionDuration);
}

if(this.settings.transitionDuration){
_addClass(this._attributes.container, this.settings.classes.animating);
setTimeout(function(){
Expand All @@ -642,6 +655,9 @@ var IdealImageSlider = (function() {
};

return {
_hasClass: _hasClass,
_addClass: _addClass,
_removeClass: _removeClass,
Slider: Slider
};

Expand Down
Loading

0 comments on commit 018c87f

Please sign in to comment.