Skip to content

Commit

Permalink
refactor: merge nested if conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
donBarbos committed Jul 30, 2023
1 parent 6f1036c commit 7f24212
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/components/ScrollToTop/ScrollToTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7f24212

Please sign in to comment.