Skip to content

Commit

Permalink
Update jellron-display to resize to fill available space, with resp…
Browse files Browse the repository at this point in the history
…ect to the MediaStream's aspect ratio
  • Loading branch information
Valkryst committed Dec 7, 2023
1 parent 0f9b979 commit 878a945
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ table, th, td {
#jellron-display {
margin: 0 auto;

height: 600px;
width: 800px;
height: 800px;
width: 50%;

& > canvas, & > video {
position: absolute;
Expand Down
6 changes: 5 additions & 1 deletion js/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ export class Camera {
}

this.videoElement.srcObject = await this.getVideoInputDevice();
this.videoElement.height = this.jellronDisplay.scrollHeight;

const aspectRatio = await this.getMediaStreamWidth() / await this.getMediaStreamHeight();
this.videoElement.parentElement.style.aspectRatio = aspectRatio;
this.videoElement.style.aspectRatio = aspectRatio;

this.videoElement.width = this.jellronDisplay.scrollWidth;
}

Expand Down

0 comments on commit 878a945

Please sign in to comment.