RunLevel works, even though half-assed

This commit is contained in:
Tamius Han 2024-05-07 20:24:50 +02:00
parent 277506b3c8
commit 968ce5432a
2 changed files with 5 additions and 16 deletions

View File

@ -402,6 +402,10 @@ class VideoData {
if (runLevel >= RunLevel.CustomCSSActive) {
this.video.classList.add(this.baseCssName);
this.video.classList.add(this.userCssClassName);
// inject custom CSS classes
this.preparePage();
this.enabled = true;
}
}

View File

@ -246,7 +246,7 @@ class Resizer {
return;
}
if ([AspectRatioType.Reset].includes(ar.type)) {
if ([AspectRatioType.Reset, AspectRatioType.Initial].includes(ar.type)) {
this.eventBus.send('set-run-level', RunLevel.UIOnly);
} else {
this.eventBus.send('set-run-level', RunLevel.CustomCSSActive);
@ -260,18 +260,6 @@ class Resizer {
this.videoData.arDetector?.stop();
}
// unless we're trying to reset aspect ratio, we need to tell VideoData that this would
// be a good time to start injecting CSS modifications into the page.
//
// CSS, et. al. initialization is deferred in order to avoid breaking wonky sites by default.
if (ar.type !== AspectRatioType.Reset && ar.type !== AspectRatioType.Initial) {
await this.videoData.preparePage();
} else {
console.log('Disabling videoData')
this.videoData.disable();
return;
}
if (ar.type !== AspectRatioType.AutomaticUpdate) {
this.manualZoom = false;
}
@ -281,8 +269,6 @@ class Resizer {
this.videoData.videoUnloaded();
}
this.logger.log('info', 'debug', '[Resizer::setAr] <rid:'+this.resizerId+'> trying to set ar. New ar:', ar);
this.logger.log('info', 'debug', '%c[Resizer::setAr] <rid:'+this.resizerId+'> trying to set ar. New ar:', 'background-color: #4c3a2f, color: #ffa349', ar);
if (ar == null) {
@ -351,7 +337,6 @@ class Resizer {
|| this.stretcher.mode === StretchType.Conditional
|| this.stretcher.mode === StretchType.FixedSource
){
stretchFactors = this.scaler.calculateCrop(ar);
if(! stretchFactors || stretchFactors.error){