Keeps only countries with archived results (Québec, France, US, Spain, Portugal). The landing gets motion and a real structure: staggered fade-in hero with a floating Loki, twinkling stars, a shimmering gold CTA and counters that tick up (draws archived, lotteries, countries); draw cards in place of the table, with lottery balls dropping in and a lift-on-hover; a three-step "Comment ça marche"; and a site-wide footer with links, covered countries, responsible-play note and 18+ notice. All motion is disabled under prefers-reduced-motion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
"use client"
|
|
|
|
import { useEffect, useRef, useState } from "react"
|
|
|
|
/** Counts from 0 to `value` once it scrolls into view. */
|
|
export function CountUp({ value, duration = 1400 }: { value: number; duration?: number }) {
|
|
const [shown, setShown] = useState(0)
|
|
const ref = useRef<HTMLSpanElement>(null)
|
|
|
|
useEffect(() => {
|
|
const el = ref.current
|
|
if (!el) return
|
|
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
setShown(value)
|
|
return
|
|
}
|
|
let frame = 0
|
|
const observer = new IntersectionObserver(([entry]) => {
|
|
if (!entry.isIntersecting) return
|
|
observer.disconnect()
|
|
const start = performance.now()
|
|
const tick = (now: number) => {
|
|
const t = Math.min(1, (now - start) / duration)
|
|
setShown(Math.round(value * (1 - Math.pow(1 - t, 3))))
|
|
if (t < 1) frame = requestAnimationFrame(tick)
|
|
}
|
|
frame = requestAnimationFrame(tick)
|
|
})
|
|
observer.observe(el)
|
|
return () => {
|
|
observer.disconnect()
|
|
cancelAnimationFrame(frame)
|
|
}
|
|
}, [value, duration])
|
|
|
|
return (
|
|
<span ref={ref} className="tabular-nums">
|
|
{shown.toLocaleString("fr-CA")}
|
|
</span>
|
|
)
|
|
}
|