liriliri / luna

UI library
https://luna.liriliri.io
MIT License
250 stars 22 forks source link

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

Closed leavesster closed 5 months ago

leavesster commented 11 months ago

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;