gridviz 2.0.31 → 2.0.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gridviz",
3
- "version": "2.0.31",
3
+ "version": "2.0.32",
4
4
  "description": "Visualization tool for gridded statistics",
5
5
  "keywords": [
6
6
  "statistics",
package/src/App.js CHANGED
@@ -160,6 +160,9 @@ export class App {
160
160
 
161
161
  if (monitor) monitorDuration('End redraw')
162
162
 
163
+ // listen for resize events on the App's container and handle them
164
+ this.defineResizeObserver(container, canvas)
165
+
163
166
  return this
164
167
  }
165
168
 
@@ -651,4 +654,28 @@ export class App {
651
654
  this.cg.setViewFromURL()
652
655
  return this
653
656
  }
657
+
658
+ /**
659
+ * @description Add a resize event observer to the Apps container and update the canvas accordingly
660
+ * @param {HTMLDivElement} container The App's container element
661
+ * @param {HTMLCanvasElement} canvas The App canvas element
662
+ * @memberof App
663
+ */
664
+ defineResizeObserver(container, canvas) {
665
+ // listen to resize events
666
+ const resizeObserver = new ResizeObserver(() => {
667
+ // update the app and canvas size
668
+ if (this.h !== container.clientHeight || this.w !== container.clientWidth) {
669
+ this.h = container.clientHeight
670
+ this.w = container.clientWidth
671
+ this.cg.h = container.clientHeight
672
+ this.cg.w = container.clientWidth
673
+ canvas.setAttribute('width', '' + this.w)
674
+ canvas.setAttribute('height', '' + this.h)
675
+ this.redraw()
676
+ }
677
+ })
678
+
679
+ resizeObserver.observe(container)
680
+ }
654
681
  }