gridviz 2.0.32 → 2.0.34

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.34",
4
4
  "description": "Visualization tool for gridded statistics",
5
5
  "keywords": [
6
6
  "statistics",
@@ -39,7 +39,7 @@
39
39
  "start-dev": "webpack --config webpack.config.dev.cjs",
40
40
  "server": "webpack serve -c webpack.config.dev.js --static ./",
41
41
  "doc": "./node_modules/.bin/jsdoc src/ src/dataset src/legend src/style -d docs/jsdoc",
42
- "build": "webpack --config webpack.config.prod.cjs",
42
+ "build-prod": "webpack --config webpack.config.prod.cjs",
43
43
  "test": "jest"
44
44
  },
45
45
  "files": [
package/src/App.js CHANGED
@@ -283,7 +283,10 @@ export class App {
283
283
  container.addEventListener('mouseout', () => {
284
284
  this.tooltip.hide()
285
285
  })
286
- this.cg.onZoomStartFun = () => {
286
+
287
+ // add extra logic to onZoomStartFun
288
+ this.cg.onZoomStartFun = (e) => {
289
+ if (opts.onZoomStartFun) opts.onZoomStartFun(e)
287
290
  this.tooltip.hide()
288
291
  }
289
292
 
@@ -663,16 +666,26 @@ export class App {
663
666
  */
664
667
  defineResizeObserver(container, canvas) {
665
668
  // 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()
669
+ const resizeObserver = new ResizeObserver((entries) => {
670
+ // make sure canvas has been built
671
+ if (container.clientWidth > 0 && container.clientHeight > 0) {
672
+ // make sure we dont exceed loop limit first
673
+ // see: https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded
674
+ window.requestAnimationFrame(() => {
675
+ if (!Array.isArray(entries) || !entries.length) {
676
+ return
677
+ }
678
+ // update the app and canvas size
679
+ if (this.h !== container.clientHeight || this.w !== container.clientWidth) {
680
+ this.h = container.clientHeight
681
+ this.w = container.clientWidth
682
+ this.cg.h = container.clientHeight
683
+ this.cg.w = container.clientWidth
684
+ canvas.setAttribute('width', '' + this.w)
685
+ canvas.setAttribute('height', '' + this.h)
686
+ this.redraw()
687
+ }
688
+ })
676
689
  }
677
690
  })
678
691