@teachinglab/omd 0.7.22 → 0.7.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/canvas/core/omdCanvas.js +9 -2
- package/package.json +1 -1
package/canvas/core/omdCanvas.js
CHANGED
|
@@ -117,6 +117,8 @@ export class omdCanvas {
|
|
|
117
117
|
this.svg.setAttribute('viewBox', `0 0 ${this.config.width} ${this.config.height}`);
|
|
118
118
|
this.svg.style.cssText = `
|
|
119
119
|
display: block;
|
|
120
|
+
width: 100%;
|
|
121
|
+
height: 100%;
|
|
120
122
|
background: ${this.config.backgroundColor};
|
|
121
123
|
cursor: none;
|
|
122
124
|
touch-action: none;
|
|
@@ -441,11 +443,16 @@ export class omdCanvas {
|
|
|
441
443
|
}
|
|
442
444
|
|
|
443
445
|
/**
|
|
444
|
-
* Handle window resize
|
|
446
|
+
* Handle window resize — resize the canvas to match the container.
|
|
445
447
|
* @private
|
|
446
448
|
*/
|
|
447
449
|
_handleResize() {
|
|
448
|
-
|
|
450
|
+
if (!this.container) return;
|
|
451
|
+
const w = Math.max(400, this.container.clientWidth || this.container.getBoundingClientRect().width || 0);
|
|
452
|
+
const h = Math.max(400, this.container.clientHeight || this.container.getBoundingClientRect().height || 0);
|
|
453
|
+
if (!w || !h) return;
|
|
454
|
+
if (Math.abs(w - this.config.width) < 1 && Math.abs(h - this.config.height) < 1) return;
|
|
455
|
+
this.resize(w, h);
|
|
449
456
|
}
|
|
450
457
|
|
|
451
458
|
/**
|