Compare commits
2 Commits
97ff22027c
...
v1.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 136571ed53 | |||
| b884884a04 |
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "g1flux",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -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