Skip to content

Commit

Permalink
feat: offscreenCanvas代替setTimeout (#317)
Browse files Browse the repository at this point in the history
* chore(release): release

* chore: 修复build失败

* feat: offscreenCanvas代替setTimeout

---------

Co-authored-by: xuying.xu <[email protected]>
  • Loading branch information
tangying1027 and xuying.xu authored Feb 18, 2025
1 parent b28cb29 commit da93eb3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/f-my/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,13 @@ class CanvasElement {
return new CanvasImageElement(url, this.canvasContext, this._addCallIdAction);
}
requestAnimationFrame(fn: any) {
const frameFn = bindDrawRunnable(fn, this.canvasContext, this._addCallIdAction);
return setTimeout(function () {
const frameFn = bindDrawRunnable(fn, this.canvasContext,this._addCallIdAction);
const offscreenCanvas = (my as any).createOffscreenCanvas
? (my as any).createOffscreenCanvas()
: { requestAnimationFrame: () => {} };
return offscreenCanvas.requestAnimationFrame(() => {
frameFn(Date.now());
}, 16);
});
}
cancelAnimationFrame(tid: any) {
return clearTimeout(tid);
Expand Down

0 comments on commit da93eb3

Please sign in to comment.