fix: heatmap overlay — masque les snapshots pendant zoom/pan, resync après
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -63,7 +63,40 @@ export function HeatMap({ transactions }: HeatMapProps) {
|
||||
mapRef.current = map;
|
||||
heatRef.current = heat;
|
||||
|
||||
// Pendant zoom/pan : cache les overlays → le canvas live est visible directement.
|
||||
// Après zoom/pan : resynchronise le snapshot sur le canvas redesssiné.
|
||||
const hideOverlays = () => {
|
||||
const prev = prevRef.current;
|
||||
const next = nextRef.current;
|
||||
if (prev) { prev.style.transition = 'none'; prev.style.opacity = '0'; }
|
||||
if (next) { next.style.transition = 'none'; next.style.opacity = '0'; }
|
||||
currentSrcRef.current = '';
|
||||
};
|
||||
|
||||
const syncAfterMove = () => {
|
||||
const canvas = (heat as unknown as { _canvas?: HTMLCanvasElement })._canvas;
|
||||
const next = nextRef.current;
|
||||
if (!canvas || !next) return;
|
||||
// Double RAF : leaflet.heat redessine en interne après l'événement
|
||||
requestAnimationFrame(() => {
|
||||
requestAnimationFrame(() => {
|
||||
try {
|
||||
const src = canvas.toDataURL();
|
||||
currentSrcRef.current = src;
|
||||
next.src = src;
|
||||
next.style.transition = 'none';
|
||||
next.style.opacity = '1';
|
||||
} catch { /* map torn down */ }
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
map.on('zoomstart movestart', hideOverlays);
|
||||
map.on('zoomend moveend', syncAfterMove);
|
||||
|
||||
return () => {
|
||||
map.off('zoomstart movestart', hideOverlays);
|
||||
map.off('zoomend moveend', syncAfterMove);
|
||||
map.remove();
|
||||
mapRef.current = null;
|
||||
heatRef.current = null;
|
||||
|
||||
Reference in New Issue
Block a user