fipamo/content/themes/fipamo-default-v2/assets/scripts/Base.js

36 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

export default class Base {
//--------------------------
// constructor
//--------------------------
constructor() {
this.currentSlide = 0;
this.slides = document.querySelectorAll('.slide');
//alert('FRESH');
document.getElementById('menu-open').addEventListener('click', e => {
document.getElementById('menu').style.opacity = '100%';
document.getElementById('menu').style.visibility = 'visible';
});
document.getElementById('menu-close').addEventListener('click', e => {
document.getElementById('menu').style.opacity = '0';
document.getElementById('menu').style.visibility = 'hidden';
});
this.start();
}
start() {
if (this.slides.length > 1) {
this.slideInterval = setInterval(() => {
this.slides[this.currentSlide].className = 'hide slide';
this.currentSlide = (this.currentSlide + 1) % this.slides.length;
this.slides[this.currentSlide].className = 'show slide';
}, 3000);
}
}
//--------------------------
// methods
//--------------------------
//--------------------------
// event handlers
//--------------------------
}