From c71209507bbc80c3e90006e67b93388b61fd0336 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Sat, 20 Jul 2013 12:58:43 -0700 Subject: [PATCH] Fix layer map bounciness (#361) --- app/assets/javascripts/leaflet.layers.js | 14 +++++++++----- app/assets/javascripts/leaflet.sidebar.js | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/leaflet.layers.js b/app/assets/javascripts/leaflet.layers.js index e8014ac47..edcbfbd4d 100644 --- a/app/assets/javascripts/leaflet.layers.js +++ b/app/assets/javascripts/leaflet.layers.js @@ -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); } }); diff --git a/app/assets/javascripts/leaflet.sidebar.js b/app/assets/javascripts/leaflet.sidebar.js index 961842668..8c4dee308 100644 --- a/app/assets/javascripts/leaflet.sidebar.js +++ b/app/assets/javascripts/leaflet.sidebar.js @@ -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; -- 2.39.5