@@ -61,6 +61,7 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
6161
6262 private unmounted = true ;
6363 private image = createRef < HTMLImageElement > ( ) ;
64+ private placeholder = createRef < HTMLDivElement > ( ) ;
6465 private timeout ?: number ;
6566 private sizeWatcher ?: string ;
6667
@@ -453,7 +454,11 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
453454 "mx_MImageBody_placeholder--blurhash" : this . props . mxEvent . getContent ( ) . info ?. [ BLURHASH_FIELD ] ,
454455 } ) ;
455456
456- placeholder = < div className = { classes } > { this . getPlaceholder ( maxWidth , maxHeight ) } </ div > ;
457+ placeholder = (
458+ < div className = { classes } ref = { this . placeholder } >
459+ { this . getPlaceholder ( maxWidth , maxHeight ) }
460+ </ div >
461+ ) ;
457462 }
458463
459464 let showPlaceholder = Boolean ( placeholder ) ;
@@ -499,8 +504,19 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
499504 if ( ! this . props . forExport ) {
500505 placeholder = (
501506 < SwitchTransition mode = "out-in" >
502- < CSSTransition classNames = "mx_rtg--fade" key = { `img-${ showPlaceholder } ` } timeout = { 300 } >
503- { showPlaceholder ? placeholder : < > </ > /* Transition always expects a child */ }
507+ < CSSTransition
508+ classNames = "mx_rtg--fade"
509+ key = { `img-${ showPlaceholder } ` }
510+ timeout = { 300 }
511+ nodeRef = { this . placeholder }
512+ >
513+ {
514+ showPlaceholder ? (
515+ placeholder
516+ ) : (
517+ < div ref = { this . placeholder } />
518+ ) /* Transition always expects a child */
519+ }
504520 </ CSSTransition >
505521 </ SwitchTransition >
506522 ) ;
0 commit comments