Skip to content

Instantly share code, notes, and snippets.

@justforuse
Created February 13, 2024 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justforuse/ba6b67f35c62ad6d1f194e38c0df4beb to your computer and use it in GitHub Desktop.
Save justforuse/ba6b67f35c62ad6d1f194e38c0df4beb to your computer and use it in GitHub Desktop.
Animation js
// refer: https://github.com/antfu/plum-demo/blob/main/src/App.vue
function frame() {
const tasks: Function[] = []
pendingTasks = pendingTasks.filter((i) => {
if (Math.random() > 0.4) {
tasks.push(i)
return false
}
return true
})
tasks.forEach(fn => fn())
}
let framesCount = 0
function startFrame() {
requestAnimationFrame(() => {
framesCount += 1
if (framesCount % 3 === 0)
frame()
startFrame()
})
}
startFrame()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment