提交 97eb6a7d 编写于 作者: K Kamran Ahmed

Fix - Canvas elements keep adding

上级 0b84e47d
......@@ -33,19 +33,26 @@ export default class Overlay {
this.window = window;
this.document = document;
this.prepareContext();
this.resetOverlay();
this.setSize();
}
/**
* Prepares the overlay
*/
prepareContext() {
resetOverlay() {
// Check and remove the canvas if it already exists
const canvasOverlay = this.document.getElementById('sholo-canvas-overlay');
if (canvasOverlay && canvasOverlay.parentNode) {
canvasOverlay.parentNode.removeChild(canvasOverlay);
}
const overlay = this.document.createElement('canvas');
this.overlay = overlay;
this.context = overlay.getContext('2d');
this.overlay.id = 'sholo-canvas-overlay';
this.overlay.style.pointerEvents = 'none';
this.overlay.style.background = 'transparent';
this.overlay.style.position = 'fixed';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册