I was working on a landing video section which has a video playing in the background and according to the video there is some text that will change with respect to the video depending on the video timing. The text animation is using keyframes. I've got it working but I am stuck at a point I.e., delay while looping.
On window load(starting of video) everything works fine but when the video comes to an end and starts back to the loop there is like 1 second or fraction of seconds of delay for the video to restart after the loop. "This is my actual problem" when the video restarts the text changes which is in keyframes delays and has its iteration count set to infinite. The text is not matching with the video the second time. when I stay on that section like for a minute video is not matching with the text slides.
Is there any way to delay the animation with CSS or jQuery that the text delays when video starts looping for the second time.
Here is the Codepen link
Below is the code I am working on.
body {
background-color: #02001b;
}
.wrapper {
position: relative;
width: 1455px;
height: 799px;
margin: 0 auto;
}
.header-section section {
width: 45%;
height: 200px;
margin: 0 auto;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
overflow: hidden;
}
.as-main-heading {
color: #fff;
text-transform: uppercase;
font-size: 36px;
font-weight: 300;
}
.as-main-excerpt {
color: #fff;
font-size: 18px;
}
.header-section .first,
.header-section .second,
.header-section .third,
.header-section .fourth {
position: absolute;
left: 0;
right: 0;
animation-duration: 12s;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
}
.header-section .first {
animation-name: anim-1;
}
.header-section .second {
animation-name: anim-2;
}
.header-section .third {
animation-name: anim-3;
}
.header-section .fourth {
animation-name: anim-4;
}
@keyframes anim-1 {
0%,
8% {
opacity: 0;
top: 54%;
}
8%,
16% {
bottom: 25%;
top: 54%;
opacity: 1;
}
25%,
100% {
bottom: 50%;
top: 25%;
opacity: 0;
}
}
@keyframes anim-2 {
0%,
25% {
opacity: 0;
}
32%,
40% {
bottom: 25%;
opacity: 1;
}
50%,
100% {
bottom: 50%;
opacity: 0;
}
}
@keyframes anim-3 {
0%,
50% {
opacity: 0;
}
58%,
66% {
bottom: 25%;
opacity: 1;
}
75%,
100% {
bottom: 50%;
opacity: 0;
}
}
@keyframes anim-4 {
0%,
75% {
opacity: 0;
}
81%,
92% {
bottom: 25%;
opacity: 1;
}
100% {
bottom: 50%;
opacity: 0;
}
}
<div class="wrapper">
<video autoplay muted loop id="myVideo" height="800px;">
<source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
</video>
<div class="landing-header">
<div class="header-section">
<section>
<h2 class="as-main-heading">Story of a bunny</h2>
<div class="as-main-excerpt first">
<p>Here comes a butterfly</p>
</div>
<div class="as-main-excerpt second">
<p>Bunny See's the butterfly</p>
</div>
<div class="as-main-excerpt third">
<p>Butterfly Sitting on the flower</p>
</div>
<div class="as-main-excerpt fourth">
<p>An apple falls on the butterfly</p>
</div>
</section>
</div>
</div>
</div>