Skip to content

Commit 2ce76fd

Browse files
committed
Update comment
1 parent 49b9894 commit 2ce76fd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

dotcom-rendering/src/components/LoopVideoProgressBar.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ export const LoopVideoProgressBar = ({
4444
if (duration <= 0) return null;
4545

4646
/**
47-
* We achieve a smooth progress bar by using CSS transitions. However, this means that
48-
* the time on the progress bar is roughly always about 0.25 seconds behind - the interval in
49-
* which the onTimeUpdate event on video is fired. Therefore, to the user it looks like the
50-
* progress bar ranges from 0s to duration - 0.25s. To make allowance for this, when calculating
51-
* the progress percentage, we take 0.25s off the duration, so that the progress bar reaches
52-
* closer to the end.
47+
* We achieve a smooth progress bar by using CSS transitions. Given that
48+
* onTimeUpdate firesevery 250ms or so, this means that the time on the
49+
* progress bar is always about 0.25s behind and begins 0.25s late.
50+
* Therefore, when calculating the progress percentage, we take 0.25s off the duration.
51+
*
52+
* Videos less than a second in duration will have no adjustment.
5353
*/
54-
const adjustedDuration = Math.max(duration - 0.25, 0.1);
54+
const adjustedDuration = duration > 1 ? duration - 0.25 : duration;
5555

5656
const progressPercentage = Math.min(
5757
(currentTime * 100) / adjustedDuration,

0 commit comments

Comments
 (0)