Implement inactivity-based visibility for back button in video overlay
This commit is contained in:
parent
7eb737705e
commit
e880a93dcb
@ -95,10 +95,9 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: block;
|
display: block;
|
||||||
position: fixed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#video-overlay-container #back-button {
|
#video-overlay-container #back-button { /* Back button is now inside the container */
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 20px;
|
top: 20px;
|
||||||
left: 20px;
|
left: 20px;
|
||||||
@ -110,6 +109,12 @@
|
|||||||
border: 1px solid white;
|
border: 1px solid white;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
opacity: 1; /* Visible by default */
|
||||||
|
transition: opacity 0.3s ease-in-out; /* Smooth transition */
|
||||||
|
}
|
||||||
|
|
||||||
|
#video-overlay-container #back-button.button-hidden {
|
||||||
|
opacity: 0; /* Class to hide the button */
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
@ -149,6 +154,21 @@
|
|||||||
let backButton = $("<button id='back-button'>Back</button>")
|
let backButton = $("<button id='back-button'>Back</button>")
|
||||||
.appendTo(overlayContainer);
|
.appendTo(overlayContainer);
|
||||||
|
|
||||||
|
// Mouse inactivity logic for back button
|
||||||
|
let inactivityTimer;
|
||||||
|
function showButtonAndResetTimer() {
|
||||||
|
backButton.removeClass('button-hidden');
|
||||||
|
clearTimeout(inactivityTimer);
|
||||||
|
inactivityTimer = setTimeout(function() {
|
||||||
|
backButton.addClass('button-hidden');
|
||||||
|
}, 3000); // 3 seconds
|
||||||
|
}
|
||||||
|
|
||||||
|
overlayContainer.on('mousemove.inactivityControls', function() {
|
||||||
|
showButtonAndResetTimer();
|
||||||
|
});
|
||||||
|
showButtonAndResetTimer(); // Initial call to show and start timer
|
||||||
|
|
||||||
// Request fullscreen on the container
|
// Request fullscreen on the container
|
||||||
const containerEl = overlayContainer[0];
|
const containerEl = overlayContainer[0];
|
||||||
if (containerEl.requestFullscreen) {
|
if (containerEl.requestFullscreen) {
|
||||||
@ -165,6 +185,7 @@
|
|||||||
if (videoElement && videoElement.pause) {
|
if (videoElement && videoElement.pause) {
|
||||||
videoElement.pause();
|
videoElement.pause();
|
||||||
}
|
}
|
||||||
|
clearTimeout(inactivityTimer); // Clear inactivity timer
|
||||||
// Exit fullscreen if active
|
// Exit fullscreen if active
|
||||||
if (document.fullscreenElement || document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement) {
|
if (document.fullscreenElement || document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement) {
|
||||||
if (document.exitFullscreen) {
|
if (document.exitFullscreen) {
|
||||||
@ -178,6 +199,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (overlayContainer) {
|
if (overlayContainer) {
|
||||||
|
overlayContainer.off('mousemove.inactivityControls'); // Remove specific listener
|
||||||
overlayContainer.remove();
|
overlayContainer.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user