From 5ce6fc85bffe13cccbda32c944e29a5274544e9c Mon Sep 17 00:00:00 2001 From: richardFocus <164948400+richardFocus@users.noreply.github.com> Date: Wed, 3 Jul 2024 21:19:54 +0100 Subject: [PATCH] Provide default values to avoid potential NAN values when using dynamic aspect ratios --- Frontend/library/src/Util/CoordinateConverter.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Frontend/library/src/Util/CoordinateConverter.ts b/Frontend/library/src/Util/CoordinateConverter.ts index 2df94385..32af6ed3 100644 --- a/Frontend/library/src/Util/CoordinateConverter.ts +++ b/Frontend/library/src/Util/CoordinateConverter.ts @@ -92,11 +92,12 @@ export class CoordinateConverter { this.videoElement = this.videoElementProvider.getVideoElement(); if (this.videoElementParent && this.videoElement) { - const playerAspectRatio = - this.videoElementParent.clientHeight / - this.videoElementParent.clientWidth; - const videoAspectRatio = - this.videoElement.videoHeight / this.videoElement.videoWidth; + const playerWidth = this.videoElementParent.clientWidth || 1; + const playerHeight = this.videoElementParent.clientHeight || 1; + const videoWidth = this.videoElement.videoWidth || 1; + const videoHeight = this.videoElement.videoHeight || 1; + const playerAspectRatio = playerHeight / playerWidth; + const videoAspectRatio = videoHeight / videoWidth; if (playerAspectRatio > videoAspectRatio) { Logger.Log( Logger.GetStackTrace(),