Spaces:
Sleeping
Sleeping
File size: 665 Bytes
036b3a6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
function checkOverflow(codeContainer) {
const fadeOutElement =
codeContainer.parentElement.querySelector(".code-fade-out");
let preElement = codeContainer.querySelector("code");
if (
Math.floor(codeContainer.getBoundingClientRect().bottom) <
Math.floor(preElement.getBoundingClientRect().bottom)
) {
fadeOutElement.style.display = "block";
} else {
fadeOutElement.style.display = "none";
}
}
checkOverflow(document.querySelector(".code-snippet"));
const codeSnippets = document.querySelectorAll(".code-snippet");
codeSnippets.forEach((container) => {
container.addEventListener("scroll", () => checkOverflow(container));
});
|