From 7f24212fe723970cd06d9905503875ff3031a6c7 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Sun, 30 Jul 2023 18:49:26 +0300 Subject: [PATCH] refactor: merge nested if conditions --- src/components/ScrollToTop/ScrollToTop.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/ScrollToTop/ScrollToTop.tsx b/src/components/ScrollToTop/ScrollToTop.tsx index 6ebb9ae..8044e52 100644 --- a/src/components/ScrollToTop/ScrollToTop.tsx +++ b/src/components/ScrollToTop/ScrollToTop.tsx @@ -11,10 +11,8 @@ export const ScrollToTop = () => { const currentScrollPos = window.pageYOffset if (currentScrollPos > lastScrollPos + 10) { setShowButton(false) - } else if (currentScrollPos < lastScrollPos - 10) { - if (currentScrollPos > 100) { - setShowButton(true) - } + } else if (currentScrollPos < lastScrollPos - 10 && currentScrollPos > 100) { + setShowButton(true) } lastScrollPos = currentScrollPos