Skip to content

Commit 634324e

Browse files
committed
fix: 延迟支付宝 canvas 首帧渲染
1 parent cd4d12c commit 634324e

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

packages/f-my/src/index.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,20 @@ Component({
115115
height: height * pixelRatio,
116116
},
117117
() => {
118-
const context = canvas.getContext('2d');
119-
const fCanvas = this.createCanvas({
120-
width,
121-
height,
122-
pixelRatio,
123-
context,
124-
createImage: canvas.createImage.bind(canvas),
125-
requestAnimationFrame: canvas.requestAnimationFrame.bind(canvas),
126-
cancelAnimationFrame: canvas.cancelAnimationFrame.bind(canvas),
127-
});
128-
fCanvas.render().catch((error) => {
129-
this.catchError(error);
118+
canvas.requestAnimationFrame(() => {
119+
const context = canvas.getContext('2d');
120+
const fCanvas = this.createCanvas({
121+
width,
122+
height,
123+
pixelRatio,
124+
context,
125+
createImage: canvas.createImage.bind(canvas),
126+
requestAnimationFrame: canvas.requestAnimationFrame.bind(canvas),
127+
cancelAnimationFrame: canvas.cancelAnimationFrame.bind(canvas),
128+
});
129+
fCanvas.render().catch((error) => {
130+
this.catchError(error);
131+
});
130132
});
131133
},
132134
);

0 commit comments

Comments
 (0)