Skip to content

Commit

Permalink
Fix the issue that element sometimes get placed incorrectly
Browse files Browse the repository at this point in the history
Fixes: #14
  • Loading branch information
huww98 committed Dec 7, 2020
1 parent 1f3c514 commit 45b5bc1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/canvasLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ export class CanvasLayer {

constructor(el: HTMLElement, private options: ResolvedRenderOptions, model: RenderModel) {
const canvas = document.createElement('canvas');
canvas.style.width = '100%';
canvas.style.height = '100%';
canvas.style.position = 'absolute';
const style = canvas.style;
style.position = 'absolute';
style.width = style.height = '100%';
style.left = style.right = style.top = style.bottom = '0';
el.shadowRoot!.appendChild(canvas);

this.gl = getContext(canvas, options.forceWebGL1);
Expand Down
7 changes: 4 additions & 3 deletions src/svgLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ export class SVGLayer {

constructor(el: HTMLElement, model: RenderModel) {
this.svgNode = document.createElementNS("http://www.w3.org/2000/svg", "svg");
this.svgNode.style.position = 'absolute';
this.svgNode.style.width = '100%';
this.svgNode.style.height = '100%';
const style = this.svgNode.style;
style.position = 'absolute';
style.width = style.height = '100%';
style.left = style.right = style.top = style.bottom = '0';
el.shadowRoot!.appendChild(this.svgNode);

model.disposing.on(() => {
Expand Down

0 comments on commit 45b5bc1

Please sign in to comment.