I am trying to draw a map in a flex child that takes up remaining space.
I have a couple headers on top of the main content, and one of the banners is sometimes hidden/removed, so I am using flexbox so that the header can go away without affecting the other elements position. I.E this does not work well when I use absolute positions.
My problem is that it seems like leaflet is calculating the maps viewport before flexbox has calculated height for the map div.
Example:
Here is a screenshot of leaflet thinking the maps height is smaller than it should be.
If I check the elements height it is correct. And furthermore if I put a timer in and force leaflet to invalidate the map size, the map re-renders at the correct height.
HTML:
<body>
<div class="header">
Header
</div>
<div class="banner">
Banner
</div>
<main class="main">
<div class="nav">
<strong>Navigation</strong>
</div>
<div id="map" class="map-content"></div>
</main>
<script src="script.js"></script>
</body>
CSS:
html, body {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
}
.header {
height: 50px;
background-color: grey;
color: white;
}
.banner {
height: 50px;
background-color: lightgrey;
color: white;
}
.main {
display: flex;
flex: 1 1 auto;
flex-direction: row;
}
.map-content {
flex: 1 1 auto;
}
.nav {
background-color: #2A3D4A;
color: white;
width: 200px;
}
EDIT:
I have reproduced the problem in a plunk, hooray! However I still don't know exactly what is happening. The problem only occurs when I include ngAnimate in my application. Doesn't matter if I use ngAnimate or not.
Here is the plunk that is broken. On initial page load the map is fine. Click the about link, then go back to the map. Notice that when going back, only about half the map loads. I log the height to the console. When you nav away from the map and come back its always about half the size.
What is angular animate doing to cause the element to be half to size for a split second? Is this a bug in angular?