aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts13
1 files changed, 1 insertions, 12 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index f22df0da2..936a459ba 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -482,7 +482,7 @@ const easeInOutQuad = (currentTime: number, start: number, change: number, durat
return (-change / 2) * (newCurrentTime * (newCurrentTime - 2) - 1) + start;
};
-export function smoothScroll(duration: number, element: HTMLElement | HTMLElement[], to: number, finish?: () => void, reset?: { resetGoTo: { to: number, duration: number } | undefined }) {
+export function smoothScroll(duration: number, element: HTMLElement | HTMLElement[], to: number) {
const elements = (element instanceof HTMLElement ? [element] : element);
let starts = elements.map(element => element.scrollTop);
let startDate = new Date().getTime();
@@ -490,23 +490,12 @@ export function smoothScroll(duration: number, element: HTMLElement | HTMLElemen
const animateScroll = () => {
const currentDate = new Date().getTime();
let currentTime = currentDate - startDate;
- const resetParams = reset?.resetGoTo;
- if (resetParams) {
- reset!.resetGoTo = undefined;
- const { to: newTo, duration: newDuration } = resetParams;
- to = newTo;
- starts = starts.map(start => easeInOutQuad(currentTime, start, to - start, duration));
- startDate = currentDate;
- duration = newDuration;
- currentTime = currentDate - startDate;
- }
elements.map((element, i) => element.scrollTop = easeInOutQuad(currentTime, starts[i], to - starts[i], duration));
if (currentTime < duration) {
requestAnimationFrame(animateScroll);
} else {
elements.forEach(element => element.scrollTop = to);
- finish?.();
}
};
animateScroll();