Purpose
Tempus allows you to merge all your requestAnimationFrame
(rAF) loops in one for better performance and gives you better control over their execution priority.
Installation
$ npm i @studio-freight/tempus
Usage
import Tempus from '@studio-freight/tempus'
function onFrame(time, deltaTime) {
}
const unsubscribe = Tempus.add(onFrame, 0)
unsubscribe()
Tempus.remove(onFrame)
Methods
add(callback, priority)
remove(callback)
Examples
GSAP
gsap.ticker.remove(gsap.updateRoot);
Tempus.add((time) => {
gsap.updateRoot(time / 1000);
}, 0);
Lenis
Tempus.add((time) => {
lenis.raf(time)
}, 0);