Hi Prakash,
Thanks for the reply.
I have found a way to achieve delaying the start of the video of a signature being written until the video is the viewport. I will share the method below, in case it helps anyone. With a bit of tweaking I am sure it could work using the Video Element too, rather than having to use raw html.
I used a Raw Content Element for the video and inserted the html:
<div class="vid">
<video playsinline autoplay muted poster="">
<source src="https://www.mydomain.com/wp-content/uploads/my-video.mp4" type="video/mp4">
</video>
</div>
Then I added the CSS to keep the video to the widths I need for desktop and mobile views:
@media only screen and (min-width: 768px) {
video {
max-width: 40%;
height: auto;
display: block;
margin: 0 auto;
}
}
@media only screen and (max-width: 767px) {
video {
max-width: 80%;
height: auto;
display: block;
margin: 0 auto;
}
}
Finally I added the following Javascript to the Page JS:
gsap.registerPlugin(ScrollTrigger);
let allVideoDivs = gsap.utils.toArray('.vid');
allVideoDivs.forEach((videoDiv, i) => {
let videoElem = videoDiv.querySelector('video')
ScrollTrigger.create({
trigger: videoElem,
start: 'top 80%',
end: 'top 20%',
markers: true,
onEnter: () => videoElem.play(),
onEnterBack: () => videoElem.play(),
onLeave: () => videoElem.pause(),
onLeaveBack: () => videoElem.pause(),
});
});
I hope this helps.
Thanks,
Christopher