Skip to content

Commit

Permalink
Add carousel support cycle option
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyguitar committed Aug 28, 2016
1 parent f1b657e commit bf2e06f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/layout/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,25 @@ Carousel.prototype.move = function() {

Carousel.prototype.next = function() {
this.currPage++
if (this.currPage==this.pages.length) this.currPage=0
if (this.currPage==this.pages.length){
if (!this.options.cycle) {
this.currPage--;
} else {
this.currPage=0
}
}
this.move()
}

Carousel.prototype.prev = function() {
this.currPage--
if (this.currPage<0) this.currPage=this.pages.length-1
if (this.currPage<0) {
if (!this.options.cycle) {
this.currPage++;
} else {
this.currPage=this.pages.length-1
}
}
this.move()
}

Expand All @@ -47,4 +59,4 @@ Carousel.prototype.start = function() {

}

module.exports = Carousel
module.exports = Carousel

0 comments on commit bf2e06f

Please sign in to comment.