preserve visual center of map on sidebar transitions
This commit is contained in:
parent
a805e0b545
commit
1082d3a653
4 changed files with 21 additions and 13 deletions
|
@ -158,19 +158,31 @@ $(document).ready(function () {
|
||||||
OSM.Index = function(map) {
|
OSM.Index = function(map) {
|
||||||
var page = {};
|
var page = {};
|
||||||
|
|
||||||
page.pushstate = page.popstate = function(path) {
|
function loadContent(path) {
|
||||||
$("#content").addClass("overlay-sidebar");
|
|
||||||
map.invalidateSize();
|
|
||||||
$('#sidebar_content').load(path + "?xhr=1", function(a, b, xhr) {
|
$('#sidebar_content').load(path + "?xhr=1", function(a, b, xhr) {
|
||||||
if (xhr.getResponseHeader('X-Page-Title')) {
|
if (xhr.getResponseHeader('X-Page-Title')) {
|
||||||
document.title = xhr.getResponseHeader('X-Page-Title');
|
document.title = xhr.getResponseHeader('X-Page-Title');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
page.pushstate = function(path) {
|
||||||
|
$("#content").addClass("overlay-sidebar");
|
||||||
|
map.invalidateSize({pan: false})
|
||||||
|
.panBy([-300, 0], {animate: false});
|
||||||
|
loadContent(path);
|
||||||
|
};
|
||||||
|
|
||||||
|
page.popstate = function(path) {
|
||||||
|
$("#content").addClass("overlay-sidebar");
|
||||||
|
map.invalidateSize({pan: false});
|
||||||
|
loadContent(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
page.unload = function() {
|
page.unload = function() {
|
||||||
|
map.panBy([300, 0], {animate: false});
|
||||||
$("#content").removeClass("overlay-sidebar");
|
$("#content").removeClass("overlay-sidebar");
|
||||||
map.invalidateSize();
|
map.invalidateSize({pan: false});
|
||||||
};
|
};
|
||||||
|
|
||||||
return page;
|
return page;
|
||||||
|
|
|
@ -88,7 +88,7 @@ OSM.Router = function(map, rts) {
|
||||||
currentRoute = routes.recognize(currentPath);
|
currentRoute = routes.recognize(currentPath);
|
||||||
currentRoute.run('popstate', currentPath);
|
currentRoute.run('popstate', currentPath);
|
||||||
var state = e.originalEvent.state;
|
var state = e.originalEvent.state;
|
||||||
map.setView(state.center, state.zoom);
|
map.setView(state.center, state.zoom, {animate: false});
|
||||||
map.updateLayers(state.layers);
|
map.updateLayers(state.layers);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -656,9 +656,9 @@ nav.secondary {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
-webkit-transition: margin 300ms linear;
|
// -webkit-transition: margin 300ms linear;
|
||||||
-moz-transition: margin 300ms linear;
|
// -moz-transition: margin 300ms linear;
|
||||||
transition: margin 300ms linear;
|
// transition: margin 300ms linear;
|
||||||
}
|
}
|
||||||
|
|
||||||
.overlay-sidebar #sidebar {
|
.overlay-sidebar #sidebar {
|
||||||
|
|
6
vendor/assets/leaflet/leaflet.js
vendored
6
vendor/assets/leaflet/leaflet.js
vendored
|
@ -1773,11 +1773,7 @@ L.Map = L.Class.extend({
|
||||||
this._rawPanBy(offset);
|
this._rawPanBy(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fire('move');
|
this.fire('move').fire('moveend');
|
||||||
|
|
||||||
// make sure moveend is not fired too often on resize
|
|
||||||
clearTimeout(this._sizeTimer);
|
|
||||||
this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.fire('resize', {
|
return this.fire('resize', {
|
||||||
|
|
Loading…
Add table
Reference in a new issue