diff --git a/src/components/HeatMap.tsx b/src/components/HeatMap.tsx index 98db3e7..9c67cd7 100644 --- a/src/components/HeatMap.tsx +++ b/src/components/HeatMap.tsx @@ -91,25 +91,33 @@ export function HeatMap({ transactions }: HeatMapProps) { return; } - // Freeze current frame in the overlay + // 1. Hide canvas instantly (no transition) + canvas.style.transition = 'none'; + canvas.style.opacity = '0'; + + // 2. Freeze current frame in the overlay try { overlay.src = canvas.toDataURL(); } catch { // canvas tainted (shouldn't happen with heatmap-only canvas) + canvas.style.opacity = '1'; update(); return; } overlay.style.transition = 'none'; overlay.style.opacity = '1'; - // Update heatmap underneath immediately + // 3. Update heatmap (invisible: canvas still at opacity 0) update(); - // Then dissolve the overlay away + // 4. Simultaneous crossfade: overlay fades out, canvas fades in const raf = requestAnimationFrame(() => { requestAnimationFrame(() => { - overlay.style.transition = 'opacity 0.5s ease-in-out'; + const DURATION = '0.5s ease-in-out'; + overlay.style.transition = `opacity ${DURATION}`; overlay.style.opacity = '0'; + canvas.style.transition = `opacity ${DURATION}`; + canvas.style.opacity = '1'; }); });