JSFiddle - React, Tailwind, and code Playground
by John Schulz
HTML
<div>Scroll me</div>
CSS
div {
height: 20000px;
}
JavaScript
jQuery(function(e) {
jQuery(window).bind('scroll', function(e) {
var now = +(new Date);
var threshold = 100; // minimum ms since last call
var delta = now - this.lastCall;
if (!this.lastCall || (delta > threshold)) {
this.lastCall = now;
// do work here
console.log('scroll');
}
else {
console.log('throttled');
}
});
});