From 80e5aed793adaaa3a37693ed3798610088322a43 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:54:56 +0800 Subject: [PATCH] perf(traffic): shorten sidebar graph animation --- src/components/layout/traffic-graph.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/layout/traffic-graph.tsx b/src/components/layout/traffic-graph.tsx index f6893003b..89b23f2f2 100644 --- a/src/components/layout/traffic-graph.tsx +++ b/src/components/layout/traffic-graph.tsx @@ -13,7 +13,8 @@ const upLineWidth = 4 const downLineAlpha = 1 const downLineWidth = 4 const sampleIntervalMs = 1000 -const animationDurationMs = sampleIntervalMs +const animationDurationMs = 150 +const scrollTransform = `translateX(${-100 / (maxPoint + 1)}%)` const zeroTraffic: Traffic = { up: 0, down: 0, upTotal: 0, downTotal: 0 } const createDefaultList = () => @@ -203,12 +204,8 @@ export function TrafficGraph({ ref }: { ref?: Ref }) { performance.now() - animationStartRef.current, animationDurationMs, ) - const step = canvas.getBoundingClientRect().width / (maxPoint + 1) animation = canvas.animate( - [ - { transform: 'translateX(0)' }, - { transform: `translateX(${-step}px)` }, - ], + [{ transform: 'translateX(0)' }, { transform: scrollTransform }], { duration: animationDurationMs, easing: 'linear', fill: 'forwards' }, ) animation.currentTime = elapsed