File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -135,6 +135,7 @@ export function HtmlRenderFrame(props: {
135135 ) }
136136 onContentHeight = { fitPage }
137137 onLoad = { showPage }
138+ onFullscreenChange = { onFullscreenChange }
138139 />
139140 < div className = "absolute end-2 top-2 flex gap-1 opacity-0 transition-opacity duration-150 focus-within:opacity-100 group-hover/html-render:opacity-100 pointer-coarse:opacity-100" >
140141 < Tooltip >
Original file line number Diff line number Diff line change @@ -127,6 +127,8 @@ export function HtmlRenderDocument(props: {
127127 readonly threadRef ?: ScopedThreadRef | undefined ;
128128 /** Receives the page's content height whenever it changes, so an inline frame can fit it. */
129129 readonly onContentHeight ?: ( height : number ) => void ;
130+ /** Reports the image viewer opening and closing, so a virtualized row can stay mounted. */
131+ readonly onFullscreenChange ?: ( ( fullscreen : boolean ) => void ) | undefined ;
130132 /** Called when the page has loaded. */
131133 readonly onLoad ?: ( ) => void ;
132134} ) {
@@ -290,6 +292,12 @@ export function HtmlRenderDocument(props: {
290292 window . addEventListener ( "message" , openImage ) ;
291293 return ( ) => window . removeEventListener ( "message" , openImage ) ;
292294 } , [ ] ) ;
295+ const { onFullscreenChange } = props ;
296+ useEffect ( ( ) => {
297+ if ( expandedImage === null ) return ;
298+ onFullscreenChange ?.( true ) ;
299+ return ( ) => onFullscreenChange ?.( false ) ;
300+ } , [ expandedImage , onFullscreenChange ] ) ;
293301 const { onContentHeight } = props ;
294302 // A page posts its height once per change, so listen from the commit that
295303 // inserts the frame; a passive effect could run after a fast page's first post.
You can’t perform that action at this time.
0 commit comments