From 059139689d05e408772a155f2f0d2390d889b3d0 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Fri, 3 Mar 2023 23:39:01 -0600 Subject: [PATCH] Fix blockchain scrolling on high refresh-rate devices --- frontend/src/app/components/start/start.component.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/components/start/start.component.ts b/frontend/src/app/components/start/start.component.ts index d83ae2dec..77c8fd7f2 100644 --- a/frontend/src/app/components/start/start.component.ts +++ b/frontend/src/app/components/start/start.component.ts @@ -196,11 +196,13 @@ export class StartComponent implements OnInit, OnDestroy { updateVelocity(x: number) { const now = performance.now(); - const dt = now - this.lastUpdate; - this.lastUpdate = now; - const velocity = (x - this.lastMouseX) / dt; - this.velocity = (0.8 * this.velocity) + (0.2 * velocity); - this.lastMouseX = x; + let dt = now - this.lastUpdate; + if (dt > 0) { + this.lastUpdate = now; + const velocity = (x - this.lastMouseX) / dt; + this.velocity = (0.8 * this.velocity) + (0.2 * velocity); + this.lastMouseX = x; + } } animateMomentum() {