Skip to content

Commit

Permalink
Added looping, start on random slide
Browse files Browse the repository at this point in the history
  • Loading branch information
dhochbaum-dcp committed Apr 16, 2024
1 parent 044b6d1 commit 401981d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/components/default-modal.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
import Component from '@ember/component';

const TOTAL_SLIDES = 3;

export default Component.extend({
tagName: '',
open: true,
slideNumber: 1,
totalSlides: 3,
slideNumber: Math.floor(Math.random() * TOTAL_SLIDES) + 1, // start on a random slide

actions: {
toggleModal() {
this.toggleProperty('open');
},
nextSlide() {
if (this.slideNumber < this.totalSlides) {
if (this.slideNumber < TOTAL_SLIDES) {
this.set('slideNumber', this.slideNumber + 1);
} else {
// comment out the line below to disable infinite looping
this.set('slideNumber', 1);
}
},
prevSlide() {
if (this.slideNumber > 1) {
this.set('slideNumber', this.slideNumber - 1);
} else {
// comment out the line below to disable infinite looping
this.set('slideNumber', TOTAL_SLIDES);
}
},
},
Expand Down

0 comments on commit 401981d

Please sign in to comment.