Intersection Observer & Efficient Scroll Handling

How should you implement efficient scroll-based parallax effects?
const parallaxObserver = new IntersectionObserver((entries) => {
  entries.forEach(entry => {
    if (entry.isIntersecting) {
      const ratio = Math.min(Math.max(entry.intersectionRatio, 0), 1);
      const yOffset = (1 - ratio) * 100;
      entry.target.style.transform = `translateY(${yOffset}px)`;
    }
  });
}, {
  threshold: Array.from({ length: 50 }, (_, i) => i / 49)
});
Next Question (17/20)