The '@darkroom.engineering/tempus' package has been renamed to 'tempus'. Please update your dependencies: npm install tempus and visit the documentation: https://www.npmjs.com/package/tempus
Tempus 允许您合并您的全部 requestAnimationFrame (RAF)循环在一个循环中,以更好的性能,并给予你更好的控制他们的执行优先级.
安装
$ npm i @darkroom.engineering/tempus
使用量
import Tempus from '@darkroom.engineering/tempus'
function onFrame(time, deltaTime) {
// called every frame
}
// subscribe
const unsubscribe = Tempus.add(onFrame, 0)
// unsubscribe
unsubscribe()
// OR
Tempus.remove(onFrame)
方法
add(callback, priority)
remove(callback)
实例
列尼斯语Name
Tempus.add((time) => {
lenis.raf(time)
}, 0);
反应
import { useFrame } from '@darkroom.engineering/hamo'
function Component() {
useFrame((time, deltaTime) => {
// called every frame
})
}
一个RAF来统治他们注意:该包已被作者标记为弃用——The '@darkroom.engineering/tempus' package has been renamed to 'tempus'. Please update your dependencies: npm install tempus and visit the documentation: https://www.npmjs.com/package/tempus