From 2f9285e0115e6bc0aebd46664e84c6a7e0e02755 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Fri, 5 Nov 2021 14:41:49 +0100 Subject: [PATCH] improve rendering of turn-restriction boxes in narrow sidebars Previously the applied paddings were too large for narrow sidebars, causing the turn-restriction min-map view to be much more zoomed out than needed. This tweaks the paddings such that even for the slimmest sidebar the rendering is still acceptable (i.e. no turn arrows to be rendered completely outside of the viewport) and at the same time allows generous margins for wider sidebars. This also fixes a minor bug where the mini-map is not properly alligned vertically --- modules/ui/fields/restrictions.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/ui/fields/restrictions.js b/modules/ui/fields/restrictions.js index 3d2c0b7bd7..1b187bb2c6 100644 --- a/modules/ui/fields/restrictions.js +++ b/modules/ui/fields/restrictions.js @@ -223,22 +223,24 @@ export function uiFieldRestrictions(field, context) { extent._extend(_intersection.vertices[i].extent()); } + var padTop = 35; // reserve top space for hint text + // If this is a large intersection, adjust zoom to fit extent if (_intersection.vertices.length > 1) { - var padding = 180; // in z22 pixels + var hPadding = Math.min(160, Math.max(110, d[0] * 0.4)); + var vPadding = 160; var tl = projection([extent[0][0], extent[1][1]]); var br = projection([extent[1][0], extent[0][1]]); - var hFactor = (br[0] - tl[0]) / (d[0] - padding); - var vFactor = (br[1] - tl[1]) / (d[1] - padding); + var hFactor = (br[0] - tl[0]) / (d[0] - hPadding); + var vFactor = (br[1] - tl[1]) / (d[1] - vPadding - padTop); var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2; var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2; z = z - Math.max(hZoomDiff, vZoomDiff); projection.scale(geoZoomToScale(z)); } - var padTop = 35; // reserve top space for hint text var extentCenter = projection(extent.center()); - extentCenter[1] = extentCenter[1] - padTop; + extentCenter[1] = extentCenter[1] - padTop / 2; projection .translate(geoVecSubtract(c, extentCenter))