Skip to content

fix: engage reveal effect only on scroll deceleration#34

Merged
kadykov merged 2 commits intomainfrom
acceleration-based-actuation
Nov 24, 2025
Merged

fix: engage reveal effect only on scroll deceleration#34
kadykov merged 2 commits intomainfrom
acceleration-based-actuation

Conversation

@kadykov
Copy link
Owner

@kadykov kadykov commented Nov 24, 2025

This change improves the visual stability of the sticky element by engaging the reveal effect only when the scroll speed is decelerating. This prevents visual gaps that occur during rapid acceleration phases where the browser's scroll position prediction is less accurate.

  • Updated src/top.ts and src/bottom.ts to track scroll step changes and only trigger sticky release when decelerating above the threshold
  • Enhanced documentation in README.md and demo pages with detailed explanations of the "Visual Gap" problem and solution
  • Added comprehensive narrative in multi-header-snap.html demo explaining the scrolling phases and prediction logic

This change improves the visual stability of the sticky element by engaging the reveal effect only when the scroll speed is decelerating. This prevents visual gaps that occur during rapid acceleration phases where the browser's scroll position prediction is less accurate.

- Updated src/top.ts and src/bottom.ts to track scroll step changes and only trigger sticky release when decelerating above the threshold
- Enhanced documentation in README.md and demo pages with detailed explanations of the "Visual Gap" problem and solution
- Added comprehensive narrative in multi-header-snap.html demo explaining the scrolling phases and prediction logic
Copilot AI review requested due to automatic review settings November 24, 2025 08:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the visual stability of sticky elements by only engaging the reveal effect during scroll deceleration phases, when browser scroll prediction is more accurate. This prevents visual gaps that occur during rapid acceleration phases. The implementation adds deceleration detection to both top and bottom sticky behaviors by tracking the previous scroll step and comparing it to the current one.

Key changes:

  • Added lastScrollStep tracking to detect scroll deceleration in both src/top.ts and src/bottom.ts
  • Modified reveal effect conditions to only trigger when scrolling is decelerating AND above the speed threshold
  • Enhanced documentation with comprehensive explanations of the "Visual Gap" problem and the deceleration-based solution

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/top.ts Added deceleration detection for upward scroll reveal effect
src/bottom.ts Added deceleration detection for downward scroll reveal effect
demo/multi-header-snap.html Added comprehensive narrative explaining the visual gap problem and deceleration solution
demo/basic-how-it-works.html Updated technical explanation to mention acceleration vs deceleration phases
README.md Updated snapEagerness documentation to reference the detailed gap explanation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@kadykov kadykov merged commit d5caf46 into main Nov 24, 2025
6 checks passed
@kadykov
Copy link
Owner Author

kadykov commented Nov 24, 2025

🎉 This PR is included in version 1.4.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@kadykov kadykov deleted the acceleration-based-actuation branch December 25, 2025 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants