From d3e24ad78109a123f7f7edbea8a174129dc3c12e Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Thu, 9 Feb 2023 21:24:38 -0500 Subject: [PATCH] [O] Optimize scrolling --- src/App.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 5787089..00c30d3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -55,14 +55,10 @@ export default function App() { function wheel(e: WheelEvent) { let direction = (e.detail < 0 || e.deltaY > 0) ? 1 : -1 - let dx = direction * 15 + let dx = direction * 20 + const max = Math.round(bcWheel.clientWidth - bcWheel.parentElement.clientWidth) - const rect = bcWheel.getBoundingClientRect() - const prect = bcWheel.parentElement.getBoundingClientRect() - const max = Math.round(rect.width - prect.width) - - setBcLeft(Math.min(Math.max(bcLeft() + dx, 0), max)) - console.log(e) + setBcLeft(Math.max(Math.min(bcLeft() + dx, max), 0)) } return (