Skip to content

Commit

Permalink
Update src/scripts/modules/backToTop/backToTop.ts
Browse files Browse the repository at this point in the history
Co-authored-by: Erik Golinelli <erik@codekraft.it>
  • Loading branch information
gardenboi and erikyo authored Nov 8, 2023
1 parent 97e1b47 commit ae974cf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/scripts/modules/backToTop/backToTop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ export function backToTop() {
const button: HTMLDivElement = document.createElement( 'div' );
button.setAttribute( 'id', 'backtotop' );
const scrollToTop = () => {
window.scrollTo( 0, 0 );
window.scrollTo({
top: 0,
behavior: "smooth"
});
};
button.onclick = scrollToTop;
document.body.appendChild( button );
Expand Down

0 comments on commit ae974cf

Please sign in to comment.