Skip to content

Scroll event performance optimization #49

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

Closed
a-kriya opened this issue May 18, 2017 · 2 comments
Closed

Scroll event performance optimization #49

a-kriya opened this issue May 18, 2017 · 2 comments

Comments

@a-kriya
Copy link
Contributor

a-kriya commented May 18, 2017

The scroll event currently triggers a relatively expensive operation: attemptLoad, and thus, getCurrentDistance which uses getBoundingClientRect a couple of times that will require a recalculation of the layout of the DOM.

The number of calls to attemptLoad can be significantly reduced by using a simple debounced scrolling handler.

Without debounce (console.count() in attemptLoad()):
out_1

With debounce (timeout of 50ms):
scroll_2

The scope of change is very minor. Would a PR for this be acceptable?

@PeachScript
Copy link
Owner

Hi @Syn-zeta , v2.2.0 has been released, contains the performance optimization, thank you very much!

@a-kriya
Copy link
Contributor Author

a-kriya commented Sep 16, 2017

Looks great, thanks!

@a-kriya a-kriya closed this as completed Sep 16, 2017
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

2 participants