11import { css } from '@emotion/react' ;
22import { log , storage } from '@guardian/libs' ;
3+ import { space } from '@guardian/source/foundations' ;
34import { SvgAudio , SvgAudioMute } from '@guardian/source/react-components' ;
45import { useCallback , useEffect , useRef , useState } from 'react' ;
56import {
@@ -25,7 +26,6 @@ import type {
2526} from './LoopVideoPlayer' ;
2627import { LoopVideoPlayer } from './LoopVideoPlayer' ;
2728import { ophanTrackerWeb } from './YoutubeAtom/eventEmitters' ;
28- import { space } from '@guardian/source/foundations' ;
2929
3030const videoContainerStyles = css `
3131 z-index : ${ getZIndex ( 'loop-video-container' ) } ;
@@ -488,14 +488,15 @@ export const LoopVideo = ({
488488 }
489489
490490 const handleLoadedMetadata = ( ) => {
491- if ( ! vidRef . current ) return ;
491+ const video = vidRef . current ;
492+ if ( ! video ) return ;
492493
493- const track = vidRef . current . textTracks [ 0 ] ;
494+ const track = video . textTracks [ 0 ] ;
494495 if ( ! track ?. cues ) return ;
495496 const pxFromBottom = space [ 3 ] ;
496497 const videoHeight =
497- vidRef . current . getBoundingClientRect ( ) . height ||
498- vidRef . current . clientHeight ||
498+ video . getBoundingClientRect ( ) . height ||
499+ video . clientHeight ||
499500 height ;
500501 const percentFromTop =
501502 ( ( videoHeight - pxFromBottom ) / videoHeight ) * 100 ;
0 commit comments