round tooltip position (#5089)

This commit is contained in:
Aleksey Shmigelski
2016-11-13 20:33:17 +03:00
committed by Vladimir Agafonkin
parent ab31976c75
commit feb716401a

View File

@ -133,17 +133,17 @@ L.Tooltip = L.DivOverlay.extend({
anchor = this._getAnchor();
if (direction === 'top') {
pos = pos.add(L.point(-tooltipWidth / 2 + offset.x, -tooltipHeight + offset.y + anchor.y));
pos = pos.add(L.point(-tooltipWidth / 2 + offset.x, -tooltipHeight + offset.y + anchor.y, true));
} else if (direction === 'bottom') {
pos = pos.subtract(L.point(tooltipWidth / 2 - offset.x, -offset.y));
pos = pos.subtract(L.point(tooltipWidth / 2 - offset.x, -offset.y, true));
} else if (direction === 'center') {
pos = pos.subtract(L.point(tooltipWidth / 2 + offset.x, tooltipHeight / 2 - anchor.y + offset.y));
pos = pos.subtract(L.point(tooltipWidth / 2 + offset.x, tooltipHeight / 2 - anchor.y + offset.y, true));
} else if (direction === 'right' || direction === 'auto' && tooltipPoint.x < centerPoint.x) {
direction = 'right';
pos = pos.add([offset.x + anchor.x, anchor.y - tooltipHeight / 2 + offset.y]);
pos = pos.add(L.point(offset.x + anchor.x, anchor.y - tooltipHeight / 2 + offset.y, true));
} else {
direction = 'left';
pos = pos.subtract(L.point(tooltipWidth + anchor.x - offset.x, tooltipHeight / 2 - anchor.y - offset.y));
pos = pos.subtract(L.point(tooltipWidth + anchor.x - offset.x, tooltipHeight / 2 - anchor.y - offset.y, true));
}
L.DomUtil.removeClass(container, 'leaflet-tooltip-right');