Skip to content

Commit

Permalink
Disable resizing if there is no comm
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed Oct 18, 2021
1 parent f0dc3de commit 461a7fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/mpl_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,21 @@ export class MPLCanvasModel extends DOMWidgetModel {
view.update_canvas();
});
});
this.on('comm_live_update', this.update_disabled.bind(this));

this.update_disabled();

this.send_initialization_message();
}

get disabled(): boolean {
return !this.comm_live;
}

update_disabled(): void {
this.set('resizable', !this.disabled);
}

sync(method: string, model: WidgetModel, options: any = {}) {
// Make sure we don't sync the data_url, we don't need it to be synced
if (options.attrs) {
Expand Down Expand Up @@ -315,6 +326,7 @@ export class MPLCanvasView extends DOMWidgetView {
private _key: string | null;
private _resize_event: (event: MouseEvent) => void;
private _stop_resize_event: () => void;

render() {
this.resizing = false;
this.resize_handle_size = 20;
Expand Down
2 changes: 1 addition & 1 deletion src/toolbar_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ToolbarView extends DOMWidgetView {
initialize(parameters: any) {
super.initialize(parameters);

this.once('comm_live_update', this.update_disabled.bind(this));
this.on('comm_live_update', this.update_disabled.bind(this));
}

render(): void {
Expand Down

0 comments on commit 461a7fd

Please sign in to comment.