Fix skills carousel: seamless right-edge coverage

This commit is contained in:
bobbert committed 2026-09-16 19:12:12 +01:00
1 parent 7da63e0741
commit cb15333409
1 file changed
+8 -5
+8 -5
View File
@@ -1,15 +1,18 @@
import { skills } from "../content.js"; import { skills } from "../content.js";
// Even copy count so the -50% translate lands on a copy boundary
// (seamless loop); 12 copies keep half the track (~5000px) far wider
// than any real viewport, so the right edge never gaps.
const COPIES = 12;
function Marquee({ label, items }) { function Marquee({ label, items }) {
// Four copies so the track always covers the viewport on wide screens; const row = Array.from({ length: COPIES }, () => items).flat();
// the -50% translate lands on a copy boundary, keeping the loop seamless.
const row = [...items, ...items, ...items, ...items];
return ( return (
<div className="marquee-block"> <div className="marquee-block">
<h3 className="marquee-label">{label}</h3> <h3 className="marquee-label">{label}</h3>
<div <div
className="marquee" className="marquee"
style={{ "--marquee-duration": `${items.length * 3.4}s` }} style={{ "--marquee-duration": `${items.length * 3.4 * (COPIES / 4)}s` }}
aria-label={`${label}: ${items.join(", ")}`} aria-label={`${label}: ${items.join(", ")}`}
> >
<div className="marquee-track"> <div className="marquee-track">
@@ -17,7 +20,7 @@ function Marquee({ label, items }) {
<span <span
key={`${item}-${i}`} key={`${item}-${i}`}
className="marquee-item" className="marquee-item"
aria-hidden={i >= items.length * 2} aria-hidden={i >= items.length * (COPIES / 2)}
> >
{item} {item}
</span> </span>