diff --git a/src/ext/lib/video-transform/Resizer.ts b/src/ext/lib/video-transform/Resizer.ts index b89f90b..514da3c 100644 --- a/src/ext/lib/video-transform/Resizer.ts +++ b/src/ext/lib/video-transform/Resizer.ts @@ -59,7 +59,7 @@ class Resizer { this.settings = videoData.settings; this.scaler = new Scaler(this.conf); - this.stretcher = new Stretcher(this.conf); + this.stretcher = new Stretcher(this.conf); this.zoom = new Zoom(this.conf); this.videoAlignment = this.settings.getDefaultVideoAlignment(window.location.hostname); // this is initial video alignment @@ -72,17 +72,17 @@ class Resizer { this.canPan = false; } - this.userCssClassName = videoData.userCssClassName; + this.userCssClassName = videoData.userCssClassName; } - + injectCss(css) { this.conf.pageInfo.injectCss(css); } - + ejectCss(css) { this.conf.pageInfo.ejectCss(css); } - + replaceCss(oldCss, newCss) { this.conf.pageInfo.replaceCss(oldCss, newCss); } @@ -101,7 +101,7 @@ class Resizer { if (ar.type !== AspectRatioType.FitWidth && ar.type !== AspectRatioType.FitHeight && ar.ratio) { return ar; } - // Skrbi za "stare" možnosti, kot na primer "na širino zaslona", "na višino zaslona" in "ponastavi". + // Skrbi za "stare" možnosti, kot na primer "na širino zaslona", "na višino zaslona" in "ponastavi". // Približevanje opuščeno. // handles "legacy" options, such as 'fit to widht', 'fit to height' and AspectRatioType.Reset. No zoom tho let ratioOut; @@ -112,22 +112,22 @@ class Resizer { return null; } - + if (! this.conf.player.dimensions) { ratioOut = screen.width / screen.height; } else { this.logger.log('info', 'debug', `[Resizer::calculateRatioForLegacyOptions] Player dimensions:`, this.conf.player.dimensions.width ,'x', this.conf.player.dimensions.height,'aspect ratio:', this.conf.player.dimensions.width / this.conf.player.dimensions.height) ratioOut = this.conf.player.dimensions.width / this.conf.player.dimensions.height; } - + // POMEMBNO: lastAr je potrebno nastaviti šele po tem, ko kličemo _res_setAr(). _res_setAr() predvideva, // da želimo nastaviti statično (type: 'static') razmerje stranic — tudi, če funkcijo kličemo tu oz. v ArDetect. // // IMPORTANT NOTE: lastAr needs to be set after _res_setAr() is called, as _res_setAr() assumes we're - // setting a static aspect ratio (even if the function is called from here or ArDetect). - + // setting a static aspect ratio (even if the function is called from here or ArDetect). + let fileAr = this.conf.video.videoWidth / this.conf.video.videoHeight; - + if (ar.type === AspectRatioType.FitWidth){ ar.ratio = ratioOut > fileAr ? ratioOut : fileAr; } @@ -168,13 +168,13 @@ class Resizer { if (this.destroyed) { return; } - + if (!this.video.videoWidth || !this.video.videoHeight) { this.logger.log('warning', 'debug', '[Resizer::setAr] Video has no width or no height. This is not allowed. Aspect ratio will not be set, and videoData will be uninitialized.'); this.conf.videoUnloaded(); } - - this.logger.log('info', 'debug', '[Resizer::setAr] trying to set ar. New ar:', ar); + + this.logger.log('info', 'debug', '%c[Resizer::setAr] trying to set ar. New ar:', 'background-color: #4c3a2f, color: #ffa349', ar); if (ar == null) { return; @@ -198,10 +198,10 @@ class Resizer { // this means here's the optimal place to set or forget aspect ratio. Saving of current crop ratio // is handled in pageInfo.updateCurrentCrop(), which also makes sure to persist aspect ratio if ar // is set to persist between videos / through current session / until manual reset. - if (ar.type === AspectRatioType.Automatic || + if (ar.type === AspectRatioType.Automatic || ar.type === AspectRatioType.Reset || ar.type === AspectRatioType.Initial ) { - // reset/undo default + // reset/undo default this.conf.pageInfo.updateCurrentCrop(undefined); } else { this.conf.pageInfo.updateCurrentCrop(ar); @@ -224,7 +224,7 @@ class Resizer { // if (this.extensionMode === ExtensionMode.Basic && !PlayerData.isFullScreen() && ar.type !== AspectRatioType.Reset) { // // don't actually apply or calculate css when using basic mode if not in fullscreen // // ... unless we're resetting the aspect ratio to original - // return; + // return; // } if (! this.video) { @@ -234,7 +234,7 @@ class Resizer { // pause AR on: // * ar.type NOT automatic // * ar.type is auto, but stretch is set to basic basic stretch - // + // // unpause when using other modes if (ar.type !== AspectRatioType.Automatic || this.stretcher.mode === StretchType.Basic) { this.conf?.arDetector?.pause(); @@ -245,10 +245,10 @@ class Resizer { } // do stretch thingy - if (this.stretcher.mode === StretchType.NoStretch - || this.stretcher.mode === StretchType.Conditional + if (this.stretcher.mode === StretchType.NoStretch + || this.stretcher.mode === StretchType.Conditional || this.stretcher.mode === StretchType.FixedSource){ - + stretchFactors = this.scaler.calculateCrop(ar); if(! stretchFactors || stretchFactors.error){ @@ -274,7 +274,7 @@ class Resizer { this.stretcher.applyStretchFixedSource(stretchFactors); } this.logger.log('info', 'debug', "[Resizer::setAr] Processed stretch factors for ", - this.stretcher.mode === StretchType.NoStretch ? 'stretch-free crop.' : + this.stretcher.mode === StretchType.NoStretch ? 'stretch-free crop.' : this.stretcher.mode === StretchType.Conditional ? 'crop with conditional StretchType.' : 'crop with fixed stretch', 'Stretch factors are:', stretchFactors ); @@ -343,7 +343,7 @@ class Resizer { const relativeX = (event.pageX - player.offsetLeft) / player.offsetWidth; const relativeY = (event.pageY - player.offsetTop) / player.offsetHeight; - + this.logger.log('info', 'mousemove', "[Resizer::panHandler] mousemove.pageX, pageY:", event.pageX, event.pageY, "\nrelativeX/Y:", relativeX, relativeY) this.setPan(relativeX, relativeY); @@ -356,7 +356,7 @@ class Resizer { } setPan(relativeMousePosX, relativeMousePosY){ - // relativeMousePos[X|Y] - on scale from 0 to 1, how close is the mouse to player edges. + // relativeMousePos[X|Y] - on scale from 0 to 1, how close is the mouse to player edges. // use these values: top, left: 0, bottom, right: 1 if(! this.pan){ this.pan = {x: 0, y: 0}; @@ -379,7 +379,7 @@ class Resizer { restore() { this.logger.log('info', 'debug', "[Resizer::restore] attempting to restore aspect ratio", {'lastAr': this.lastAr} ); - + // this is true until we verify that css has actually been applied if(this.lastAr.type === AspectRatioType.Initial){ this.setAr({type: AspectRatioType.Reset}); @@ -414,7 +414,7 @@ class Resizer { setZoom(zoomLevel, no_announce) { this.zoom.setZoom(zoomLevel, no_announce); } - + zoomStep(step){ this.zoom.zoomStep(step); } @@ -439,23 +439,23 @@ class Resizer { /** * Returns the size of the video file _as displayed_ on the screen. * Consider the following example: - * + * * * player dimensions are 2560x1080 * *