-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
scroll to top functionality #5620
base: main
Are you sure you want to change the base?
Changes from 6 commits
92598a3
592568c
ef86638
30fcb29
4721fb3
2a306b2
2d93e09
5e51f8b
fed3dd0
f9efe04
6f0b308
518293f
fa49f48
7ece877
794e07b
40da502
cb6f411
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 |
---|---|---|
|
@@ -2,3 +2,48 @@ | |
{{ partial "script.html" (dict "src" "js/tracing.js") -}} | ||
{{ end -}} | ||
{{ partial "script.html" (dict "src" "js/navScroll.js") -}} | ||
|
||
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. Move all of this extra content into it's own partial, say As for the JS, and I think I mentioned this before, do the following:
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. But @svrnm said i handle this differently already 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. @bintus-ux can you give more details on your concerns on @chalin's requests? To me they sound like a further improvement on what we have so far. 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. Yeah all he just suggested was what i did initially already, i had the scrollToTop.js file in the js folder but you suggested i implement the javascript code on the body-end.html file that way getting rid of the scrollToTop.js file seeing as it was no longer needed, but i am confused now @svrnm 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. 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. @bintus-ux no worries, everyone of us is misreading things from time to time and from own experience I know that beign a non-native english speaker adds an additional source of potential misunderstanding, that's why it is always good to ask more questions! I hope you feel better now! 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. Thank you so much for the words mentor, and yes i'm recuperating fast! |
||
<!-- Scroll-to-Top Button --> | ||
<div class="scroll-container"> | ||
<button id="scrollToTopBtn" class="scroll-btn btn" aria-label="Scroll to top" title="Scroll to top"> | ||
<i class="fas fa-arrow-up"></i> | ||
</button> | ||
</div> | ||
|
||
<script> | ||
// Scroll-to-Top Functionality | ||
document.addEventListener("DOMContentLoaded", function () { | ||
let scrollToTopBtn = document.getElementById("scrollToTopBtn"); | ||
let footer = document.querySelector(".td-footer"); | ||
|
||
if (!scrollToTopBtn || !footer) return; | ||
|
||
function adjustButtonPosition() { | ||
let footerTop = footer.getBoundingClientRect().top; | ||
let windowHeight = window.innerHeight; | ||
|
||
if (footerTop < windowHeight + 40) { | ||
scrollToTopBtn.style.bottom = windowHeight - footerTop + 40 + "px"; | ||
} else { | ||
scrollToTopBtn.style.bottom = "40px"; | ||
} | ||
} | ||
|
||
window.onscroll = function () { | ||
if ( | ||
document.body.scrollTop > 200 || | ||
document.documentElement.scrollTop > 200 | ||
) { | ||
scrollToTopBtn.style.display = "block"; | ||
} else { | ||
scrollToTopBtn.style.display = "none"; | ||
} | ||
|
||
adjustButtonPosition(); | ||
}; | ||
|
||
scrollToTopBtn.onclick = function () { | ||
window.scrollTo({ top: 0, behavior: "smooth" }); | ||
}; | ||
}); | ||
</script> |
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.
Since these styles are no longer confined to the registry, they should be moved. I think that it's fine to move it to the end of
assets/scss/_styles_project.scss
.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.
Done. @chalin