mutant
Version:
Create observables and map them to DOM elements. Massively inspired by hyperscript and observ-*. No virtual dom, just direct observable bindings. Unnecessary garbage collection is avoided by using mutable objects instead of blasting immutable junk all ove
17 lines (14 loc) • 380 B
JavaScript
module.exports = function watchAnimationFrame (listener) {
var handle = null
var stopped = false
var renderLoop = function (ev) {
if (stopped) return
listener(ev)
handle = window.requestAnimationFrame(renderLoop)
}
renderLoop()
return function unwatch () {
stopped = true
window.cancelAnimationFrame(handle)
}
}