Commit d677c4ac authored by Piotr Gawron's avatar Piotr Gawron
Browse files

popover position is updated when necessary

parent ac214f5f
......@@ -30,7 +30,7 @@ function OpenLayerInfoWindow(options) {
var popup = new ol.Overlay({
element: element,
positioning: 'bottom-center'
positioning: 'top-center'
});
options.map.getOpenLayersMap().addOverlay(popup);
......@@ -48,11 +48,25 @@ function OpenLayerInfoWindow(options) {
$(element).on('shown.bs.popover', function () {
self._visible = true;
});
options.map.getOpenLayersMap().on('postrender', function () {
if (self.isOpened()) {
var popover = $(element).data('bs.popover');
if (!popover) return;
var popper = popover._popper;
if (!popper) return;
popper.scheduleUpdate();
}
});
}
OpenLayerInfoWindow.prototype = Object.create(InfoWindow.prototype);
OpenLayerInfoWindow.prototype.constructor = OpenLayerInfoWindow;
/**
*
* @return {Promise}
*/
OpenLayerInfoWindow.prototype.updatePosition = function () {
var self = this;
var popup = self.getOpenLayerInfoWindow();
......@@ -66,8 +80,22 @@ OpenLayerInfoWindow.prototype.updatePosition = function () {
popup.setOffset([0, 0]);
}
popup.setPosition(position);
return Promise.delay(100).then(function () {
if (self.isOpened()) {
var popover = $(self._element).data('bs.popover');
if (!popover) return;
var popper = popover._popper;
if (!popper) return;
popper.scheduleUpdate();
}
});
};
/**
*
* @return {Promise}
*/
OpenLayerInfoWindow.prototype.open = function () {
var self = this;
......@@ -86,9 +114,10 @@ OpenLayerInfoWindow.prototype.open = function () {
'html': true
});
self.updatePosition();
var promise = self.updatePosition();
$(self._element).popover('show');
self._visible = true;
return promise;
};
OpenLayerInfoWindow.prototype.hide = function () {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment