27 lines
593 B
JavaScript
27 lines
593 B
JavaScript
{fa1fde453c642692d9fe26aefcb098962311bdd8 true 593 index.js 0xc0030baa80}
const imageContainerEl = document.querySelector(".image-container");
|
|
|
|
const prevEl = document.getElementById("prev");
|
|
const nextEl = document.getElementById("next");
|
|
let x = 0;
|
|
let timer;
|
|
prevEl.addEventListener("click", () => {
|
|
x = x + 45;
|
|
clearTimeout(timer);
|
|
updateGallery();
|
|
});
|
|
nextEl.addEventListener("click", () => {
|
|
x = x - 45;
|
|
clearTimeout(timer);
|
|
updateGallery();
|
|
});
|
|
|
|
function updateGallery() {
|
|
imageContainerEl.style.transform = `perspective(1000px) rotateY(${x}deg)`;
|
|
timer = setTimeout(() => {
|
|
x = x - 45;
|
|
updateGallery();
|
|
}, 3000);
|
|
}
|
|
|
|
updateGallery();
|