Skip to content

Commit 043f83b

Browse files
Merge pull request #387 from SylvainCorlay/after-and-before-attach
Trigger before-attach events and fix popup display
2 parents d82992e + 3f2922c commit 043f83b

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

js/src/controls/WidgetControl.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ var LeafletWidgetControlView = LeafletControlView.extend({
8484
this.widget_view.trigger('displayed', this);
8585
this.widget_view.displayed.then(() => {
8686
this.updateLayout();
87+
PMessaging.MessageLoop.sendMessage(view.pWidget, PWidgets.Widget.Msg.BeforeAttach);
8788
this.obj.setContent(view.el);
8889
PMessaging.MessageLoop.sendMessage(view.pWidget, PWidgets.Widget.Msg.AfterAttach);
8990
});

js/src/layers/Popup.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ var widgets = require('@jupyter-widgets/base');
22
var _ = require('underscore');
33
var L = require('../leaflet.js');
44
var layer = require('./Layer.js');
5+
var PMessaging = require('@phosphor/messaging');
6+
var PWidgets = require('@phosphor/widgets');
57
var LeafletUILayerView = layer.LeafletUILayerView;
68
var LeafletUILayerModel = layer.LeafletUILayerModel;
79
var def_loc = [0.0, 0.0];
@@ -57,14 +59,10 @@ var LeafletPopupView = LeafletUILayerView.extend({
5759
var that = this;
5860
this.child_promise = this.child_promise.then(function() {
5961
return that.create_child_view(value).then(function(view) {
60-
that.obj.setContent(view.el);
62+
PMessaging.MessageLoop.sendMessage(view.pWidget, PWidgets.Widget.Msg.BeforeAttach);
63+
thar.obj.setContent(view.el);
64+
PMessaging.MessageLoop.sendMessage(view.pWidget, PWidgets.Widget.Msg.AfterAttach);
6165
that.force_update();
62-
63-
// Trigger the displayed event of the child view.
64-
that.displayed.then(function() {
65-
view.trigger('displayed', that);
66-
});
67-
6866
that.child = view;
6967
that.trigger('child:created');
7068
});
@@ -99,8 +97,7 @@ var LeafletPopupView = LeafletUILayerView.extend({
9997
if (this.map_view.obj.hasLayer(this.obj)) {
10098
this.map_view.obj.closePopup(this.obj);
10199
this.map_view.obj.openPopup(this.obj);
102-
}
103-
else {
100+
} else {
104101
this.map_view.obj.openPopup(this.obj);
105102
this.map_view.obj.closePopup(this.obj);
106103
}

0 commit comments

Comments
 (0)