From 2a2ae99ed3391eb7f339b8684bdb70a580ccf035 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Sat, 25 Dec 2021 12:41:13 +0100 Subject: [PATCH] Profile: Fix redundant scroll top animation --- src/components/right/hooks/useProfileState.ts | 2 +- src/util/fastSmoothScroll.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/right/hooks/useProfileState.ts b/src/components/right/hooks/useProfileState.ts index b03ee0ff6..ab6bfd347 100644 --- a/src/components/right/hooks/useProfileState.ts +++ b/src/components/right/hooks/useProfileState.ts @@ -47,7 +47,7 @@ export default function useProfileState( } const tabListEl = container.querySelector('.TabList'); - if (!tabListEl) { + if (!tabListEl || tabListEl.offsetTop > container.scrollTop) { return; } diff --git a/src/util/fastSmoothScroll.ts b/src/util/fastSmoothScroll.ts index 4106ccab5..f7fc2fe26 100644 --- a/src/util/fastSmoothScroll.ts +++ b/src/util/fastSmoothScroll.ts @@ -7,6 +7,7 @@ import { FAST_SMOOTH_MAX_DISTANCE, FAST_SMOOTH_MAX_DURATION, FAST_SMOOTH_MIN_DURATION, FAST_SMOOTH_SHORT_TRANSITION_MAX_DISTANCE, } from '../config'; +import { IS_ANDROID } from './environment'; import { dispatchHeavyAnimationEvent } from '../hooks/useHeavyAnimationCheck'; import { animateSingle } from './animation'; @@ -89,7 +90,7 @@ function scrollWithJs( switch (position) { case 'start': - path = (elementTop - margin) - scrollFrom; + path = (elementTop - margin) - scrollFrom + (IS_ANDROID ? 1 : 0); break; case 'end': path = (elementTop + elementHeight + margin) - (scrollFrom + targetContainerHeight);