Skip to content

Commit

Permalink
Revert "feat: async for init anim"
Browse files Browse the repository at this point in the history
This reverts commit cd7fe97.
  • Loading branch information
psemsari committed May 3, 2023
1 parent 7d32ac5 commit 0dee88c
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/Anim.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import { fabric } from 'fabric'

async function Init(obj, canvas) {
// // update position
if (obj.get('top') > window.innerHeight)
{
obj.vy = Math.random() * 10 + 2
obj.set({left: Math.floor(Math.random() * canvas.width) - 50, top: -100})
}
else
obj.set({top: obj.get('top') + obj.vy})
}

function Anim() {

let canvas = new fabric.StaticCanvas('c', {
Expand All @@ -27,8 +16,15 @@ function Anim() {

// update velocity
canvas.getObjects().forEach((obj) => {

// // update position
Init(obj, canvas)
if (obj.get('top') > window.innerHeight)
{
obj.vy = Math.random() * 10 + 2
obj.set({left: Math.floor(Math.random() * canvas.width) - 50, top: -100})
}
else
obj.set({top: obj.get('top') + obj.vy})
})
fabric.util.requestAnimFrame(update)
canvas.renderAll()
Expand Down

0 comments on commit 0dee88c

Please sign in to comment.