|
27 | 27 | justify-content: center; |
28 | 28 | } |
29 | 29 |
|
30 | | - video { |
| 30 | + .video-container { |
| 31 | + position: relative; |
31 | 32 | width: 100vw; |
32 | 33 | height: 100vh; |
| 34 | + display: flex; |
| 35 | + align-items: center; |
| 36 | + justify-content: center; |
| 37 | + } |
| 38 | + |
| 39 | + video { |
| 40 | + width: 100%; |
| 41 | + height: 100%; |
33 | 42 | object-fit: contain; |
34 | 43 | background: #000; |
35 | 44 | } |
|
52 | 61 | transition: box-shadow 0.3s ease; |
53 | 62 | } |
54 | 63 |
|
| 64 | + /* Ensure overlay is visible in fullscreen */ |
| 65 | + .video-container:fullscreen .social-overlay, |
| 66 | + .video-container:-webkit-full-screen .social-overlay, |
| 67 | + .video-container:-moz-full-screen .social-overlay, |
| 68 | + .video-container:-ms-fullscreen .social-overlay { |
| 69 | + position: fixed; |
| 70 | + z-index: 2147483647; |
| 71 | + } |
| 72 | + |
55 | 73 | .social-overlay:hover { |
56 | 74 | box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4); |
57 | 75 | } |
|
177 | 195 | </style> |
178 | 196 | </head> |
179 | 197 | <body> |
180 | | - <video id="mainVideo" controls playsinline preload="auto" loop> |
181 | | - Your browser does not support HTML5 video. |
182 | | - </video> |
183 | | - |
184 | | - <div class="social-overlay" id="socialOverlay"> |
| 198 | + <div class="video-container" id="videoContainer"> |
| 199 | + <video id="mainVideo" controls playsinline preload="auto" loop> |
| 200 | + Your browser does not support HTML5 video. |
| 201 | + </video> |
| 202 | + |
| 203 | + <div class="social-overlay" id="socialOverlay"> |
185 | 204 | <div class="social-links"> |
186 | 205 | <a href="https://www.facebook.com/groups/perujug" target="_blank" rel="noopener noreferrer" class="social-link facebook" title="Facebook"> |
187 | 206 | <div class="social-icon"> |
|
286 | 305 | } |
287 | 306 | }); |
288 | 307 |
|
289 | | - // Request fullscreen when video can play |
| 308 | + // Request fullscreen on container (so overlay is visible) |
| 309 | + const videoContainer = document.getElementById('videoContainer'); |
| 310 | + |
290 | 311 | video.addEventListener('loadedmetadata', () => { |
291 | 312 | console.log('Video metadata loaded, duration:', video.duration); |
292 | 313 |
|
293 | | - // Try to enter fullscreen |
| 314 | + // Try to enter fullscreen on container |
294 | 315 | const requestFullscreen = () => { |
295 | | - if (video.requestFullscreen) { |
296 | | - video.requestFullscreen().catch(err => { |
| 316 | + const element = videoContainer; |
| 317 | + if (element.requestFullscreen) { |
| 318 | + element.requestFullscreen().catch(err => { |
297 | 319 | console.log('Fullscreen request failed:', err); |
298 | 320 | }); |
299 | | - } else if (video.webkitRequestFullscreen) { |
300 | | - video.webkitRequestFullscreen(); |
301 | | - } else if (video.mozRequestFullScreen) { |
302 | | - video.mozRequestFullScreen(); |
303 | | - } else if (video.msRequestFullscreen) { |
304 | | - video.msRequestFullscreen(); |
| 321 | + } else if (element.webkitRequestFullscreen) { |
| 322 | + element.webkitRequestFullscreen(); |
| 323 | + } else if (element.mozRequestFullScreen) { |
| 324 | + element.mozRequestFullScreen(); |
| 325 | + } else if (element.msRequestFullscreen) { |
| 326 | + element.msRequestFullscreen(); |
305 | 327 | } |
306 | 328 | }; |
307 | 329 |
|
308 | 330 | // Request fullscreen after a short delay |
309 | 331 | setTimeout(requestFullscreen, 500); |
310 | 332 | }); |
311 | 333 |
|
| 334 | + // Handle fullscreen change events |
| 335 | + document.addEventListener('fullscreenchange', updateOverlayPosition); |
| 336 | + document.addEventListener('webkitfullscreenchange', updateOverlayPosition); |
| 337 | + document.addEventListener('mozfullscreenchange', updateOverlayPosition); |
| 338 | + document.addEventListener('MSFullscreenChange', updateOverlayPosition); |
| 339 | + |
| 340 | + function updateOverlayPosition() { |
| 341 | + // Ensure overlay is visible and positioned correctly in fullscreen |
| 342 | + const isFullscreen = document.fullscreenElement || |
| 343 | + document.webkitFullscreenElement || |
| 344 | + document.mozFullScreenElement || |
| 345 | + document.msFullscreenElement; |
| 346 | + |
| 347 | + if (isFullscreen) { |
| 348 | + // Overlay should remain visible and draggable |
| 349 | + socialOverlay.style.position = 'fixed'; |
| 350 | + socialOverlay.style.zIndex = '2147483647'; |
| 351 | + } |
| 352 | + } |
| 353 | + |
312 | 354 | // Ensure video plays |
313 | 355 | video.addEventListener('canplay', () => { |
314 | 356 | console.log('Video can play'); |
|
453 | 495 | currentX = clientX - initialX; |
454 | 496 | currentY = clientY - initialY; |
455 | 497 |
|
| 498 | + // Get viewport dimensions (works in both normal and fullscreen) |
| 499 | + const isFullscreen = document.fullscreenElement || |
| 500 | + document.webkitFullscreenElement || |
| 501 | + document.mozFullScreenElement || |
| 502 | + document.msFullscreenElement; |
| 503 | + |
| 504 | + const viewportWidth = isFullscreen ? |
| 505 | + (document.fullscreenElement?.clientWidth || window.innerWidth) : |
| 506 | + window.innerWidth; |
| 507 | + const viewportHeight = isFullscreen ? |
| 508 | + (document.fullscreenElement?.clientHeight || window.innerHeight) : |
| 509 | + window.innerHeight; |
| 510 | + |
456 | 511 | // Keep overlay within viewport bounds |
457 | 512 | const rect = socialOverlay.getBoundingClientRect(); |
458 | | - const maxX = window.innerWidth - rect.width; |
459 | | - const maxY = window.innerHeight - rect.height; |
| 513 | + const maxX = viewportWidth - rect.width; |
| 514 | + const maxY = viewportHeight - rect.height; |
460 | 515 |
|
461 | 516 | currentX = Math.max(0, Math.min(currentX, maxX)); |
462 | 517 | currentY = Math.max(0, Math.min(currentY, maxY)); |
|
0 commit comments