Intersection Observer with timer

PHOTO EMBED

Wed May 10 2023 16:23:16 GMT+0000 (Coordinated Universal Time)

Saved by @markporo #intersection #observer

  // let stillIntersecting;

  // const waitForThreeSecondsTimeOut = (observer, targetTestimonialModule) => {
  //   setTimeout(() => {
  //     if (stillIntersecting) {
  //       // log('3 seconds yeah!');
  //       setAttributes({
  //         acrns264_user_sees_testimonials_module: 'true',
  //       });
  //       log('attribute set --- acrns264_user_sees_testimonials_module: true');
  //       observer.unobserve(targetTestimonialModule);
  //     }
  //   }, 3000);
  // };
 

  // utils.waitForElement('.card.marissa-card').then((targetTestimonialModule) => {
  //   const observer = new IntersectionObserver((entries, observer) => {
  //     entries.forEach((entry) => {
  //       if (entry.isIntersecting) {
  //         stillIntersecting = true;
  //         waitForThreeSecondsTimeOut(observer, targetTestimonialModule);
  //       } 

  //       if (!entry.isIntersecting) {
  //         stillIntersecting = false;
  //         clearTimeout(waitForThreeSecondsTimeOut);
  //         // log('user did not view testimonial for 3 seconds');
  //       }
  //     });
  //   }, {
  //     threshold: 1.0,
  //   });

  //   observer.observe(targetTestimonialModule);
  // }).catch(error);
content_copyCOPY