From 850ba7fe62b99eb7be09d00d0456cebdd0fc561f Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sun, 15 Nov 2015 19:18:29 +0100 Subject: [PATCH] Move _setPosition from L.Popup to L.PopupBase so it can be inherited Idea is to make it easier for plugins to create custom popups or labels or whatever HTML element that would be bound to a map layer. --- src/layer/Popup.js | 20 -------------------- src/layer/PopupBase.js | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/layer/Popup.js b/src/layer/Popup.js index 1050c38c..3abffa43 100644 --- a/src/layer/Popup.js +++ b/src/layer/Popup.js @@ -98,26 +98,6 @@ L.Popup = L.PopupBase.extend({ this._tip = L.DomUtil.create('div', prefix + '-tip', this._tipContainer); }, - _updatePosition: function () { - if (!this._map) { return; } - - var pos = this._map.latLngToLayerPoint(this._latlng), - offset = L.point(this.options.offset); - - if (this._zoomAnimated) { - L.DomUtil.setPosition(this._container, pos); - } else { - offset = offset.add(pos); - } - - var bottom = this._containerBottom = -offset.y, - left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x; - - // bottom position the popup in case the height of the popup changes (images loading etc) - this._container.style.bottom = bottom + 'px'; - this._container.style.left = left + 'px'; - }, - _updateLayout: function () { var container = this._contentNode, style = container.style; diff --git a/src/layer/PopupBase.js b/src/layer/PopupBase.js index b2a8503f..691d1ee2 100644 --- a/src/layer/PopupBase.js +++ b/src/layer/PopupBase.js @@ -151,6 +151,26 @@ L.PopupBase = L.Layer.extend({ node.appendChild(content); } this.fire('contentupdate'); + }, + + _updatePosition: function () { + if (!this._map) { return; } + + var pos = this._map.latLngToLayerPoint(this._latlng), + offset = L.point(this.options.offset); + + if (this._zoomAnimated) { + L.DomUtil.setPosition(this._container, pos); + } else { + offset = offset.add(pos); + } + + var bottom = this._containerBottom = -offset.y, + left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x; + + // bottom position the popup in case the height of the popup changes (images loading etc) + this._container.style.bottom = bottom + 'px'; + this._container.style.left = left + 'px'; } });