Fix slideshow transition

This commit is contained in:
2025-09-22 23:06:18 +02:00
parent 95e6fff98b
commit 4701c0804b
3 changed files with 38 additions and 5 deletions

View File

@@ -12,11 +12,13 @@ document.addEventListener("alpine:init", () => {
elapsed: 0, elapsed: 0,
current: 0, current: 0,
previous: 0,
init() { init() {
this.$watch("elapsed", () => { this.$watch("elapsed", () => {
const displayTime = this.posters[this.current].displayTime * 1000; const displayTime = this.posters[this.current].displayTime * 1000;
if (this.elapsed > displayTime) { if (this.elapsed > displayTime) {
this.previous = this.current;
this.current = this.getNext(); this.current = this.getNext();
this.elapsed = 0; this.elapsed = 0;
} }

View File

@@ -76,6 +76,7 @@ body {
justify-content: center; justify-content: center;
top: 0px; top: 0px;
left: 0%;
img { img {
max-width: 100%; max-width: 100%;
@@ -83,12 +84,21 @@ body {
object-fit: contain; object-fit: contain;
} }
&.active { &.current {
animation: scrolling 1s;
display: inline-flex; display: inline-flex;
left: 0%;
animation: scrolling-in 1s linear;
} }
@keyframes scrolling { &.previous {
display: inline-flex;
animation: scrolling-out 1s linear;
opacity: 0;
transition: opacity 0.1s;
transition-delay: 0.9s;
}
@keyframes scrolling-in {
0% { 0% {
transform: translateX(100%); transform: translateX(100%);
} }
@@ -98,6 +108,16 @@ body {
} }
} }
@keyframes scrolling-out {
0% {
transform: translateX(0%);
}
100% {
transform: translateX(-100%);
}
}
} }
} }
@@ -131,14 +151,24 @@ body {
} }
progress { progress {
--color: #304c83;
position: absolute; position: absolute;
bottom: 0px; bottom: 0px;
height: 10px; height: 10px;
// color: #304c83; color: var(--color);
width: 100%; width: 100%;
margin-bottom: 0px; margin-bottom: 0px;
border: none; border: none;
&::-moz-progress-bar {
background: var(--color);
}
&::-webkit-progress-value {
background: var(--color);
}
&[value] { &[value] {
background-color: transparent; background-color: transparent;
} }

View File

@@ -19,7 +19,8 @@
<div id="slides"> <div id="slides">
<template x-for="(poster, index) in posters"> <template x-for="(poster, index) in posters">
<div class="slide" :class="{ <div class="slide" :class="{
active: index === current, current: index === current,
previous: index !== current && index === previous,
}"> }">
<img :src="poster.url"> <img :src="poster.url">
</div> </div>