mirror of
https://github.com/Doodle3D/Doodle3D-Core.git
synced 2024-06-29 07:21:23 +02:00
17 lines
313 B
JavaScript
17 lines
313 B
JavaScript
|
|
// Utility to make it easy for one instance to create only one
|
|
// animation request.
|
|
import raf from 'raf';
|
|
export default function createRAFOnce() {
|
|
let rafID;
|
|
return function rafOnce(notify) {
|
|
if (rafID) {
|
|
return;
|
|
}
|
|
rafID = raf(() => {
|
|
rafID = null;
|
|
notify();
|
|
});
|
|
};
|
|
}
|