gridviz 2.0.32 → 2.0.33

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.32",
3
+ "version": "2.0.33",
4
4
  "description": "Visualization tool for gridded statistics",
5
5
  "keywords": [
6
6
  "statistics",
package/src/App.js CHANGED
@@ -663,16 +663,26 @@ export class App {
663
663
  */
664
664
  defineResizeObserver(container, canvas) {
665
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()
666
+ const resizeObserver = new ResizeObserver((entries) => {
667
+ // make sure canvas has been built
668
+ if (container.clientWidth > 0 && container.clientHeight > 0) {
669
+ // make sure we dont exceed loop limit first
670
+ // see: https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded
671
+ window.requestAnimationFrame(() => {
672
+ if (!Array.isArray(entries) || !entries.length) {
673
+ return
674
+ }
675
+ // update the app and canvas size
676
+ if (this.h !== container.clientHeight || this.w !== container.clientWidth) {
677
+ this.h = container.clientHeight
678
+ this.w = container.clientWidth
679
+ this.cg.h = container.clientHeight
680
+ this.cg.w = container.clientWidth
681
+ canvas.setAttribute('width', '' + this.w)
682
+ canvas.setAttribute('height', '' + this.h)
683
+ this.redraw()
684
+ }
685
+ })
676
686
  }
677
687
  })
678
688