Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Successfully adding the class into the element but not effecting the element

show class adding to the elemet but doesnt work

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

.show {
  opacity: 1;
  filter: blur(0);
  transform: translate(0);
}

.hidden {
  opacity: 0;
  transition: 1s ease all;
  filter: blur(5px);
  transform: translate(-100%);
}

>Solution :

.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);
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading