Adjust animation for stacks < 3 images

- Disable eventlistener on 1-image stacks
- Remove cursor on 1-image stacks
This commit is contained in:
Adam Iannazzone 2024-10-17 10:47:58 -04:00
parent b6bc55e543
commit fe73cca82a
3 changed files with 14 additions and 12 deletions

View file

@ -2,7 +2,6 @@
position: relative; position: relative;
display: flex; display: flex;
padding-right: 30px; padding-right: 30px;
cursor: pointer;
} }
#features .row:nth-child(odd) .stack { #features .row:nth-child(odd) .stack {
@ -62,17 +61,20 @@
} }
} }
/*
Commented lines make the animation more flexible
with different numbers of slides
*/
@keyframes fade-out { @keyframes fade-out {
0% { 0% {
/* z-index: 3; */ /* bottom: 0; */
bottom: 0;
opacity: 1; opacity: 1;
} }
100% { 100% {
/* z-index: 0; */
opacity: 0; opacity: 0;
left: calc(-200% - 10px); /* left: calc(-200% - 10px); */
bottom: -30px; /* bottom: -30px; */
scale: 1.05; scale: 1.05;
} }
} }

View file

@ -238,8 +238,6 @@
alt="The RetroDECK and ES-DE logos on a black screen" /> alt="The RetroDECK and ES-DE logos on a black screen" />
<img src="assets/screens/screen02.png" class="img-fluid screenshot" <img src="assets/screens/screen02.png" class="img-fluid screenshot"
alt="The RetroDECK and ES-DE logos on a black screen" /> alt="The RetroDECK and ES-DE logos on a black screen" />
<img src="assets/screens/screen03.png" class="img-fluid screenshot"
alt="The RetroDECK and ES-DE logos on a black screen" />
</div> </div>
<div class="col-12 col-lg-4"> <div class="col-12 col-lg-4">
<div class="feature-card p-2 mt-2 mt-lg-0"> <div class="feature-card p-2 mt-2 mt-lg-0">

View file

@ -1,9 +1,12 @@
let timing = 400; let timing = 250;
let stacks = document.getElementsByClassName('stack'); let stacks = document.getElementsByClassName('stack');
for (let i = 0; i < stacks.length; i++) { for (let i = 0; i < stacks.length; i++) {
[...stacks[i].children].reverse().forEach(j => stacks[i].append(j)); [...stacks[i].children].reverse().forEach(j => stacks[i].append(j));
stacks[i].addEventListener("click", swap); if (stacks[i].children.length > 1) {
stacks[i].addEventListener('click', swap);
stacks[i].style.cursor = 'pointer';
}
} }
function swap(e) { function swap(e) {
@ -14,11 +17,10 @@ function swap(e) {
setTimeout(() => { setTimeout(() => {
thisTarget.style.animation = `fade-in ${timing}ms ease-out forwards`; thisTarget.style.animation = `fade-in ${timing}ms ease-out forwards`;
this.prepend(thisTarget); this.prepend(thisTarget);
// thisTarget.style = '';
}, timing); }, timing);
setTimeout(() => { setTimeout(() => {
// this.prepend(thisTarget);
thisTarget.style = ''; thisTarget.style = '';
}, 2*timing); }, 2*timing);
} }