Webflow sync, pageviews & more.
NEW

Is there a way to auto-scroll the page in Webflow after a certain amount of time, without the script automatically scrolling back up if the user has already scrolled past the designated point?

TL;DR
  • Choose a target section and delay time, then insert custom JavaScript in the Webflow Page Settings under "Before tag."
  • The script waits for the delay, checks if the user has scrolled past the target, and auto-scrolls only if they haven't.

Yes, you can auto-scroll the page in Webflow after a delay, and prevent it from interrupting users who have scrolled past the target point. This requires a bit of custom JavaScript embedded in your Webflow project.

1. Decide the Scroll Target and Timing

  • Choose the section or element you want to scroll to (e.g., a section with ID #about).
  • Determine the delay time (e.g., 5 seconds = 5000 milliseconds).

2. Add Custom Code in Page Settings

  • Go to Page Settings, then scroll to the Before tag section.
  • Insert a script with the following logic:
  • Wait for the specified delay.
  • Check the user's current scroll position.
  • Only scroll if the user hasn't already passed the destination.

3. Use Script with Scroll Check

  • The script below waits 5 seconds, then scrolls to #about only if the user hasn't already scrolled past that section:
<script>  setTimeout(function () {    var target = document.getElementById("about");    if (!target) return;    var targetTop = target.getBoundingClientRect().top + window.pageYOffset;    if (window.pageYOffset < targetTop - 100) {      window.scrollTo({ top: targetTop, behavior: "smooth" });    }  }, 5000);</script>
  • Replace "about" with the ID of your target section.
  • Adjust the buffer (100) if needed to allow a small threshold past the section before canceling auto-scroll.

4. Publish and Test the Behavior

  • Publish your site and test:
  • Wait for the delay while staying at the top: the page should auto-scroll.
  • Manually scroll past the target section before the delay ends: the page should not scroll automatically.

Summary

To auto-scroll a Webflow page after a delay without interfering with user scroll, add a script that checks your scroll position before triggering smooth scrolling. This ensures a smooth experience and respects user interaction.

Rate this answer

Other Webflow Questions