I'm trying to create a loading animation, which at first the logo is inside a rectangle in the center of the page, then the rectangle expands to the dimensions of the page, and the logo goes up to the corner (and on mobile: to the center) as the rectangle expands.
The problem is that when animation occurs, unexpectedly the rectangle does not expand evenly in all directions alike. I've created this JSFiddle that shows the problem. Notice how the expansion on the right and bottom sides is slower than the expansion on the left and top sides.
Does anyone know why this is happening and how to correct this?
Also here is my CSS and HTML for reference:
CSS:
:root {
--main: #007;
--bright: #fdc;
}
@media (max-width: 1024px) {
#logo a {
position: fixed;
left: 50%;
transform: translate(-50%);
}
}
body {
margin: 0;
padding: 0;
background-color: var(--main);
}
#logo div {
background-color: var(--bright);
border-color: var(--main);
border-style: solid;
position: fixed;
width: 100vw;
height: 100vh;
top: 0%;
left: 0%;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
border-width: 12px;
transition: all .8s ease;
}
#logo.loading div {
width: 172px;
height: 72px;
top: 50%;
left: 50%;
border-width: 0px;
transform: translate(-50%, -50%);
}
#logo a {
display: inline-grid;
fill: var(--main);
}
#logo svg {
width: 140px;
height: 40px;
margin: 16px;
}
#logo {
position: fixed;
width: 100vw;
height: 100vh;
}
HTML (and JS):
<div id="logo" class="loading">
<div>
<a href="https://example.com">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 140 40" style="enable-background:new 0 0 140 40;" xml:space="preserve">
<!-- THE LOGO SVG -->
</svg>
</a>
</div>
</div>
<script>
window.onload = function() {
var logo = document.getElementById("logo");
setTimeout(function() {
logo.classList.remove("loading");
}, 500);
}
</script>