Skip to content

Commit 6ee61a4

Browse files
committed
Process Lumino messages with compatibility with Phosphor
See github.com/jupyter-widgets/ipywidgets/pull/3124 for resize change rationale
1 parent c72eb38 commit 6ee61a4

File tree

1 file changed

+19
-8
lines changed
  • packages/javascript/jupyterlab-plotly/src

1 file changed

+19
-8
lines changed

Diff for: packages/javascript/jupyterlab-plotly/src/Figure.ts

+19-8
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ export class FigureView extends DOMWidgetView {
806806
viewID: string;
807807

808808
/**
809-
* The perform_render method is called by processPhosphorMessage
809+
* The perform_render method is called by processLuminoMessage
810810
* after the widget's DOM element has been attached to the notebook
811811
* output cell. This happens after the initialize of the
812812
* FigureModel, and it won't happen at all if the Python FigureWidget
@@ -900,10 +900,10 @@ export class FigureView extends DOMWidgetView {
900900
}
901901

902902
/**
903-
* Respond to phosphorjs events
903+
* Respond to Lumino events
904904
*/
905-
processPhosphorMessage(msg: any) {
906-
super.processPhosphorMessage.apply(this, arguments);
905+
_processLuminoMessage(msg: any, _super: any) {
906+
_super.apply(this, arguments);
907907
var that = this;
908908
switch (msg.type) {
909909
case "before-attach":
@@ -921,10 +921,6 @@ export class FigureView extends DOMWidgetView {
921921
xaxis: axisHidden,
922922
yaxis: axisHidden,
923923
});
924-
925-
window.addEventListener("resize", function () {
926-
that.autosizeFigure();
927-
});
928924
break;
929925
case "after-attach":
930926
// Rendering actual figure in the after-attach event allows
@@ -938,6 +934,21 @@ export class FigureView extends DOMWidgetView {
938934
}
939935
}
940936

937+
processPhosphorMessage(msg: any) {
938+
this._processLuminoMessage(msg, super["processPhosphorMessage"]);
939+
940+
var that = this;
941+
if (msg.type === "before-attach") {
942+
window.addEventListener("resize", function () {
943+
that.autosizeFigure();
944+
});
945+
}
946+
}
947+
948+
processLuminoMessage(msg: any) {
949+
this._processLuminoMessage(msg, super["processLuminoMessage"]);
950+
}
951+
941952
autosizeFigure() {
942953
var that = this;
943954
var layout = that.model.get("_layout");

0 commit comments

Comments
 (0)