Skip to content

Menambahkan Scroll ke atas atau Scroll to top dan Dark Mode #105

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update base.js
Menambahkan JavaScript untuk Logika Scroll
  • Loading branch information
nadyakhrns authored Jan 14, 2025
commit d76890dc3e7b069f30c005b76b24d1c86d69ffc3
19 changes: 19 additions & 0 deletions belajarpython_theme/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,25 @@ $(document).ready(function() {
});
});

// Scroll to the top
// Get the button
let scrollToTopButton = document.getElementById("scrollToTop");

// Show button when user scrolls down
window.onscroll = function () {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
scrollToTopButton.style.display = "block";
} else {
scrollToTopButton.style.display = "none";
}
};

// Scroll to top when button is clicked
scrollToTopButton.onclick = function () {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE, and Opera
};

$(window).on('resize', applyTopPadding);

$('body').scrollspy({
Expand Down