I want to have a function run a set time after the user scrolls the screen which is easy, but the problem is that when you scroll fast or with the scroll bar, the scroll function is called multiple times. In these cases, I only want to execute the function once, as opposed to multiple times. Here is what I have right now:
$(window).scroll(function() {
scrolled();
});
function RunFunction() {
//Do fancy stuff
};
function scrolled() {
setTimeout(function() {
RunFunction();
}, 1000);
};
If you can tell me how I can day running ‘RunFunction()’ till the user has stopped scrolling, and also only run it once, I’d greatly appreciate it.