DELAYING JAVASCRIPT EVENT EXECUTION
If you're looking to execute javascript code whenever someone finishes (or stops temporary) scrolling, moving the mouse, or resizing the page, you may find the following code segment useful.
var onFooEndFunc = function() {
var delay = 50; // Vary for effect
var executionTimer;
return function() {
if (!!executionTimer) {
clearTimeout(executionTimer);
}
executionTimer = setTimeout(function() {
// YOUR CODE HERE
}, delay);
};
}();
Simulated onMouseMoveEnd:
onMouseMove onMouseMoveEndExecuted 0 times.
Simulated onResizeEnd:
onResize onResizeEndExecuted 0 times.
Simulated onScrollEnd:
onScroll onScrollEndExecuted 0 times.
Scroll Me