From bf035a4ec454a2419cbb3a2e8a5636ae067092ab Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Wed, 9 Mar 2022 09:48:30 -0800 Subject: [PATCH] use window to track scrolling for /app web routes --- packages/web/components/templates/article/Article.tsx | 6 ++++++ packages/web/pages/app/[username]/[slug]/index.tsx | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/web/components/templates/article/Article.tsx b/packages/web/components/templates/article/Article.tsx index eb88f59fc..2f729a42b 100644 --- a/packages/web/components/templates/article/Article.tsx +++ b/packages/web/components/templates/article/Article.tsx @@ -79,6 +79,12 @@ export function Article(props: ArticleProps): JSX.Element { scrollContainer.scrollHeight setReadingProgress(newReadingProgress * 100) + } else if (window && window.document.scrollingElement) { + const newReadingProgress = + window.scrollY / window.document.scrollingElement.scrollHeight + const adjustedReadingProgress = + newReadingProgress > 0.92 ? 1 : newReadingProgress + setReadingProgress(adjustedReadingProgress * 100) } }, 1000 diff --git a/packages/web/pages/app/[username]/[slug]/index.tsx b/packages/web/pages/app/[username]/[slug]/index.tsx index 9d1693beb..7f871ab5f 100644 --- a/packages/web/pages/app/[username]/[slug]/index.tsx +++ b/packages/web/pages/app/[username]/[slug]/index.tsx @@ -67,9 +67,7 @@ function AppArticleEmbedContent( if (articleData) { return (