Merge pull request #819 from vector-im/dbkr/prefix_other_fullscreen_apis
Use prefixed versions of other fullscreen APIs too
This commit is contained in:
		
				commit
				
					
						11a262b58f
					
				
			
		
					 2 changed files with 15 additions and 2 deletions
				
			
		
							
								
								
									
										6
									
								
								src/@types/global.d.ts
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								src/@types/global.d.ts
									
										
									
									
										vendored
									
									
								
							|  | @ -17,6 +17,12 @@ limitations under the License. | ||||||
| import "matrix-js-sdk/src/@types/global"; | import "matrix-js-sdk/src/@types/global"; | ||||||
| 
 | 
 | ||||||
| declare global { | declare global { | ||||||
|  |   interface Document { | ||||||
|  |     // Safari only supports this prefixed, so tell the type system about it
 | ||||||
|  |     webkitExitFullscreen: () => void; | ||||||
|  |     webkitFullscreenElement: HTMLElement | null; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   interface Window { |   interface Window { | ||||||
|     // TODO: https://gitlab.matrix.org/matrix-org/olm/-/issues/10
 |     // TODO: https://gitlab.matrix.org/matrix-org/olm/-/issues/10
 | ||||||
|     OLM_OPTIONS: Record<string, string>; |     OLM_OPTIONS: Record<string, string>; | ||||||
|  |  | ||||||
|  | @ -54,16 +54,23 @@ export function useFullscreen(ref: React.RefObject<HTMLElement>): { | ||||||
|   ); |   ); | ||||||
| 
 | 
 | ||||||
|   const onFullscreenChanged = useCallback(() => { |   const onFullscreenChanged = useCallback(() => { | ||||||
|     if (!document.fullscreenElement) { |     if (!document.fullscreenElement && !document.webkitFullscreenElement) { | ||||||
|       setFullscreenParticipant(null); |       setFullscreenParticipant(null); | ||||||
|     } |     } | ||||||
|   }, [setFullscreenParticipant]); |   }, [setFullscreenParticipant]); | ||||||
| 
 | 
 | ||||||
|   useEventTarget(ref.current, "fullscreenchange", onFullscreenChanged); |   useEventTarget(ref.current, "fullscreenchange", onFullscreenChanged); | ||||||
|  |   useEventTarget(ref.current, "webkitfullscreenchange", onFullscreenChanged); | ||||||
| 
 | 
 | ||||||
|   useEffect(() => { |   useEffect(() => { | ||||||
|     if (disposed) { |     if (disposed) { | ||||||
|  |       if (document.exitFullscreen) { | ||||||
|         document.exitFullscreen(); |         document.exitFullscreen(); | ||||||
|  |       } else if (document.webkitExitFullscreen) { | ||||||
|  |         document.webkitExitFullscreen(); | ||||||
|  |       } else { | ||||||
|  |         logger.error("No available fullscreen API!"); | ||||||
|  |       } | ||||||
|       setFullscreenParticipant(null); |       setFullscreenParticipant(null); | ||||||
|     } |     } | ||||||
|   }, [disposed]); |   }, [disposed]); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue