consistently round non-integer initial zoom when zooming in/out

…when using the zoom buttons or +/- keyboard shortcuts (i.e. does not affect the mouse-wheel/pinch zooming)

Also: make zoom in/out transition slightly faster.

In sum, this allows to zoom in/out multiple levels in quick succession, and using the zoom buttons should be more intuive: they don't snap to very-close zoom levels anymore (e.g. hitting `+` when the current zoom was 15.97 would previously result in a final zoom of 16.00, which is not really what a user would need. Now the zooming in results in a final zoom level of 17.00, which is "actually properly zoomed in".

initial zoom | operation | final zoom (new) | final zoom (old code)
----- | --- | ----- | -----
16.00 | `+` | 17.00 | 17.00
16.00 | `-` | 15.00 | 15.00
16.10 | `+` | 17.00 | 17.00
16.10 | `-` | 15.00 | 15.00
15.90 | `+` | 17.00 | 16.00
15.90 | `-` | 15.00 | 14.00
This commit is contained in:
Martin Raifer
2025-04-26 20:49:20 +02:00
parent fa91fe7c0d
commit 19adc5cd54
2 changed files with 3 additions and 2 deletions
+1
View File
@@ -39,6 +39,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
#### :sparkles: Usability & Accessibility
* Show full relation label as hover-text in _membership editor_, disambiguate relations with duplicate labels by appending the relation id ([#10492])
* More consistently round non-integer initial zoom when zooming in/out when using the zoom buttons or `+`/`-` keyboard shortcuts
#### :scissors: Operations
* Preserve the sum of certain tags (`step_count`, `parking:*:capacity`) during _join_ operation ([#10492], thanks [@ChaitanyaKadu03])
* Preserve total value of `parking:*:capacity` tags during _split_ operation by distributing it proportionally to the resulting ways ([#10492])
+2 -2
View File
@@ -825,11 +825,11 @@ export function rendererMap(context) {
function zoomIn(delta) {
setCenterZoom(map.center(), ~~map.zoom() + delta, 250, true);
setCenterZoom(map.center(), Math.trunc(map.zoom() + 0.45) + delta, 150, true);
}
function zoomOut(delta) {
setCenterZoom(map.center(), ~~map.zoom() - delta, 250, true);
setCenterZoom(map.center(), Math.ceil(map.zoom() - 0.45) - delta, 150, true);
}
map.zoomIn = function() { zoomIn(1); };