RetroDECK-Website/scripts/carousel.js
Adam Iannazzone fe73cca82a Adjust animation for stacks < 3 images
- Disable eventlistener on 1-image stacks
- Remove cursor on 1-image stacks
2024-10-17 10:47:58 -04:00

26 lines
782 B
JavaScript

let timing = 250;
let stacks = document.getElementsByClassName('stack');
for (let i = 0; i < stacks.length; i++) {
[...stacks[i].children].reverse().forEach(j => stacks[i].append(j));
if (stacks[i].children.length > 1) {
stacks[i].addEventListener('click', swap);
stacks[i].style.cursor = 'pointer';
}
}
function swap(e) {
let thisTarget = e.target
if (!thisTarget.classList.contains('screenshot')) return;
thisTarget.style.animation = `fade-out ${timing}ms ease-in forwards`;
setTimeout(() => {
thisTarget.style.animation = `fade-in ${timing}ms ease-out forwards`;
this.prepend(thisTarget);
}, timing);
setTimeout(() => {
// this.prepend(thisTarget);
thisTarget.style = '';
}, 2*timing);
}