diff --git a/src/components/HeatMap.tsx b/src/components/HeatMap.tsx index 64148f7..86831f2 100644 --- a/src/components/HeatMap.tsx +++ b/src/components/HeatMap.tsx @@ -91,12 +91,7 @@ export function HeatMap({ transactions }: HeatMapProps) { return; } - // 1. Cancel any running overlay transition instantly (flush only the overlay) - overlay.style.transition = 'none'; - overlay.style.opacity = '0'; - void overlay.offsetWidth; // flush overlay only — avoids double-paint with canvas - - // 2. Capture current frame (canvas still visible at opacity 1) + // 1. Freeze previous frame in overlay (canvas still at opacity 1) try { overlay.src = canvas.toDataURL(); } catch { @@ -104,22 +99,19 @@ export function HeatMap({ transactions }: HeatMapProps) { return; } - // 3. In one paint batch: hide canvas + show overlay (Frame A moves from canvas to overlay) - canvas.style.transition = 'none'; - canvas.style.opacity = '0'; + // 2. Snap overlay visible — cancel any running transition first + overlay.style.transition = 'none'; + void overlay.offsetWidth; // flush overlay.style.opacity = '1'; - // 4. Update heatmap (invisible: canvas at opacity 0) + // 3. Update canvas underneath (canvas always at opacity 1, covered by overlay) update(); - // 5. Simultaneous crossfade: overlay fades out, canvas fades in + // 4. After Leaflet redraws: dissolve overlay away, revealing new frame const raf = requestAnimationFrame(() => { requestAnimationFrame(() => { - const DURATION = '0.5s ease-in-out'; - overlay.style.transition = `opacity ${DURATION}`; + overlay.style.transition = 'opacity 0.5s ease-in-out'; overlay.style.opacity = '0'; - canvas.style.transition = `opacity ${DURATION}`; - canvas.style.opacity = '1'; }); });