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

Performance issues of scrollBehavior #1145

Closed
fnlctrl opened this issue Feb 8, 2017 · 0 comments
Closed

Performance issues of scrollBehavior #1145

fnlctrl opened this issue Feb 8, 2017 · 0 comments

Comments

@fnlctrl
Copy link
Member

fnlctrl commented Feb 8, 2017

image

Currently, using scrollBehavior adds a scroll listener to record window.pageXOffset and window.pageYOffset, which will force the browser into doing layout+repaint when scrolling, resulting in serious scrolling janks on mobile devices.

Since we cannot avoid accessing pageXOffset and pageYOffset, here are some improvements I can think of:

  1. Implement a simple debounce function for the scroll listener, and add a scrollListenerDebounce option to router configs, which defaults to 1000ms. This should make accessing pageXOffset and pageYOffset only when the user have stopped scrolling for 1000ms.
  2. Add a section in the docs explaining the potential performance issues when using scrollBehavior, and the inaccuracy of the recorded scrolling position, caused by the debounce function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant