]> git.openstreetmap.org Git - rails.git/commitdiff
Fix layer map bounciness (#361)
authorJohn Firebaugh <john.firebaugh@gmail.com>
Sat, 20 Jul 2013 19:58:43 +0000 (12:58 -0700)
committerTom Hughes <tom@compton.nu>
Sun, 21 Jul 2013 07:43:33 +0000 (08:43 +0100)
app/assets/javascripts/leaflet.layers.js
app/assets/javascripts/leaflet.sidebar.js

index e8014ac4794d2836b1aa30f6135625ce49c545e5..edcbfbd4dd9dd94e73879908644b879f768dc51a 100644 (file)
@@ -64,16 +64,20 @@ L.OSM.layers = function(options) {
 
         function shown() {
           miniMap.invalidateSize();
-          setView();
-          map.on('moveend', setView);
+          setView({animate: false});
+          map.on('moveend', moved);
         }
 
         function hide() {
-          map.off('moveend', setView);
+          map.off('moveend', moved);
+        }
+
+        function moved() {
+          setView();
         }
 
-        function setView() {
-          miniMap.setView(map.getCenter(), Math.max(map.getZoom() - 2, 0));
+        function setView(options) {
+          miniMap.setView(map.getCenter(), Math.max(map.getZoom() - 2, 0), options);
         }
       });
 
index 961842668f25432a3c4905e8df6f8b9a3163fc58..8c4dee308ada2bb36068aaf2f7fe430a9501279c 100644 (file)
@@ -28,11 +28,11 @@ L.OSM.sidebar = function(selector) {
       current = pane;
     }
 
+    map.invalidateSize({pan: false, animate: false});
+
     current
       .show()
       .trigger('show');
-
-    map.invalidateSize({pan: false, animate: false});
   };
 
   return control;