mirror of
https://github.com/TrezOne/congo-hindi-gujarati.git
synced 2026-07-19 17:13:02 -04:00
🔀 Merge pull request #806 from Jh123x/fix/772/set-to-top-elem-on-scrollable-height
feat: add js to check height and decide if to top is required
This commit is contained in:
@@ -38,7 +38,29 @@ if (document.documentElement.getAttribute("data-auto-appearance") === "true") {
|
||||
});
|
||||
}
|
||||
|
||||
function add_to_top_elem() {
|
||||
var body = document.body;
|
||||
var html = document.documentElement;
|
||||
|
||||
const height =
|
||||
Math.max(
|
||||
body.scrollHeight,
|
||||
body.offsetHeight,
|
||||
html.clientHeight,
|
||||
html.scrollHeight,
|
||||
html.offsetHeight
|
||||
) - 150;
|
||||
|
||||
const elem = document.getElementById("to-top");
|
||||
if (elem === null || elem === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
elem.hidden = height < window.innerHeight;
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", (event) => {
|
||||
add_to_top_elem();
|
||||
setThemeColor();
|
||||
var switchers = document.querySelectorAll("[id^='appearance-switcher']");
|
||||
switchers.forEach((switcher) => {
|
||||
|
||||
Reference in New Issue
Block a user