Skip to content

Commit a5e8f9d

Browse files
committed
Prevent invalid overview resizing.
If the overview panel is collapsed and is asked to rerender, the map ended up being 512 pixels wide. There were two separate effects that could result in this behavior. When a new analysis task is loaded, the overview panel has the tile source updated, even though it didn't change. Any such update resulted in recreating the map unnecessarily. When the map was created, if the div for the map was not visible due to being collapsed, it has a zero width. geojs defaults to 512 pixels wide in this case. Further, if the div changed size without the window changing size, that map was not updated appropriately (for instance, when the scroll bar appears or disappears). Use a ResizeObserver, if available, to adjust the map when either condition occurs.
1 parent a0d418f commit a5e8f9d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

histomicsui/web_client/panels/OverviewWidget.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ var OverviewWidget = Panel.extend({
3535
},
3636

3737
setImage(tiles) {
38-
this._tiles = tiles;
39-
this._createOverview();
38+
if (!_.isEqual(tiles, this._tiles)) {
39+
this._tiles = tiles;
40+
this._createOverview();
41+
}
4042
return this;
4143
},
4244

@@ -80,6 +82,15 @@ var OverviewWidget = Panel.extend({
8082
});
8183
this.viewer = geo.map(params.map);
8284

85+
if (window.ResizeObserver) {
86+
this._observer = new window.ResizeObserver(() => {
87+
if (this.viewer.node().width()) {
88+
this.viewer.size({width: this.viewer.node().width(), height: this.viewer.node().height()});
89+
}
90+
});
91+
this._observer.observe(this.viewer.node()[0]);
92+
}
93+
8394
params.layer.autoshareRenderer = false;
8495
this._tileLayer = this.viewer.createLayer('osm', params.layer);
8596
this._featureLayer = this.viewer.createLayer('feature', {features: ['polygon']});

0 commit comments

Comments
 (0)