]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5686'
authorTom Hughes <tom@compton.nu>
Sun, 16 Feb 2025 11:12:47 +0000 (11:12 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 16 Feb 2025 11:12:47 +0000 (11:12 +0000)
app/assets/javascripts/index/note.js

index 6a0487aaac21a2622386f66257860975357b833d..4fb512bdd81028eeaf6de4c6920a52e48856ab14 100644 (file)
@@ -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();
@@ -50,7 +44,7 @@ OSM.Note = function (map) {
         oauth: true,
         success: () => {
           OSM.loadSidebarContent(path, () => {
-            initialize(path, id);
+            initialize(path, id, false);
           });
         },
         error: (xhr) => {
@@ -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 });