Add bottomVisible

This commit is contained in:
Farhad
2017-12-13 09:15:41 +03:30
parent d1ee299342
commit 556ef539fd
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,16 @@
### Bottom visible
Returns `true` if bottom of the page is visible. It adds `scrollY` to
the height of the visible portion of the page (`clientHeight`) and
compares it to `pageHeight` to see if bottom of the page is visible.
```js
const bottomVisible = () => {
const scrollY = window.scrollY;
const visibleHeight = document.documentElement.clientHeight;
const pageHeight = document.documentElement.scrollHeight;
const bottomOfPage = visibleHeight + scrollY >= pageHeight;
return bottomOfPage || pageHeight < visibleHeight;
}
```