Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Throttle Main component's scroll event (150ms) to reduce freque… #63

Closed

Conversation

ntscshen
Copy link
Contributor

  1. add throttling operation in the scroll event of Main component - set 150ms, compared with the previous trigger frequency reduced by about 8 times (i.e., to ensure that the user experience has been the same as before at the same time, but also to avoid triggering the scroll event too frequently, to improve the performance of scrolling)
  2. add event cleanup operation, in the current scenario (Main component always exists in the page, listening to events wrapped by useCallback) theoretically do not clean up the event listener will not cause memory leaks or performance problems, but based on the maintenance point of view, add on is still a good practice, to ensure that in any scenario the code is robust
  3. Remove duplicate state settings setOffsetTop(false) Every time a scroll event is triggered, if the scroll height does not change, there is no need to duplicate the state settings.

Copy link

vercel bot commented May 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
slash-admin ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2024 2:04am

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.

2 participants