window.onscroll = function() {
let doc = document.body,
docOffset = doc.scrollTop + window.innerHeight,
docHeight = doc.offsetHeight;
console.log('offset = ' + docOffset);
// console.log('height = ' + docHeight);
if (docOffset >= docHeight) {
console.log('At the bottom');
}
};