Skip to content

Instantly share code, notes, and snippets.

@earthboundkid
Created June 19, 2019 12:34
Show Gist options
  • Save earthboundkid/4a904a1f6cff71f1dd425864b30c784b to your computer and use it in GitHub Desktop.
Save earthboundkid/4a904a1f6cff71f1dd425864b30c784b to your computer and use it in GitHub Desktop.
const onAnimate = (eventType, callback) => {
let timeout;
window.addEventListener(eventType, ev => {
if (timeout) {
window.cancelAnimationFrame(timeout);
}
timeout = window.requestAnimationFrame(callback);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment