Background Video Play and Pause on Hover Conflicts with Safari

Hi Webflow Team and the Community,

I was trying to achieve background video play and pause on hover effect. It works fine on Chrome, but is not quite compatible with Safari.

Does anyone figure out any solutions?


Thank you all.


Here is my site Read-Only: LINK

The issue seems to be with how Safari handles the pause method on videos. To address this, I added a check to ensure the video element is fully loaded before applying the play and pause functionality.

Here’s the updated code:

document.querySelectorAll(‘.image-stack-video-elem video’).forEach(video => {
// Ensure the video is fully loaded before attaching event listeners
video.addEventListener(‘loadeddata’, () => {
// Play video on hover
video.parentElement.addEventListener(‘mouseenter’, () => {
video.play();
});

// Pause video on mouse leave
video.parentElement.addEventListener('mouseleave', () => {
  video.pause();
});

});
});