Skip to content

Conversation

wo-o29
Copy link
Contributor

@wo-o29 wo-o29 commented Sep 21, 2025

This PR enhances the useScrollTrigger hook by introducing requestAnimationFrame throttling to the scroll event listener.

Improvements and Benefits:

  • Introduces a ticking flag combined with requestAnimationFrame to throttle scroll event handling, reducing the number of state updates and re-renders on rapid scroll events.
  • Prevents potential performance bottlenecks caused by frequent and expensive update calls during fast scrolling.
  • Cleans up any scheduled animation frame callbacks on unmount to avoid memory leaks.
  • The initial trigger evaluation remains immediate on mount and dependency changes, maintaining correct state without unnecessary delay.
  • Improves smoothness and responsiveness especially on devices or browsers where scroll events fire frequently.

These changes help optimize performance without changing the hook’s external behavior or API.

@mui-bot
Copy link

mui-bot commented Sep 21, 2025

Netlify deploy preview

https://deploy-preview-46968--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material 🔺+157B(+0.03%) 🔺+43B(+0.03%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 6137860

@wo-o29 wo-o29 changed the title refactor(useScrollTrigger): improve scroll event handling with requestAnimationFrame throttling [useScrollTrigger] refactor: improve scroll event handling with requestAnimationFrame throttling Sep 21, 2025
@wo-o29 wo-o29 reopened this Sep 28, 2025
@wo-o29
Copy link
Contributor Author

wo-o29 commented Sep 28, 2025

I also fixed that part because pnpm-lock.yaml was out of date and the ci test was failing.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Sep 28, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants