I was following this tutorial here: https://cloudcannon.com/deconstructions/2014/11/15/facebook-content-placeholder-deconstruction.html
to create a dummy loader. unfortunately this tutorial includes fixed pixel-values and I want it to work on screens of all sizes. so I adjusted the animation like this:
@keyframes placeHolderShimmer {
0% {
background-position: -30vw 0
}
100% {
background-position: 30vw 0
}
}
.c-animated-background {
animation-duration: 1.5s;
animation-fill-mode: forwards;
animation-iteration-count: infinite;
animation-name: placeHolderShimmer;
animation-timing-function: linear;
background: fff;
background: linear-gradient(to right, #eeeeee 8%, #dddddd 18%, #eeeeee 33%);
height: 100%;
width: 100%;
position: relative;
padding-top: 50px;
-webkit-backface-visibility: hidden
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body class="c-animated-background">
</body>
</html>
Unfortunately on animation end after 1.5s, the grey area jumps either forward or back, depending on the keyframe-background-position values that I set. How can I prevent that and make the transition smooth? also, the animation seems to be more intense on the performance than I thought - when I want to inspect the background-element in dev mode in chrome with my macbook 2016', it hangs for around 15 seconds. should I perhaps use a transition/transform-animation instead?
Here is a plunker: https://plnkr.co/edit/X8PBIUYmAC11LCUV9uTy?p=preview