From e96ab08210570f6075fc744feb1e9f1ad5c30575 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Wed, 6 Oct 2021 12:23:53 +0700 Subject: [PATCH] added smooth scrolling for comments --- src/components/containers/CommentWrapper/styles.module.scss | 2 +- src/utils/hooks/useScrollToTop.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/containers/CommentWrapper/styles.module.scss b/src/components/containers/CommentWrapper/styles.module.scss index b44c96d0..1e6d7755 100644 --- a/src/components/containers/CommentWrapper/styles.module.scss +++ b/src/components/containers/CommentWrapper/styles.module.scss @@ -34,7 +34,7 @@ left: 0; right: 0; bottom: 0; - animation: highlight 1s 0.25s forwards; + animation: highlight 1s 0.5s forwards; background: transparentize($wisegreen, 0.7); border-radius: $radius; } diff --git a/src/utils/hooks/useScrollToTop.ts b/src/utils/hooks/useScrollToTop.ts index 5a721152..6daee407 100644 --- a/src/utils/hooks/useScrollToTop.ts +++ b/src/utils/hooks/useScrollToTop.ts @@ -11,6 +11,9 @@ export const useScrollToTop = (deps?: any[]) => { } const bounds = targetElement.getBoundingClientRect(); - window.scrollTo(0, bounds.y - 100); + window.scrollTo({ + top: bounds.top - 100, + behavior: 'smooth', + }); }, deps || []); };