From 0f61ac8d5c7ba5694f19d8d3a40e4ab4be7de410 Mon Sep 17 00:00:00 2001 From: Emma Cunningham Date: Fri, 8 Feb 2019 08:06:27 -0800 Subject: [PATCH] fix(offscreen canvas): set negative position to move offscreen (#50) re: #43 --- src/lib/axes/canvas_text_bbox_calculator.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/axes/canvas_text_bbox_calculator.ts b/src/lib/axes/canvas_text_bbox_calculator.ts index ba1f0ee289..92798010ca 100644 --- a/src/lib/axes/canvas_text_bbox_calculator.ts +++ b/src/lib/axes/canvas_text_bbox_calculator.ts @@ -9,6 +9,9 @@ export class CanvasTextBBoxCalculator implements BBoxCalculator { constructor(rootElement?: HTMLElement) { this.offscreenCanvas = document.createElement('canvas'); + this.offscreenCanvas.style.position = 'absolute'; + this.offscreenCanvas.style.top = '-9999px'; + this.context = this.offscreenCanvas.getContext('2d'); this.attachedRoot = rootElement || document.documentElement; this.attachedRoot.appendChild(this.offscreenCanvas);