diff --git a/app/src/app/components/frames/chart/components/timeScale.tsx b/app/src/app/components/frames/chart/components/timeScale.tsx index e89329306..72a116953 100644 --- a/app/src/app/components/frames/chart/components/timeScale.tsx +++ b/app/src/app/components/frames/chart/components/timeScale.tsx @@ -6,8 +6,8 @@ import { GENESIS_DAY } from "../../../../../scripts/lightweightCharts/whitespace import { Box } from "../../box"; import { Scrollable } from "../../scrollable"; -const MULTIPLIER = 0.002; -const DELAY = 10; +const MULTIPLIER = 0.0025; +const DELAY = 25; const LEFT = -1; const RIGHT = 1; @@ -30,28 +30,33 @@ export function TimeScale({ return chart.timeScale(); }); - const interval = setInterval(() => { - const time = timeScale(); - - if (!time) return; + let interval: number | undefined; + function createScrollLoop() { + clearInterval(interval); const direction = scrollDirection(); - if (!direction) return; - const range = time.getVisibleLogicalRange(); - - if (!range) return; - - const speed = (range.to - range.from) * MULTIPLIER * direction; - // @ts-ignore - range.from += speed; - // @ts-ignore - range.to += speed; + interval = setInterval(() => { + const time = timeScale(); - time.setVisibleLogicalRange(range); - }, DELAY); + if (!time) return; + + const range = time.getVisibleLogicalRange(); + + if (!range) return; + + const speed = (range.to - range.from) * MULTIPLIER * direction; + + // @ts-ignore + range.from += speed; + // @ts-ignore + range.to += speed; + + time.setVisibleLogicalRange(range); + }, DELAY); + } onCleanup(() => clearInterval(interval)); @@ -61,7 +66,10 @@ export function TimeScale({