Skip to content

Commit

Permalink
Layer: refactor openPopup/openTooltip: use common function DivOverlay…
Browse files Browse the repository at this point in the history
…._open

more solid devision between functions (_prepareOpen was less clear)
  • Loading branch information
johndoe committed Mar 30, 2021
1 parent c791cf1 commit 3aa318c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
7 changes: 5 additions & 2 deletions src/layer/DivOverlay.js
Expand Up @@ -160,7 +160,9 @@ export var DivOverlay = Layer.extend({
return this;
},

_prepareOpen: function (parent, layer, latlng) {
_open: function (parent, layer, latlng) {
if (!parent._map) { return; }

if (!(layer instanceof Layer)) {
latlng = layer;
layer = parent;
Expand Down Expand Up @@ -191,7 +193,8 @@ export var DivOverlay = Layer.extend({
// update the overlay (content, layout, ect...)
this.update();

return latlng;
// open the overlay on the map
parent._map._openOverlay(this.constructor, this, latlng);
},

_updateContent: function () {
Expand Down
7 changes: 2 additions & 5 deletions src/layer/Popup.js
Expand Up @@ -408,11 +408,8 @@ Layer.include({
// @method openPopup(latlng?: LatLng): this
// Opens the bound popup at the specified `latlng` or at the default popup anchor if no `latlng` is passed.
openPopup: function (layer, latlng) {
if (this._popup && this._map) {
latlng = this._popup._prepareOpen(this, layer, latlng);

// open the popup on the map
this._map.openPopup(this._popup, latlng);
if (this._popup) {
this._popup._open(this, layer, latlng);
}

return this;
Expand Down
6 changes: 1 addition & 5 deletions src/layer/Tooltip.js
Expand Up @@ -313,11 +313,7 @@ Layer.include({
// @method openTooltip(latlng?: LatLng): this
// Opens the bound tooltip at the specified `latlng` or at the default tooltip anchor if no `latlng` is passed.
openTooltip: function (layer, latlng) {
if (this._tooltip && this._map) {
latlng = this._tooltip._prepareOpen(this, layer, latlng);

// open the tooltip on the map
this._map.openTooltip(this._tooltip, latlng);
if (this._tooltip && this._tooltip._open(this, layer, latlng)) {

// Tooltip container may not be defined if not permanent and never
// opened.
Expand Down

0 comments on commit 3aa318c

Please sign in to comment.