]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index.js
Make sure the hash updates properly on browse pages
[rails.git] / app / assets / javascripts / index.js
index dc3c932773066ce56a518a9b1c921659cf5ee7e8..96e03539a08a4e245b3dafc51d5f094bc1bb75fb 100644 (file)
@@ -264,10 +264,11 @@ $(document).ready(function () {
 
     function addObject(type, id, center) {
       var bounds = map.addObject({type: type, id: parseInt(id)}, function(bounds) {
-        if (!window.location.hash && bounds.isValid()) {
-          OSM.router.moveListenerOff();
-          map.once('moveend', OSM.router.moveListenerOn);
-          if (center || !map.getBounds().contains(bounds)) map.fitBounds(bounds);
+        if (!window.location.hash && bounds.isValid() &&
+            (center || !map.getBounds().contains(bounds))) {
+          OSM.router.withoutMoveListener(function () {
+            map.fitBounds(bounds);
+          });
         }
       });
     }