From 0c1cae3215e2e1c622ead6ab15f790740023f31e Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sat, 27 Jan 2018 20:27:11 +0100 Subject: [PATCH] "Fit to width" and "fit to height" now calculate video fit according to player size, not screen size. --- js/modules/Resizer.js | 10 +++++++++- js/uw.js | 9 ++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/js/modules/Resizer.js b/js/modules/Resizer.js index eb902b9..2a223c7 100644 --- a/js/modules/Resizer.js +++ b/js/modules/Resizer.js @@ -182,7 +182,15 @@ var _res_reset = function(force){ // handles "legacy" options, such as 'fit to widht', 'fit to height' and 'reset'. No zoom tho var _res_legacyAr = function(action){ var vid = GlobalVars.video; - var ar = screen.width / screen.height; + var ar; + + if(GlobalVars.playerDimensions === null || GlobalVars.playerDimensions === undefined){ + ar = screen.width / screen.height; + } + else{ + ar = GlobalVars.playerDimensions.width / GlobalVars.playerDimensions.height; + } + var fileAr = vid.videoWidth / vid.videoHeight; if(action == "fitw"){ diff --git a/js/uw.js b/js/uw.js index ef06a44..bbb8b6c 100644 --- a/js/uw.js +++ b/js/uw.js @@ -101,12 +101,7 @@ function ghettoOnChange(){ var video = document.getElementsByTagName("video")[0]; if(video !== undefined){ GlobalVars.video = video; - -// try{ - Comms.sendToBackgroundScript({"cmd":"register-video"}); -// } -// catch(chromeIsShitError){ - // cos firefox won't crap its bed if a promise comes back unfulfilled + Comms.sendToBackgroundScript({"cmd":"register-video"}); } } } @@ -123,7 +118,7 @@ function ghettoOnChange(){ if (newPlayerDims == undefined) return; - GlobalVars.playerDimeimensions = newPlayerDims; + GlobalVars.playerDimensions = newPlayerDims; if ( newPlayerDims.width != _player_dimensions_last.width || newPlayerDims.height != _player_dimensions_last.height){