Skip to content

feat(react-utils): add useScrollProgress hook#602

Open
maeertin wants to merge 1 commit intomainfrom
feat/react-utils-useScrollProgress
Open

feat(react-utils): add useScrollProgress hook#602
maeertin wants to merge 1 commit intomainfrom
feat/react-utils-useScrollProgress

Conversation

@maeertin
Copy link
Contributor

@maeertin maeertin commented Oct 7, 2025

Add new hook to spy scroll progress on elements. Useful for creating scroll based animations.

Check out the Codesandbox demo.

@maeertin maeertin self-assigned this Oct 7, 2025
Copilot AI review requested due to automatic review settings October 7, 2025 13:18
@changeset-bot
Copy link

changeset-bot bot commented Oct 7, 2025

🦋 Changeset detected

Latest commit: 1cfa89b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@noaignite/react-utils Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs Ready Ready Preview Comment Oct 9, 2025 0:00am

@maeertin maeertin marked this pull request as draft October 7, 2025 13:18
Copy link

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 introduces a new React hook useScrollProgress that tracks the scroll progress of elements within containers, enabling scroll-based animations and interactions.

  • Adds comprehensive scroll progress tracking with both inner and outer progress calculations
  • Provides TypeScript definitions for entry data, callback functions, and configuration options
  • Implements efficient event handling with IntersectionObserver optimization and requestAnimationFrame smoothing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

❌ Patch coverage is 0% with 78 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/react-utils/src/useScrollProgress.ts 0.00% 78 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

@@            Coverage Diff             @@
##             main     #602      +/-   ##
==========================================
- Coverage   73.80%   71.17%   -2.63%     
==========================================
  Files          62       63       +1     
  Lines        2111     2189      +78     
  Branches      295      295              
==========================================
  Hits         1558     1558              
- Misses        541      619      +78     
  Partials       12       12              
Files with missing lines Coverage Δ
packages/react-utils/src/useScrollProgress.ts 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maeertin maeertin marked this pull request as ready for review October 9, 2025 12:28
Copilot AI review requested due to automatic review settings October 9, 2025 12:28
Copy link

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

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


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


// Attach event listeners to update progress.
scrollContainer.addEventListener('scroll', scheduleUpdate, { passive: true })
window.addEventListener('resize', scheduleUpdate)
Copy link

Choose a reason for hiding this comment

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

Why not use an ResizeObserver on the scrollContainer instead?
So an update is triggered if the container's height changes regardless of the window size.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! I'll look into it, thanks for feedback ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants