Skip to content

Instantly share code, notes, and snippets.

@bendc
Created August 18, 2016 20:28
Better setInterval
const interval = (callback, delay) => {
const tick = now => {
if (now - start >= delay) {
start = now;
callback();
}
requestAnimationFrame(tick);
};
let start = performance.now();
requestAnimationFrame(tick);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment