-
-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added scroll to top feature #1014
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
Toggle Dark Mode | ||
</label> --> | ||
<style> | ||
|
||
/* Features Section */ | ||
.features { | ||
padding: 60px 20px; | ||
|
@@ -182,6 +183,8 @@ | |
</style> | ||
|
||
|
||
|
||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
|
@@ -899,6 +902,36 @@ | |
background-color: #3f10ea; | ||
} | ||
</style> | ||
|
||
<style> | ||
#scroll-to-top { | ||
position: fixed; | ||
bottom: 20px; | ||
right: 80px; | ||
background-color: #007bff; /* Blue button color */ | ||
color: white; | ||
border: none; | ||
border-radius: 50%; | ||
padding: 15px; | ||
font-size: 24px; | ||
display: none; /* Hidden initially */ | ||
cursor: pointer; | ||
transition: opacity 0.3s ease; | ||
z-index: 1000; /* Ensure it stays on top */ | ||
} | ||
|
||
#scroll-to-top:hover { | ||
background-color: #0056b3; /* Darker blue on hover */ | ||
} | ||
|
||
/* Mobile responsiveness */ | ||
@media (max-width: 768px) { | ||
#scroll-to-top { | ||
padding: 12px; | ||
font-size: 20px; | ||
} | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
|
@@ -1041,6 +1074,9 @@ <h3>Emily Johnson</h3> | |
</div> | ||
</section> | ||
|
||
<button id="scroll-to-top" aria-label="Scroll to Top"> | ||
<i class="fas fa-arrow-up"></i> <!-- Font Awesome Arrow Icon --> | ||
</button> | ||
|
||
<!-- Chatbot Button --> | ||
<a href="chatbot.html"> | ||
|
@@ -1124,7 +1160,28 @@ <h3>Connect With Us</h3> | |
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> | ||
<script> | ||
// Get the button | ||
const scrollToTopButton = document.getElementById("scroll-to-top"); | ||
|
||
// Show or hide the button based on scroll position | ||
window.onscroll = function () { | ||
if (document.body.scrollTop > 200 || document.documentElement.scrollTop > 200) { | ||
scrollToTopButton.style.display = "block"; // Show button | ||
} else { | ||
scrollToTopButton.style.display = "none"; // Hide button | ||
} | ||
}; | ||
|
||
// Smooth scroll to the top when button is clicked | ||
scrollToTopButton.onclick = function () { | ||
window.scrollTo({ | ||
top: 0, | ||
behavior: "smooth" | ||
}); | ||
}; | ||
|
||
</script> | ||
Comment on lines
+1782
to
+1803
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consolidate and organize scripts. Current issues with script organization:
+ /* Create a directory structure */
+ scripts/
+ ├── vendors/
+ │ ├── jquery.min.js
+ │ ├── bootstrap.min.js
+ │ └── gsap.min.js
+ ├── components/
+ │ ├── scroll-to-top.js
+ │ └── progress-bar.js
+ └── main.js
<!-- Add to the bottom of body -->
<!-- Vendor scripts -->
<script src="scripts/vendors/jquery.min.js"></script>
<script src="scripts/vendors/bootstrap.min.js"></script>
<script src="scripts/vendors/gsap.min.js"></script>
<!-- Application scripts -->
<script src="scripts/components/scroll-to-top.js"></script>
<script src="scripts/components/progress-bar.js"></script>
<script src="scripts/main.js"></script> |
||
|
||
</body> | ||
|
||
|
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.
Fix duplicate scroll-to-top implementations and improve accessibility.
There are multiple scroll-to-top buttons in the file:
<button id="scroll-to-top">
at line 1072<button class="scroll-to-top" id="scrollToTopBtn">
(duplicate implementation)Additionally, the implementation can be improved for performance and accessibility.
Key improvements:
Also applies to: 905-931, 1783-1801