You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, attaching a root Lumino widget to the DOM requires some way initiate widget resize messages on the Lumino widget tree. In JupyterLab, IIRC, we add a window resize listener. But on other situations (like ipywidgets), we may attach root Lumino nodes to arbitrary places in the DOM tree. In those cases, we need be able to initiate resize events in the Lumino tree when a DOM element changes size.
In jupyter-widgets/ipywidgets#3124, @ibdafna listened for window resize events as a proxy for if a root widget view needed to have a resize event triggered. This is a coarse proxy, since changing a browsers window size may or may not mean that the root widget size changed, and something else on the page may also change the root widget size and we wouldn't know if the browser window size didn't change.
That means that we can now use a ResizeObserver on each root widget DOM element instead of listening to the window resize event to give more precise triggering of this event. And actually, WICG/resize-observer#59 suggests having a single resize observer observing all root widget DOM elements would be much better.
Proposed Solution
We could at least document how to use ResizeObserver to trigger these resize changes. We could also add a convenience method or function somewhere to help implement this pattern.
Additional context
The text was updated successfully, but these errors were encountered:
Problem
Currently, attaching a root Lumino widget to the DOM requires some way initiate widget resize messages on the Lumino widget tree. In JupyterLab, IIRC, we add a window resize listener. But on other situations (like ipywidgets), we may attach root Lumino nodes to arbitrary places in the DOM tree. In those cases, we need be able to initiate resize events in the Lumino tree when a DOM element changes size.
In jupyter-widgets/ipywidgets#3124, @ibdafna listened for window resize events as a proxy for if a root widget view needed to have a resize event triggered. This is a coarse proxy, since changing a browsers window size may or may not mean that the root widget size changed, and something else on the page may also change the root widget size and we wouldn't know if the browser window size didn't change.
@blois pointed out in jupyter-widgets/ipywidgets#2605 (comment) that the standardized ResizeObserver is now pretty well supported (at least since early 2020).
That means that we can now use a ResizeObserver on each root widget DOM element instead of listening to the window resize event to give more precise triggering of this event. And actually, WICG/resize-observer#59 suggests having a single resize observer observing all root widget DOM elements would be much better.
Proposed Solution
We could at least document how to use ResizeObserver to trigger these resize changes. We could also add a convenience method or function somewhere to help implement this pattern.
Additional context
The text was updated successfully, but these errors were encountered: