Make sure aspect ratio makes sense before setting it. Don't set NaN for aspect ratio, that tends to break things
This commit is contained in:
parent
4b177a9724
commit
c5f6868a63
@ -391,7 +391,11 @@ class ArDetector {
|
|||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
getDefaultAr() {
|
getDefaultAr() {
|
||||||
return this.video.videoWidth / this.video.videoHeight;
|
const ratio = this.video.videoWidth / this.video.videoHeight;
|
||||||
|
if (isNaN(ratio)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateArFromEdges(edges) {
|
calculateArFromEdges(edges) {
|
||||||
|
@ -121,6 +121,19 @@ class Resizer {
|
|||||||
|
|
||||||
|
|
||||||
updateAr(ar) {
|
updateAr(ar) {
|
||||||
|
if (!ar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some options require a bit more testing re: whether they make sense
|
||||||
|
// if they don't, we refuse to update aspect ratio until they do
|
||||||
|
if (ar.type === AspectRatio.Automatic || ar.type === AspectRatio.Fixed) {
|
||||||
|
if (!ar.ratio || isNaN(ar.ratio)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only update aspect ratio if there's a difference between the old and the new state
|
||||||
if (!this.lastAr || ar.type !== this.lastAr.type || ar.ratio !== this.lastAr.ratio) {
|
if (!this.lastAr || ar.type !== this.lastAr.type || ar.ratio !== this.lastAr.ratio) {
|
||||||
this.setAr(ar);
|
this.setAr(ar);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user