提交 98023983 编写于 作者: H hdx

chord(canvas): 避免使用 bind this

上级 28442497
...@@ -61,10 +61,7 @@ ...@@ -61,10 +61,7 @@
constructor(ctx : CanvasRenderingContext2D) { constructor(ctx : CanvasRenderingContext2D) {
this.ctx = ctx this.ctx = ctx
this.initBall() this.initBall()
this.ctx.fillStyle = '#007AFF' this.ctx.fillStyle = '#007AFF'
// #ifdef WEB
this._bindAnimate = this.animate.bind(this)
// #endif
} }
private getDistance(x : number, y : number) : number { private getDistance(x : number, y : number) : number {
...@@ -106,7 +103,9 @@ ...@@ -106,7 +103,9 @@
if (!this.runningFlag) { if (!this.runningFlag) {
return return
} }
this._animateResult = requestAnimationFrame(this.animate.bind(this)) this._animateResult = requestAnimationFrame(() => {
this.animate()
})
// #endif // #endif
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册