Skip to content

Commit

Permalink
simplify scroll check
Browse files Browse the repository at this point in the history
  • Loading branch information
kea-roy committed Dec 4, 2024
1 parent aca6fcb commit 1a34943
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions frontend/src/utils/saveScrollPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ export const useSaveScrollPosition = (storageKey: string, pathName: string): voi
}
const scrollInterval = setInterval(() => {
const maxScroll = document.documentElement.scrollHeight - window.innerHeight;
if (
Math.abs(window.scrollY - targetPosition) > 50 &&
window.location.pathname === pathName
) {
if (window.scrollY < targetPosition - 50 && window.location.pathname === pathName) {
if (targetPosition <= maxScroll) {
window.scrollTo({
top: targetPosition,
Expand Down

0 comments on commit 1a34943

Please sign in to comment.