Hi I'm trying to show content after the page has been scrolled and revealed.
This is the code, should I make a function to check if the page has been loaded already then take off the animation? Thanks.
const allSections = document.querySelectorAll(".section");
const revealSection = function (entries, observer) {
const [entry] = entries;
if (!entry.isIntersecting) return;
entry.target.classList.remove("section--hidden");
observer.unobserve(entry.target);
};
const sectionObserver = new IntersectionObserver(revealSection, {
root: null,
threshold: 0.15,
});
allSections.forEach(function (section) {
sectionObserver.observe(section);
section.classList.add("section--hidden");
});
question from:
https://stackoverflow.com/questions/65545517/how-to-show-content-after-page-has-been-reloaded-when-i-reveal-sections 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…