Skip to content

Commit

Permalink
DivOverlay: process 'interactive' option
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoe committed Nov 7, 2021
1 parent 4ae51f7 commit df66fe1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 14 additions & 0 deletions src/layer/DivOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export var DivOverlay = Layer.extend({
// @section
// @aka DivOverlay options
options: {
// @option interactive: Boolean = false
// If true, the popup/tooltip will listen to the mouse events.
interactive: false,

// @option offset: Point = Point(0, 7)
// The offset of the popup position. Useful to control the anchor
// of the popup when opening it on some overlays.
Expand Down Expand Up @@ -58,6 +62,11 @@ export var DivOverlay = Layer.extend({
}

this.bringToFront();

if (this.options.interactive) {
DomUtil.addClass(this._container, 'leaflet-interactive');
this.addInteractiveTarget(this._container);
}
},

onRemove: function (map) {
Expand All @@ -67,6 +76,11 @@ export var DivOverlay = Layer.extend({
} else {
DomUtil.remove(this._container);
}

if (this.options.interactive) {
DomUtil.removeClass(this._container, 'leaflet-interactive');
this.removeInteractiveTarget(this._container);
}
},

// @namespace Popup
Expand Down
14 changes: 0 additions & 14 deletions src/layer/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ export var Tooltip = DivOverlay.extend({
// If true, the tooltip will follow the mouse instead of being fixed at the feature center.
sticky: false,

// @option interactive: Boolean = false
// If true, the tooltip will listen to the mouse events.
interactive: false,

// @option opacity: Number = 0.9
// Tooltip container opacity.
opacity: 0.9
Expand All @@ -68,11 +64,6 @@ export var Tooltip = DivOverlay.extend({
DivOverlay.prototype.onAdd.call(this, map);
this.setOpacity(this.options.opacity);

if (this.options.interactive) {
DomUtil.addClass(this._container, 'leaflet-interactive');
this.addInteractiveTarget(this._container);
}

// @namespace Map
// @section Tooltip events
// @event tooltipopen: TooltipEvent
Expand All @@ -93,11 +84,6 @@ export var Tooltip = DivOverlay.extend({
onRemove: function (map) {
DivOverlay.prototype.onRemove.call(this, map);

if (this.options.interactive) {
DomUtil.removeClass(this._container, 'leaflet-interactive');
this.removeInteractiveTarget(this._container);
}

// @namespace Map
// @section Tooltip events
// @event tooltipclose: TooltipEvent
Expand Down

0 comments on commit df66fe1

Please sign in to comment.