@@ -44,15 +44,30 @@ export const ImageZoomable: React.FC<ImageZoomableWrapperProps> = ({ src, alt })
4444
4545 useEffect ( ( ) => {
4646 window . onresize = ( ) => {
47- setIsFullScreen ( ( document . fullscreenElement != null ) ? true : false ) ;
48- if ( document . fullscreenElement ) {
49- console . log ( document . fullscreenElement )
47+ setIsFullScreen ( ( document . fullscreenElement != null ) ? true : false ) ;
48+ if ( document . fullscreenElement ) {
5049
51- const ele = document . fullscreenElement as HTMLElement
52- ele . style . display = 'flex' ;
53- ele . style . alignItems = 'center' ;
54- ele . style . justifyContent = 'center' ;
50+ // when entered fullscreen, set image position to flex-centered for better display
51+ const ele = document . fullscreenElement as HTMLElement
52+ ele . style . display = 'flex' ;
53+ ele . style . alignItems = 'center' ;
54+ ele . style . justifyContent = 'center' ;
55+ ele . style . flexFlow = 'column-reverse' ;
56+
57+ // when entered fullscreen, unset 'position:absolute' zoom button group for better display
58+ const ele2 = ele . querySelector ( ".ZoomButtonGroup" ) as HTMLElement ;
59+ ele2 . style . position = 'unset' ;
60+
61+ } else {
62+ if ( ImageZoomableRef . current ) {
63+ // exited fullscreen and back to normal position
64+ ImageZoomableRef . current . style . display = 'block' ;
65+
66+ // exited fullscreen and restore 'position:absolute' of zoom button group
67+ const ele2 = ImageZoomableRef . current . querySelector ( ".ZoomButtonGroup" ) as HTMLElement ;
68+ ele2 . style . position = 'absolute' ;
5569 }
70+ }
5671 }
5772 } )
5873
0 commit comments