RetroDECK-Website/scripts/carousel.js

26 lines
782 B
JavaScript
Raw Normal View History

let timing = 250;
2024-10-16 15:43:00 +00:00
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';
}
2024-10-16 15:43:00 +00:00
}
function swap(e) {
let thisTarget = e.target
if (!thisTarget.classList.contains('screenshot')) return;
2024-10-16 17:18:08 +00:00
thisTarget.style.animation = `fade-out ${timing}ms ease-in forwards`;
2024-10-16 15:43:00 +00:00
setTimeout(() => {
2024-10-16 17:18:08 +00:00
thisTarget.style.animation = `fade-in ${timing}ms ease-out forwards`;
2024-10-16 15:43:00 +00:00
this.prepend(thisTarget);
}, timing);
2024-10-16 17:18:08 +00:00
setTimeout(() => {
// this.prepend(thisTarget);
2024-10-16 17:18:08 +00:00
thisTarget.style = '';
}, 2*timing);
2024-10-16 15:43:00 +00:00
}