Skip to content

Commit 01caf61

Browse files
committed
Correct calculations and wordings of some dimensions
1 parent 0edff6b commit 01caf61

File tree

5 files changed

+47
-34
lines changed

5 files changed

+47
-34
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"@types/node": "24.10.1",
9292
"@types/superagent": "8.1.9",
9393
"@types/ua-parser-js": "0.7.39",
94-
"@vitest/eslint-plugin": "1.5.2",
94+
"@vitest/eslint-plugin": "1.6.4",
9595
"audit-ci": "7.1.0",
9696
"chromatic": "13.3.4",
9797
"cross-env": "10.1.0",

src/wrappers/container.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class Container extends Despot {
398398
const heightDimension = this.visuals.getRecorderHeight(true);
399399

400400
videomailFormData.width = widthDimension?.value;
401-
videomailFormData.height = heightDimension.value;
401+
videomailFormData.height = heightDimension?.value;
402402

403403
return await this.resource.post(videomailFormData);
404404
} else if (method === FormMethod.PUT) {

src/wrappers/visuals/notifier.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ class Notifier extends Despot {
167167
const heightDimension = this.visuals.getRecorderHeight(true, true);
168168

169169
this.notifyElement.style.width = "auto";
170-
this.notifyElement.style.height = `${heightDimension.value}${heightDimension.unit}`;
170+
171+
if (heightDimension) {
172+
this.notifyElement.style.height = `${heightDimension.value}${heightDimension.unit}`;
173+
}
171174
} else {
172175
let heightDimension: Dimension | undefined;
173176
let widthDimension = useFullWidth(this.options.video.mobileBreakPoint);

src/wrappers/visuals/recorder.ts

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class Recorder extends Despot {
338338
this.emit("PREVIEW", {
339339
key: this.key,
340340
width: widthDimension?.value,
341-
height: heightDimension.value,
341+
height: heightDimension?.value,
342342
hasAudio,
343343
duration,
344344
});
@@ -1348,7 +1348,7 @@ class Recorder extends Despot {
13481348
if (this.options.video.height) {
13491349
const recorderHeight = this.getRecorderHeight(true);
13501350

1351-
if (recorderHeight.value) {
1351+
if (recorderHeight?.value) {
13521352
this.recorderElement.height = recorderHeight.value;
13531353
} else {
13541354
this.recorderElement.style.removeProperty("height");
@@ -1542,36 +1542,34 @@ class Recorder extends Despot {
15421542
}
15431543

15441544
public getRecorderHeight(responsive: boolean, useBoundingClientRect?: boolean) {
1545+
let recorderHeight: Dimension | undefined;
1546+
15451547
if (this.recorderElement && useBoundingClientRect) {
15461548
const height = this.recorderElement.getBoundingClientRect().height;
15471549

1548-
const dimension: Dimension = {
1550+
recorderHeight = {
15491551
unit: "px",
15501552
value: height,
15511553
};
1552-
1553-
return dimension;
15541554
} else if (this.userMedia) {
15551555
const height = this.userMedia.getRawHeight(responsive);
15561556

1557-
const dimension: Dimension = {
1557+
recorderHeight = {
15581558
unit: "px",
15591559
value: height,
15601560
};
1561-
1562-
return dimension;
15631561
} else if (responsive && this.options.video.height) {
1564-
return this.calculateHeight(responsive);
1565-
}
1566-
1567-
const height = this.options.video.height;
1562+
recorderHeight = this.calculateHeight(responsive);
1563+
} else if (this.options.video.height) {
1564+
const height = this.options.video.height;
15681565

1569-
const dimension: Dimension = {
1570-
unit: "px",
1571-
value: height,
1572-
};
1566+
recorderHeight = {
1567+
unit: "px",
1568+
value: height,
1569+
};
1570+
}
15731571

1574-
return dimension;
1572+
return recorderHeight;
15751573
}
15761574

15771575
private getRatio() {
@@ -1608,21 +1606,33 @@ class Recorder extends Despot {
16081606
}
16091607

16101608
public calculateHeight(responsive: boolean) {
1611-
let videoWidth: number | undefined;
1609+
let videoDimension: Dimension | undefined;
16121610

16131611
if (this.userMedia) {
1614-
videoWidth = this.userMedia.getVideoWidth();
1612+
const videoHeight = this.userMedia.getVideoHeight();
1613+
1614+
videoDimension = {
1615+
value: videoHeight,
1616+
unit: "px",
1617+
};
16151618
} else if (this.recorderElement) {
1616-
videoWidth = this.recorderElement.videoWidth || this.recorderElement.width;
1619+
const videoHeight = this.recorderElement.videoHeight || this.recorderElement.height;
1620+
1621+
videoDimension = {
1622+
value: videoHeight,
1623+
unit: "px",
1624+
};
1625+
} else {
1626+
videoDimension = calculateHeight(
1627+
responsive,
1628+
undefined,
1629+
this.options,
1630+
this.getRatio(),
1631+
this.recorderElement,
1632+
);
16171633
}
16181634

1619-
return calculateHeight(
1620-
responsive,
1621-
videoWidth,
1622-
this.options,
1623-
this.getRatio(),
1624-
this.recorderElement,
1625-
);
1635+
return videoDimension;
16261636
}
16271637

16281638
public getRawVisualUserMedia() {

0 commit comments

Comments
 (0)