@abernier/loop 中文文档教程
INSTALL
import Loop from 'https://unpkg.com/@abernier/loop@1.0.4'
Usage
以最大速度(requestAnimationFrame
):
const myLoop = new Loop((t1, t0) => {
console.log(`dt: ${t1 - t0}`)
})
myLoop.start()
// ...
myLoop.stop()
以给定速度(setTimeout
):
const myLoop = new Loop((t1, t0) => {
console.log(`dt: ${t1 - t0}`)
}, 1000)
myLoop.start()
// ...
myLoop.stop()
INSTALL
import Loop from 'https://unpkg.com/@abernier/loop@1.0.4'
Usage
At max speed (requestAnimationFrame
):
const myLoop = new Loop((t1, t0) => {
console.log(`dt: ${t1 - t0}`)
})
myLoop.start()
// ...
myLoop.stop()
At given speed (setTimeout
):
const myLoop = new Loop((t1, t0) => {
console.log(`dt: ${t1 - t0}`)
}, 1000)
myLoop.start()
// ...
myLoop.stop()