diff --git a/js/Slideshow.js b/js/Slideshow.js new file mode 100644 index 0000000000000000000000000000000000000000..514156834f5d1cd0aa191ba21886d5c3f47c3591 --- /dev/null +++ b/js/Slideshow.js @@ -0,0 +1,29 @@ +export class Slideshow { + + constructor(image, element) { + this.images = image.split(','); + this.element = element; + this._index = 0; + this.show(this.images[this._index]); + } + + show(image) { + this.element.html(`<a href="images/${image}.gif"> + <img src="images/${image}.gif" /></a>`); + } + + next() { + this._index = this._index + 1 < this.images.length ? this._index + 1 : 0; + this.show(this.images[this._index]); + } + + prev() { + this._index = this._index - 1 > -1 ? this._index - 1 : this.images.length - 1; + this.show(this.images[this._index]); + } + + get index() { + return this._index; + } + +} \ No newline at end of file