sidebar floating

This commit is contained in:
Nils Schneider 2015-03-21 19:08:51 +01:00
parent 66d912ee10
commit 2fead2fb54
2 changed files with 19 additions and 13 deletions

View File

@ -100,13 +100,16 @@
z-index: 5; z-index: 5;
width: 50em; width: 50em;
box-sizing: border-box; box-sizing: border-box;
position: relative; position: absolute;
top: 0;
left: 0;
background: white;
box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.19), 0px 3px 6px rgba(0, 0, 0, 0.23); box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.19), 0px 3px 6px rgba(0, 0, 0, 0.23);
transition: left 0.5s;
} }
#sidebar.hidden { #sidebar.hidden {
position: relative; left: -50em;
margin-left: -50em;
} }
#sidebardata { #sidebardata {
@ -164,6 +167,7 @@
} }
#sidebar { #sidebar {
position: static;
margin-left: 0em !important; margin-left: 0em !important;
width: auto; width: auto;
height: auto; height: auto;

View File

@ -44,11 +44,8 @@ function main() {
sb.classList.remove("hidden") sb.classList.remove("hidden")
else else
sb.classList.add("hidden") sb.classList.add("hidden")
map.invalidateSize()
} }
var urls = [ config.dataPath + 'nodes.json', var urls = [ config.dataPath + 'nodes.json',
config.dataPath + 'graph.json' config.dataPath + 'graph.json'
] ]
@ -237,29 +234,34 @@ function mkmap(map, newnodes, lostnodes, onlinenodes, graph, showNodeinfo, showL
var group = L.featureGroup(markers).addTo(map) var group = L.featureGroup(markers).addTo(map)
var group_online = L.featureGroup(onlinemarkers).addTo(map) var group_online = L.featureGroup(onlinemarkers).addTo(map)
map.fitBounds(group.getBounds()) map.fitBounds(group.getBounds(), {paddingTopLeft: [getSidebarWidth(), 0]})
var funcDict = {} var funcDict = {}
Object.keys(markersDict).map( function(k) { Object.keys(markersDict).map( function(k) {
funcDict[k] = function (d) { funcDict[k] = function (d) {
var m = markersDict[k] var m = markersDict[k]
var bounds
if ("getBounds" in m) { if ("getBounds" in m) {
var bounds = m.getBounds() bounds = m.getBounds()
map.fitBounds(bounds)
m.openPopup(bounds.getCenter())
} else { } else {
map.setView(m.getLatLng(), map.getMaxZoom()) bounds = L.latLngBounds([m.getLatLng()])
m.openPopup()
} }
return false map.fitBounds(bounds, {paddingTopLeft: [getSidebarWidth(), 0]})
m.openPopup(bounds.getCenter())
} }
}); });
return funcDict return funcDict
} }
function getSidebarWidth() {
var small = window.matchMedia("(max-width: 60em)");
var sb = document.getElementById("sidebar")
return small.matches ? 0 : sb.offsetWidth
}
function addLinksToMap(map, graph, showLinkinfo) { function addLinksToMap(map, graph, showLinkinfo) {
var markersDict = {} var markersDict = {}