diff --git a/index.js b/index.js index f8adf3b..ee87478 100644 --- a/index.js +++ b/index.js @@ -731,16 +731,31 @@ Code related to auotplay features of the carousel }, methods: { autoplayStart: function () { + // Don't loop if we only have one page + if (this.pages <= 0) { + return; + } + if (this.autoplayDelay) { return this.autoPlayInterval = setInterval(() => { if (!this.autoplayPaused) { - return this.next(); + return this.autoplayNext(); } }, this.autoplayDelay * 1000); } }, autoplayStop: function () { return clearInterval(this.autoPlayInterval); + }, + autoplayNext: function () { + var nextIndex; + nextIndex = this.index + 1; + + if (nextIndex < this.pages) { + return this.next(); + } else { + return this.goto(0); + } } } }); diff --git a/package.json b/package.json index 7ad82bd..5ec2438 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-ssr-carousel", - "version": "0.3.0", + "version": "0.3.1", "description": "A performance focused Vue carousel designed for SSR/SSG environments.", "main": "index.js", "scripts": {