From: Martin Raifer Date: Sun, 16 Feb 2025 09:36:00 +0000 (+0100) Subject: don't re-pan the map when selecting another note that is already on the screen X-Git-Tag: live~151^2~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/a3737b74badf62a50bf354025a3079ed20ffa70b don't re-pan the map when selecting another note that is already on the screen fixes a regression in #5679 --- diff --git a/app/assets/javascripts/index/note.js b/app/assets/javascripts/index/note.js index 6a0487aaa..7d1d77801 100644 --- a/app/assets/javascripts/index/note.js +++ b/app/assets/javascripts/index/note.js @@ -22,16 +22,10 @@ OSM.Note = function (map) { page.pushstate = page.popstate = function (path, id) { OSM.loadSidebarContent(path, function () { - initialize(path, id); - var data = $(".details").data(); if (!data) return; var latLng = L.latLng(data.coordinates.split(",")); - if (!map.getBounds().contains(latLng)) { - OSM.router.withoutMoveListener(function () { - map.setView(latLng, 15, { reset: true }); - }); - } + initialize(path, id, map.getBounds().contains(latLng)); }); }; @@ -39,7 +33,7 @@ OSM.Note = function (map) { initialize(path, id); }; - function initialize(path, id) { + function initialize(path, id, skipMoveToNote) { content.find("button[name]").on("click", function (e) { e.preventDefault(); var data = $(e.target).data(); @@ -86,7 +80,7 @@ OSM.Note = function (map) { latLng: L.latLng(data.coordinates.split(",")), icon: noteIcons[data.status] }, function () { - if (!hashParams.center) { + if (!hashParams.center && !skipMoveToNote) { var latLng = L.latLng(data.coordinates.split(",")); OSM.router.withoutMoveListener(function () { map.setView(latLng, 15, { reset: true });