I found code which runs a function when I scroll. And it works fine. But the problem is that it runs the function too many times per millisecond; can someone help me to add a function which allows me to choose the number of milliseconds between two function calls? Thanks :)
var runOnScroll = function(evt) {
console.log("hello");
};
var elements = document.querySelectorAll(".div2");
elements = Array.prototype.slice.call(elements);
elements.forEach(function(element) {
window.addEventListener("scroll", runOnScroll, {passive: true});
});