Область видимости для документа
by Alexey Zakharov
JavaScript
//top – координата верхней границы видимой части (относительно документа).
//bottom – координата нижней границы видимой части (относительно документа).
//height – полная высота документа, включая прокрутку.
function getDocumentScroll() {
var scrollHeight = Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.clientHeight, document.documentElement.clientHeight,
document.body.offsetHeight, document.documentElement.offsetHeight
);
return {
top: pageYOffset,
bottom: pageYOffset + document.documentElement.clientHeight,
height: scrollHeight,
}
}
console.log(getDocumentScroll());