Overview
TheuseFullscreenChatOverlay hook manages the chat overlay that appears when the video player enters fullscreen mode. It automatically shows the chat when entering fullscreen and hides it when exiting.
Usage
Return Value
Whether the page is currently in fullscreen mode. Tracks browser fullscreen API state.
Whether the chat overlay should be visible. Automatically set to
true when entering fullscreen.Whether the chat overlay is minimized. When minimized, only the chat header is visible.
Toggles the chat overlay between minimized and expanded states.
Closes the chat overlay completely. User can reopen it with
showChatOverlayManually.Manually shows the chat overlay. Useful for reopening after closing, or showing chat without entering fullscreen.
Behavior
Automatic Fullscreen Detection
The hook automatically detects fullscreen state changes using the Fullscreen API:src/hooks/use-fullscreen-chat-overlay.ts:11-33
fullscreenchange(standard)webkitfullscreenchange(Safari, older Chrome)msfullscreenchange(Internet Explorer/Edge)
State Transitions
Entering fullscreen
When the video player enters fullscreen:
isFullscreen→trueshowChatOverlay→trueisChatMinimized→false
User minimizes chat
User clicks minimize button:
isChatMinimized→true
User closes chat
User clicks close button:
showChatOverlay→false
Example: Complete Chat Overlay
Browser Compatibility
The hook supports multiple fullscreen API implementations:| Browser | API Support |
|---|---|
| Chrome 71+ | fullscreenElement |
| Safari 6+ | webkitFullscreenElement |
| Firefox 64+ | fullscreenElement |
| Edge 79+ | fullscreenElement |
| IE 11 | msFullscreenElement |
The hook automatically detects which API is available and uses the appropriate one.
Common Use Cases
Manual chat toggle button
Manual chat toggle button
Conditional UI based on fullscreen
Conditional UI based on fullscreen
Show different UI elements based on fullscreen state:
Persist chat minimize state
Persist chat minimize state
Remember user’s preference for minimized state:
Related Components
- ChatOverlay - The actual overlay component that uses this hook
- VideoPlayer - Controls fullscreen mode that triggers the overlay
- RoomPage - Coordinates both video and chat overlays
Related Hooks
useRoom
Manage room state and chat messages
useVideoSync
Control video playback in fullscreen