window.addEventListener('scroll', function (event) { if (isInViewport(theElementToWatch)) { // update the element display } }, false);