Intersection Observer error

Hi, I'm a UX designer trying to get that hang of coding in Vue JS. I wouldn't say it's going great, so here I am asking for some assistance to solve my current issue!

 Uncaught TypeError: IntersectionObserver.observe: Argument 1 is not an object.


Code in question;
const movingCarSection = document.querySelector(".hidden");

const movingCarsOptions = {
  rootMargin: "5px 0px 0px 0px"
}

const movingCarsObservers = new IntersectionObserver(function(
  entries,
  movingCarsObservers
  ) {
    entries.forEach(entry => {
      if(!entry.isIntersecting){
        movingCarSection.classList.add("show");
      } else {
        movingCarSection.classList.remove("show");
      }
    });
}, movingCarsOptions);

  movingCarsObservers.observe(movingCarSection);


I've tried multiple different videos, there's also been times where it works only one time for some reason and refuses to do anything after each refresh. Now I keep getting the aforementioned error, looking online didnt give me much of an answer that I understood.

Thanks!
Was this page helpful?