From 64b3bbf1a6f66eaa019ecd97017209ee71fab68b Mon Sep 17 00:00:00 2001 From: Rishabh Date: Tue, 14 Dec 2021 21:01:12 +0530 Subject: [PATCH] Refined video controls behavior refs https://github.com/TryGhost/Team/issues/1229 --- core/frontend/src/cards/js/video.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/frontend/src/cards/js/video.js b/core/frontend/src/cards/js/video.js index 6e763713a8..3336f7e6af 100644 --- a/core/frontend/src/cards/js/video.js +++ b/core/frontend/src/cards/js/video.js @@ -101,6 +101,25 @@ }); } + videoElementContainer.onmouseover = () => { + videoPlayerContainer.classList.remove("kg-video-hide"); + } + + videoElementContainer.onmouseleave = () => { + const isPlaying = !!(videoEl.currentTime > 0 && !videoEl.paused && !videoEl.ended && videoEl.readyState > 2); + if (isPlaying) { + videoPlayerContainer.classList.add("kg-video-hide"); + } + } + + videoEl.onplay = () => { + largePlayIcon.classList.add("kg-video-hide"); + videoOverlay.classList.add("kg-video-hide"); + playIconContainer.classList.add("kg-video-hide"); + pauseIconContainer.classList.remove("kg-video-hide"); + videoPlayerContainer.classList.add("kg-video-hide"); + }; + const handleOnPlay = () => { largePlayIcon.classList.add("kg-video-hide"); videoOverlay.classList.add("kg-video-hide");