-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add smooth scrolling, back to top button and update copyright and cop…
…yright year in footer
- Loading branch information
1 parent
09cb447
commit 53e6338
Showing
3 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
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
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 @@ | ||
// Select the button: | ||
const backToTopButton = document.getElementById("backToTopBtn"); | ||
|
||
// When the user scrolls down 20px from the top of the document, show the button | ||
window.onscroll = function() {scrollFunction()}; | ||
|
||
function scrollFunction() { | ||
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { | ||
backToTopButton.style.display = "block"; | ||
} else { | ||
backToTopButton.style.display = "none"; | ||
} | ||
} | ||
|
||
// When the user clicks on the button, scroll to the top of the document | ||
function topFunction() { | ||
document.body.scrollTop = 0; // For Safari | ||
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera | ||
} | ||
|
||
// Select the Copyright element: | ||
let currentYearElement = document.getElementById("currentYear"); | ||
|
||
// Get the current year | ||
//let currentDate = new Date(); | ||
let currentYear = (new Date().getFullYear()); | ||
|
||
// Update the date in the Copyright element | ||
currentYearElement.innerText = currentYear; | ||
|