diff --git a/src/components/LiveLeaderboard.tsx b/src/components/LiveLeaderboard.tsx index 50deb6a..f954d5d 100644 --- a/src/components/LiveLeaderboard.tsx +++ b/src/components/LiveLeaderboard.tsx @@ -55,13 +55,15 @@ export const LiveLeaderboard = ({ roomId }: Props) => { const timerRef = useRef(null) useEffect(() => { + const PIXELS_PER_MILLISECOND = [1, 1000 / 30] // e.g. [1, 10] means 1px every 10ms + if (autoscroll !== false) { timerRef.current = setInterval(() => { console.log('scrolling') window.scrollBy({ - top: autoscroll === 'down' ? 10 : -10, - behavior: 'smooth', + top: autoscroll === 'down' ? PIXELS_PER_MILLISECOND[0] : -PIXELS_PER_MILLISECOND[0], + behavior: 'instant', }) if (window.scrollY + window.innerHeight + 1 > document.body.scrollHeight) { @@ -71,7 +73,7 @@ export const LiveLeaderboard = ({ roomId }: Props) => { if (window.scrollY === 0) { setAutoscroll('down') } - }, 100) + }, PIXELS_PER_MILLISECOND[1]) return () => { if (timerRef.current) {