Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Navigation displays block after multiple resizes Reply To: Navigation displays block after multiple resizes

#235287
rocksmethew
Participant

function throttle (callback, limit) {
var wait = false; // Initially, we’re not waiting
return function () { // We return a throttled function
if (!wait) { // If we’re not waiting
callback.call(); // Execute users function
wait = true; // Prevent future invocations
setTimeout(function () { // After a period of time
wait = false; // And allow future invocations
}, limit);
}
}
}

$(window).on(‘resize’, throttle(yourResizeFunction, 200))