Skip to content

Commit f37a160

Browse files
committed
Fix: Refine realtime map point states
- Extend new event pulse duration to 30 seconds - Add smooth breathing state for idle realtime points - Tune idle point radius and opacity for better visibility
1 parent 1c7c7d1 commit f37a160

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

‎apps/dashboard/src/features/analytics/WebsiteAnalyticsRealtimePage.tsx‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,13 @@ const MAP_WIDTH = 1400;
168168
const MAP_HEIGHT = 620;
169169
const MAX_POINTS = 320;
170170
const FLASH_MS = 900;
171-
const PULSE_MS = 15_000;
171+
const PULSE_MS = 30_000;
172172
const PULSE_CYCLE_MS = 3_600;
173173
const FADE_MS = 10_000;
174174
const POINT_TTL_MS = FLASH_MS + PULSE_MS + FADE_MS;
175+
const LIVE_POINT_RADIUS = 4.7;
176+
const IDLE_POINT_RADIUS = 4.2;
177+
const IDLE_POINT_BREATH_MS = 4_800;
175178
const MAP_PADDING_X = 34;
176179
const MAP_PADDING_Y = 28;
177180
const HOME_ANIMATION_MS = 820;
@@ -245,6 +248,11 @@ function pointOpacity(point: LivePoint, now: number) {
245248
return Math.max(0, 1 - (age - FLASH_MS - PULSE_MS) / FADE_MS);
246249
}
247250

251+
function idlePointBreath(now: number) {
252+
const progress = (now % IDLE_POINT_BREATH_MS) / IDLE_POINT_BREATH_MS;
253+
return 0.5 - Math.cos(progress * Math.PI * 2) / 2;
254+
}
255+
248256
function activityLabel(activity: GeoActivity) {
249257
return ACTIVITY_META[activity]?.label ?? activity;
250258
}
@@ -699,7 +707,10 @@ function drawRealtimePoint(
699707
const pulseActive = !point.persistent && age <= FLASH_MS + PULSE_MS;
700708
const pulseAge = Math.max(0, age - FLASH_MS * 0.35);
701709
const pulseRamp = Math.min(1, Math.max(0, pulseAge / 900));
702-
const coreRadius = 4.7;
710+
const breath = pulseActive ? 0 : idlePointBreath(now);
711+
const coreRadius = pulseActive ? LIVE_POINT_RADIUS : IDLE_POINT_RADIUS + breath * 0.5;
712+
const fillOpacity = (pulseActive ? 0.3 : 0.18 + breath * 0.16) * opacity;
713+
const strokeOpacity = (pulseActive ? 1 : 0.52 + breath * 0.26) * opacity;
703714

704715
context.save();
705716
context.globalCompositeOperation = "lighter";
@@ -719,13 +730,13 @@ function drawRealtimePoint(
719730
}
720731

721732
context.shadowBlur = 0;
722-
context.globalAlpha = 0.3 * opacity;
733+
context.globalAlpha = fillOpacity;
723734
context.fillStyle = meta.color;
724735
context.beginPath();
725736
context.arc(x, y, coreRadius, 0, Math.PI * 2);
726737
context.fill();
727738

728-
context.globalAlpha = opacity;
739+
context.globalAlpha = strokeOpacity;
729740
context.strokeStyle = meta.color;
730741
context.lineWidth = 1;
731742
context.beginPath();

0 commit comments

Comments
 (0)