onSizeChanged method doesn’t seem to be called when adjusting viewer is closed.

- if I close bottom right viewer, I’d expect top right viewer to be notified so it can take more space.

Thanks for bringing our attention to that. We have decided to change the size notification mechanism in favor of a more flexible Observable, also internally we use ResizeObserver instead of size polling like we did previously. This resulted in one breaking change, the onSizeChanged now being a property that returns Observable. Here is how to use it (Leaflet viewer is already doing that: https://github.com/datagrok-ai/public/blob/master/packages/Leaflet/leaflet/leaflet_viewer.js#L17)

this.onSizeChanged.subscribe((_) => this.map.invalidateSize());

The OnSize event seems to never be broadcasted. Neither when I open, close, or resize the viewer with the mouse.

class SomeViewer extends DG.JsViewer {

constructor() {

   this.onSizeChanged.subscribe((_) =>alert("Resized"));

It works when the subscription is made through the UI class
ui.onSizeChanged(this.root).subscribe((_) => alert(“Resized”));


Indeed, that was a breaking change we have introduced about a month ago, apologies for not announcing it properly - we thought we’ve adjusted all the code but apparently not :slight_smile: We got rid of the ViewerBase’s onSizeChanged in favor of the more universal ui.onSizeChanged(element), as the latter could be used in any context.

1 Like