Skip to content

Commit a94431e

Browse files
committed
Alias vidRef.current to video for easier parsing
1 parent 83d75d3 commit a94431e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

dotcom-rendering/src/components/LoopVideo.importable.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { css } from '@emotion/react';
22
import { log, storage } from '@guardian/libs';
3+
import { space } from '@guardian/source/foundations';
34
import { SvgAudio, SvgAudioMute } from '@guardian/source/react-components';
45
import { useCallback, useEffect, useRef, useState } from 'react';
56
import {
@@ -25,7 +26,6 @@ import type {
2526
} from './LoopVideoPlayer';
2627
import { LoopVideoPlayer } from './LoopVideoPlayer';
2728
import { ophanTrackerWeb } from './YoutubeAtom/eventEmitters';
28-
import { space } from '@guardian/source/foundations';
2929

3030
const 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

Comments
 (0)