@@ -46,6 +46,7 @@ const Controls = () => {
4646 // opacity: 0;
4747 transition: 200ms;
4848 gap: 10px;
49+ margin-top: 10px;
4950}
5051
5152.imgViewerControls button {
@@ -91,7 +92,38 @@ export const ImageClickManagerImgViewerOnly: React.FC = () => {
9192 let scale = Math . min ( scaleX , scaleY ) ;
9293 if ( scale > 1 ) scale = 1 ;
9394
94- const imageDescription = dom_detailsText || dom_figcaptionText || dom_describedbyText || dom_labelledByText || altAttributeOf_HTMLImg_SVGImage_SVGFragment || "" ;
95+ const descriptions = [
96+ { label : __ ( "reader.imgViewer.description.details" ) , value : dom_detailsText } ,
97+ { label : __ ( "reader.imgViewer.description.figcaption" ) , value : dom_figcaptionText } ,
98+ { label : __ ( "reader.imgViewer.description.describedby" ) , value : dom_describedbyText } ,
99+ { label : __ ( "reader.imgViewer.description.labelledby" ) , value : dom_labelledByText } ,
100+ ] ;
101+
102+ const hasAlt = ! ! altAttributeOf_HTMLImg_SVGImage_SVGFragment ;
103+ const activeDescriptions = descriptions . filter ( d => ! ! d . value ) ;
104+ const hasOtherDescriptions = activeDescriptions . length > 0 ;
105+
106+ const imageHasDescription = hasAlt || hasOtherDescriptions ;
107+ const imageHasOnlyAltDescription = hasAlt && ! hasOtherDescriptions ;
108+
109+ const DescriptionList = (
110+ < details style = { { fontSize : "14px" , cursor : "pointer" } } >
111+ < summary >
112+ { altAttributeOf_HTMLImg_SVGImage_SVGFragment || __ ( "reader.imgViewer.description.about" ) }
113+ </ summary >
114+ < ul style = { { marginTop : "10px" , listStyleType : "none" , paddingLeft : 0 } } >
115+ { activeDescriptions . map ( ( { label, value } ) => (
116+ < li key = { label } style = { { marginBottom : "10px" } } >
117+ < strong > { label } : </ strong > { value }
118+ </ li >
119+ ) ) }
120+ </ ul >
121+ </ details >
122+ ) ;
123+
124+ const imageDescription = imageHasOnlyAltDescription
125+ ? altAttributeOf_HTMLImg_SVGImage_SVGFragment
126+ : DescriptionList ;
95127
96128 return ( < >
97129
@@ -115,9 +147,10 @@ export const ImageClickManagerImgViewerOnly: React.FC = () => {
115147 </ Dialog . Close >
116148 </ div >
117149 < div style = { { display : "flex" , flexDirection : "column" , padding : "5px 10px" , alignItems : "center" , flex : 1 } } >
118- < div style = { { position : "relative" , display : "flex" , gap : 10 , width : "100%" , height : "100%" , paddingLeft : 5 , flex : 1 , flexDirection : "column" } } >
150+ < div className = { stylesModals . imageViewerContent } >
151+ < div style = { { transition : "600ms ease-in-out" } } >
119152 < TransformWrapper initialScale = { scale } minScale = { scale / 2 } maxScale = { 4 * scale } >
120- < TransformComponent wrapperStyle = { { display : "flex" , width : "100 %" , height : "100 %" , minHeight : "350px" , flex : "1" , position : "relative" } } >
153+ < TransformComponent wrapperStyle = { { display : "flex" , margin : "auto" , width : "90 %" , height : "90 %" , minHeight : "350px" , flex : "1" , position : "relative" , transition : "600ms ease-in-out " } } >
121154 < img
122155 style = { { height : "100%" , width : "100%" , maxHeight : "calc(100vh - 250px)" , backgroundColor : "white" , color : "black" , fill : "currentcolor" , stroke : "currentcolor" } }
123156 src = { isSVGFragment ? ( "data:image/svg+xml;base64," + Buffer . from ( HTMLImgSrc_SVGImageHref_SVGFragmentMarkup ) . toString ( "base64" ) ) : HTMLImgSrc_SVGImageHref_SVGFragmentMarkup }
@@ -129,12 +162,12 @@ export const ImageClickManagerImgViewerOnly: React.FC = () => {
129162 </ TransformComponent >
130163 < Controls />
131164 </ TransformWrapper >
132- { imageDescription ?
133- < p style = { { maxWidth : "unset" , fontStyle : "italic" } } >
165+ </ div >
166+ { imageHasDescription && (
167+ < div style = { { width : "100%" , marginTop : "10px" } } >
134168 { imageDescription }
135- </ p >
136- : < > </ >
137- }
169+ </ div >
170+ ) }
138171 </ div >
139172 </ div >
140173 </ Dialog . Content >
0 commit comments