@@ -25,6 +25,7 @@ interface ControlProps {
2525 forceMobile ?: boolean ;
2626 isMobile : boolean ;
2727 isSmall : boolean ;
28+ viewerRef : React . RefObject < HTMLDivElement > ;
2829}
2930
3031interface PdfViewerProps {
@@ -57,7 +58,7 @@ function useBreakpoint() {
5758}
5859
5960const Controls = memo ( function Controls ( { documentId, toggleFullscreen, isFullscreen, onDownload,
60- forceMobile, isMobile, isSmall} : ControlProps ) {
61+ forceMobile, isMobile, isSmall, viewerRef } : ControlProps ) {
6162
6263 const { provides : zoomProv , state : zoomState } = useZoom ( documentId ) ;
6364 const { provides : scrollProv , state : scrollState } = useScroll ( documentId ) ;
@@ -127,7 +128,7 @@ const Controls = memo(function Controls({documentId, toggleFullscreen, isFullscr
127128 < Download size = { 24 } />
128129 </ Button >
129130
130- < ShareButton />
131+ < ShareButton isFullscreen = { isFullscreen } viewerRef = { viewerRef } />
131132
132133 < Button
133134 onClick = { zoomOut }
@@ -492,47 +493,48 @@ if (isLoading || !engine) {
492493 forceMobile = { true }
493494 isMobile = { isMobile }
494495 isSmall = { isSmall }
496+ viewerRef = { viewerRef }
495497 /> }
496498 < DocumentContent documentId = { activeDocumentId } >
497- { ( { isLoaded } ) => (
498- < >
499- < div
500- className = "absolute inset-0 z-50 flex items-center justify-center bg-[#070114]"
501- style = { {
502- opacity : isLoaded ? 0 : 1 ,
503- pointerEvents : isLoaded ? "none" : "auto" ,
504- transition : "opacity 0.3s" ,
505- backgroundColor : effectiveBackgroundColor ,
506- } }
507- >
508- < Loader
509- backgroundColor = { effectiveBackgroundColor }
510- textColor = { loaderTextColor }
511- />
512- </ div >
513- < Viewport
514- documentId = { activeDocumentId }
515- style = { {
516- backgroundColor : effectiveBackgroundColor ,
517- visibility : isLoaded ? "visible" : "hidden" ,
518- } }
519- >
520- < Scroller
521- documentId = { activeDocumentId }
522- renderPage = { ( { width, height, pageIndex } ) => (
523- < div
524- style = { { width, height } }
525- onClick = { ( e ) => e . stopPropagation ( ) }
526- >
527- < RenderLayer documentId = { activeDocumentId } pageIndex = { pageIndex } />
528- </ div >
529- ) }
530- />
531- </ Viewport >
532- </ >
533- ) }
534- </ DocumentContent >
535-
499+ { ( { isLoaded } ) => (
500+ < >
501+ < div
502+ className = "absolute inset-0 z-50 flex items-center justify-center bg-[#070114]"
503+ style = { {
504+ opacity : isLoaded ? 0 : 1 ,
505+ pointerEvents : isLoaded ? "none" : "auto" ,
506+ transition : "opacity 0.3s" ,
507+ backgroundColor : effectiveBackgroundColor ,
508+ } }
509+ >
510+ < Loader
511+ backgroundColor = { effectiveBackgroundColor }
512+ textColor = { loaderTextColor }
513+ />
514+ </ div >
515+ < Viewport
516+ documentId = { activeDocumentId }
517+ style = { {
518+ backgroundColor : effectiveBackgroundColor ,
519+ visibility : isLoaded ? "visible" : "hidden" ,
520+ } }
521+ >
522+ < Scroller
523+ documentId = { activeDocumentId }
524+ renderPage = { ( { width, height, pageIndex } ) => (
525+ < div
526+ style = { { width, height } }
527+ onClick = { ( e ) => e . stopPropagation ( ) }
528+ >
529+ < RenderLayer documentId = { activeDocumentId } pageIndex = { pageIndex } />
530+ </ div >
531+ ) }
532+ />
533+ </ Viewport >
534+ </ >
535+ ) }
536+ </ DocumentContent >
537+
536538 { ! hideControls && ( ! isMobile || isFullscreen ) && (
537539 < Controls
538540 documentId = { activeDocumentId }
@@ -542,6 +544,7 @@ if (isLoading || !engine) {
542544 forceMobile = { false }
543545 isMobile = { isMobile }
544546 isSmall = { isSmall }
547+ viewerRef = { viewerRef }
545548 />
546549 ) }
547550 </ >
0 commit comments