execute a function if element in view code example
Example: execute a function if element in view
var counter;
window.onscroll = inView;
counter = document.getElementById('counter');
function inView() {
if (counter.getBoundingClientRect().top <= window.innerHeight) {
console.log('IN VIEW');
}
}