feat(andreknie.de): improve accessibility and initial loading

This commit is contained in:
2026-07-28 23:53:18 +02:00
parent cf0fbd077e
commit 88bd952a60
27 changed files with 393 additions and 109 deletions
@@ -15,6 +15,8 @@ export default function BackgroundPattern() {
const canvas = canvasRef.current
if (!canvas) return
const ctx = canvas.getContext('2d')
const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches
const accentColor = getComputedStyle(document.documentElement).getPropertyValue('--accent-color').trim() || '#4a9eff'
function resize() {
const dpr = window.devicePixelRatio || 1
@@ -61,8 +63,6 @@ export default function BackgroundPattern() {
const h = window.innerHeight
ctx.clearRect(0, 0, w, h)
const style = getComputedStyle(document.documentElement)
const accentColor = style.getPropertyValue('--accent-color').trim() || '#4a9eff'
const mouse = mouseRef.current
const repelRadius = 80
@@ -99,14 +99,21 @@ export default function BackgroundPattern() {
ctx.globalAlpha = 1
})
animRef.current = requestAnimationFrame(animate)
if (!reducedMotion && !document.hidden) animRef.current = requestAnimationFrame(animate)
}
function handleVisibilityChange() {
if (document.hidden) cancelAnimationFrame(animRef.current)
else if (!reducedMotion) animate()
}
animate()
document.addEventListener('visibilitychange', handleVisibilityChange)
return () => {
cancelAnimationFrame(animRef.current)
window.removeEventListener('resize', resize)
window.removeEventListener('mousemove', handleMouseMove)
document.removeEventListener('visibilitychange', handleVisibilityChange)
}
}, [])