X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/b0348093f8877d2f59f153bf35e87ba411f4004b..a5ee93b30110e2c89879e0a67ab2b1c18158faf2:/app/assets/javascripts/index/note.js diff --git a/app/assets/javascripts/index/note.js b/app/assets/javascripts/index/note.js index 6a0487aaa..4fb512bdd 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(); @@ -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 });