Home / Widgets / wwr parallax
Duplicate Snippet

Embed Snippet on Your Site

wwr parallax

hero parallax

Code Preview
php
<?php
<script>
document.addEventListener("DOMContentLoaded", () => {
  // Only run on larger screens (disable on phones for smoother performance)
  if (window.innerWidth < 768) return;
  const hero = document.querySelector('.hero-cover.fullbleed');
  if (!hero) return;
  const speed = 0.25; // Adjust between 0.2–0.35 for strength of movement
  function updateParallax() {
    const rect = hero.getBoundingClientRect();
    const offset = rect.top * speed;
    hero.style.backgroundPosition = `center calc(50% + ${offset}px)`;
  }
  window.addEventListener('scroll', updateParallax, { passive: true });
  window.addEventListener('resize', updateParallax);
  updateParallax();
});
</script>

Comments

Add a Comment