From 74e080fd58c681a549a8e369202096bd456b6e6e Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 28 Oct 2020 23:50:03 -0400 Subject: fixed up webBox's to navigate better synchronously when srollTop chagnes. fixed navigation in wikipedia and other pages when hyou dont' click directly on a link. --- src/Utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Utils.ts') diff --git a/src/Utils.ts b/src/Utils.ts index cc7ee9537..daacca51d 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -475,7 +475,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, to: number) { +export function smoothScroll(duration: number, element: HTMLElement, to: number, finish?: () => void) { const start = element.scrollTop; const change = to - start; const startDate = new Date().getTime(); @@ -489,6 +489,7 @@ export function smoothScroll(duration: number, element: HTMLElement, to: number) requestAnimationFrame(animateScroll); } else { element.scrollTop = to; + finish?.(); } }; animateScroll(); -- cgit v1.2.3-70-g09d2