Skip to content

Commit

Permalink
Provide default values to avoid potential NAN values when using dynam…
Browse files Browse the repository at this point in the history
…ic aspect ratios
  • Loading branch information
richardFocus authored Jul 3, 2024
1 parent d79251f commit 5ce6fc8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Frontend/library/src/Util/CoordinateConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 5ce6fc8

Please sign in to comment.