I'm not good with JS and struggle with triggering multiple CSS animations when they come into view.
So for I only manage to trigger one animation despite having three intersections that supposedly target the different elements. All I want to fill the bars to different widths which I have specified with keyframes. The section of the code is in the codepen. Could some help me out with it?
https://codepen.io/asmmargod/pen/QWzOeQx
I tried adding new observers to target different elements but they come out with the same width.
I made separate observers for each element but the resulting efect shows the same animations on three elements
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("active");
}
});
});
observer.observe(document.querySelector(".various__item--skills-fill-1"));
const observer1 = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("active-2");
}
});
});
observer.observe(document.querySelector(".various__item--skills-fill-2"));
const observer2 = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("active-3");
}
});
});
observer.observe(document.querySelector(".various__item--skills-fill-3"));`
var()to customize the percentage