Reputation: 15
i am adding the show class Successfully to the element but somehow the show class is not working.
const obeserver = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("show");
} else {
entry.target.classList.remove("show");
}
});
});
const hiddenElements = document.querySelectorAll(".hidden");
hiddenElements.forEach((el) => obeserver.observe(el));
and css
.show {
opacity: 1;
filter: blur(0);
transform: translate(0);
}
.hidden {
opacity: 0;
transition: 1s ease all;
filter: blur(5px);
transform: translate(-100%);
}
Upvotes: 0
Views: 24
Reputation: 24651
.show
is before .hidden
in the css file
Swap the order:
.hidden {
opacity: 0;
transition: 1s ease all;
filter: blur(5px);
transform: translate(-100%);
}
.show {
opacity: 1;
filter: blur(0);
transform: translate(0);
}
Upvotes: 1