-
Notifications
You must be signed in to change notification settings - Fork 601
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 #1237 from meetarora10/top-branch
feat: Added a scroll to top button on the contributor page .
- Loading branch information
Showing
2 changed files
with
56 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,67 @@ | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Contributors</title> | ||
<link rel="stylesheet" href="contributors.css"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" | ||
integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" | ||
crossorigin="anonymous" referrerpolicy="no-referrer" /> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/fonts/remixicon.css" rel="stylesheet" /> | ||
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet"> | ||
|
||
<style> | ||
html { | ||
scroll-behavior: smooth; | ||
} | ||
.top-btn { | ||
display: none; | ||
width: 50px; | ||
height: 50px; | ||
position: fixed; | ||
bottom: 10px; | ||
right: 0px; | ||
background-color: #ab45e7; | ||
color: #fff; | ||
padding: 2px; | ||
border: none; | ||
margin-right: 36px; | ||
border-radius: 50%; | ||
cursor: pointer; | ||
} | ||
|
||
.top-btn:hover { | ||
background-color: #0056b3; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1 class="title">Contributors</h1> | ||
<div id="contributors" class="contributors-grid"></div> | ||
</div> | ||
<button class="top-btn" id="goToTopBtn" onclick="goToTop()"><i class="fa-solid fa-chevron-up" | ||
style="color: #ffffff;"></i></button> | ||
<script> | ||
// Get the button | ||
var mybutton = document.getElementById("goToTopBtn"); | ||
|
||
// 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) { | ||
mybutton.style.display = "block"; | ||
} else { | ||
mybutton.style.display = "none"; | ||
} | ||
} | ||
|
||
// When the user clicks on the button, scroll to the top of the document | ||
function goToTop() { | ||
document.body.scrollTop = 0; | ||
document.documentElement.scrollTop = 0; | ||
} | ||
</script> | ||
<script src="contributors.js"></script> | ||
</body> | ||
</html> |