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

fix: totally scrolled check need consider value is rounded #17

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

leavesster
Copy link
Contributor

according MDN scrollHeight document

scrollTop is a non-rounded number, while scrollHeight and clientHeight are rounded — so the only way to determine if the scroll area is scrolled to the bottom is by seeing if the scroll amount is close enough to some threshold (in this example 1):

to check an element has been totally scrolled should consider: scrollTop is a non-rounded number, while scrollHeight and clientHeight are rounded, so the consider should be like below:

Math.abs(element.scrollHeight - element.clientHeight - element.scrollTop) < 1;

@surunzi surunzi merged commit cc87ff6 into liriliri:master Jul 8, 2024
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