0.0.1 • Published 7 years ago
@readable/lock v0.0.1
Lock
Tool to create a trailing edge throttle out of any deferring function.
Places a lock on a function preventing its simultaneous execution. While another execution is due, all other requests to run will be ignored.
var throttle = Rd.lock(function (callback) {
setTimeout(callback, 16)
})
window.addEventListener('resize', function () {
throttle(function () {
// Update DOM no more than every 16ms (~ 60fps)
})
})
var throttledRAF = Rd.lock(requestAnimationFrame)
window.addEventListener('resize', function () {
throttledRAF(function () {
// Update DOM before repaint
})
})
0.0.1
7 years ago