提交 f5ebead7 编写于 作者: K Kamran Ahmed

Fix - Memory leak, animation frame never cancelled

上级 d5e94aa9
......@@ -141,10 +141,14 @@ export default class Overlay {
document.body.appendChild(this.overlay);
}
// @todo: do not requestAnimationFrame once final highlight position has been reached
// Stage a new animation frame
this.redrawAnimation = this.window.requestAnimationFrame(this.draw);
// Stage a new animation frame only if the position has not been reached
// of the alpha has not yet fully reached fully required opacity
if (
!this.positionToHighlight.equals(this.highlightedPosition) ||
this.overlayAlpha.toFixed(2) !== this.opacity.toFixed(2)
) {
this.redrawAnimation = this.window.requestAnimationFrame(this.draw);
}
} else {
this.document.body.removeChild(this.overlay);
}
......
......@@ -24,4 +24,11 @@ export default class Position {
canHighlight() {
return this.left < this.right && this.top < this.bottom;
}
equals(position) {
return this.left.toFixed(3) === position.left.toFixed(3) &&
this.right.toFixed(3) === position.right.toFixed(3) &&
this.top.toFixed(3) === position.top.toFixed(3) &&
this.bottom.toFixed(3) === position.bottom.toFixed(3);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册