Skip to content

Commit

Permalink
resizing support in html-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
ibdafna committed Feb 19, 2021
1 parent 808db46 commit 8a1c4e2
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion packages/html-manager/src/htmlmanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import * as widgets from '@jupyter-widgets/controls';
import * as base from '@jupyter-widgets/base';
import * as outputWidgets from './output';
import { ManagerBase } from '@jupyter-widgets/base-manager';
import { MessageLoop } from '@lumino/messaging';
import { Widget } from '@lumino/widgets';

import * as LuminoWidget from '@lumino/widgets';
import {
Expand Down Expand Up @@ -32,6 +34,16 @@ export class HTMLManager extends ManagerBase {
},
0
);

this._viewList = new Set<DOMWidgetView>();
window.addEventListener('resize', () => {
this._viewList.forEach(view => {
MessageLoop.postMessage(
view.lmWidget,
Widget.ResizeMessage.UnknownSize
);
});
});
}
/**
* Display the specified view. Element where the view is displayed
Expand All @@ -41,7 +53,13 @@ export class HTMLManager extends ManagerBase {
view: Promise<DOMWidgetView> | DOMWidgetView,
el: HTMLElement
): Promise<void> {
LuminoWidget.Widget.attach((await view).lmWidget, el);
const v = await view;
LuminoWidget.Widget.attach(v.lmWidget, el);

this._viewList.add(v);
v.once('remove', () => {
this._viewList.delete(v);
});
}

/**
Expand Down Expand Up @@ -118,4 +136,6 @@ export class HTMLManager extends ManagerBase {
loader:
| ((moduleName: string, moduleVersion: string) => Promise<any>)
| undefined;

private _viewList: Set<DOMWidgetView>;
}

0 comments on commit 8a1c4e2

Please sign in to comment.