mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-08-16 16:45:22 +00:00
round tooltip position (#5089)
This commit is contained in:

committed by
Vladimir Agafonkin

parent
ab31976c75
commit
feb716401a
@ -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');
|
||||
|
Reference in New Issue
Block a user