mirror of
https://github.com/JustAnimeCore/JustAnime.git
synced 2026-04-17 22:01:45 +00:00
Landing page
This commit is contained in:
32
src/helper/toggleScrollbar.js
Normal file
32
src/helper/toggleScrollbar.js
Normal file
@@ -0,0 +1,32 @@
|
||||
export function toggleScrollbar(isOpen) {
|
||||
const getScrollbarWidth = () => {
|
||||
return window.innerWidth - document.documentElement.clientWidth;
|
||||
};
|
||||
const body = document.body;
|
||||
if (isOpen) {
|
||||
const scrollbarWidth = getScrollbarWidth();
|
||||
body.style.paddingRight = `${scrollbarWidth}px`;
|
||||
body.classList.add("overflow-y-hidden");
|
||||
|
||||
const style = document.createElement("style");
|
||||
style.id = "hide-scrollbar";
|
||||
style.innerHTML = `::-webkit-scrollbar { display: none; }`;
|
||||
document.head.appendChild(style);
|
||||
} else {
|
||||
body.style.paddingRight = "0";
|
||||
body.classList.remove("overflow-y-hidden");
|
||||
const styleElement = document.getElementById("hide-scrollbar");
|
||||
if (styleElement) {
|
||||
styleElement.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
export function cleanupScrollbar() {
|
||||
const body = document.body;
|
||||
body.style.paddingRight = "0";
|
||||
body.classList.remove("overflow-y-hidden");
|
||||
const styleElement = document.getElementById("hide-scrollbar");
|
||||
if (styleElement) {
|
||||
styleElement.remove();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user