-
-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from dhawal-793/main
Feature: added back To Top button
- Loading branch information
Showing
10 changed files
with
155 additions
and
135 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import { ArrowUp } from "./Icons" | ||
import { Link } from 'react-scroll' | ||
|
||
const BackToTopButton = () => { | ||
const [btnVisiblity, setBtnVisiblity] = useState(false) | ||
const handleScroll = () => { | ||
window.scrollTo({ top: 0, behavior: 'smooth' }) | ||
} | ||
useEffect(() => { | ||
const toggleVisiblity = () => { | ||
window.pageYOffset > 250 ? setBtnVisiblity(true) : setBtnVisiblity(false); | ||
} | ||
window.addEventListener('scroll', toggleVisiblity); | ||
return () => { | ||
window.removeEventListener('scroll', toggleVisiblity); | ||
} | ||
}, []) | ||
|
||
|
||
return ( | ||
<Link onClick={handleScroll} to="Top" smooth duration={500}> | ||
<div className={` ${!btnVisiblity ?"transition-before": "transition-after"} backToTopButton`}> | ||
<ArrowUp /> | ||
</div> | ||
</Link> | ||
) | ||
} | ||
|
||
export default BackToTopButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
a28fa9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
free-hit – ./
free-hit.vercel.app
free-hit-git-main-jasondsouza212.vercel.app
free-hit-jasondsouza212.vercel.app