diff --git a/js/lib/Comms.js b/js/lib/Comms.js index a586de3..8d737d7 100644 --- a/js/lib/Comms.js +++ b/js/lib/Comms.js @@ -63,8 +63,8 @@ class CommsClient { if (message.cmd === "set-ar") { this.pageInfo.setAr(message.ratio); - } else if (message.cmd === 'set-video-float') { - this.pageInfo.setVideoFloat(message.newFloat); + } else if (message.cmd === 'set-alignment') { + this.pageInfo.setVideoFloat(message.mode); this.pageInfo.restoreAr(); } else if (message.cmd === "set-stretch") { this.pageInfo.setStretchMode(StretchMode[message.mode]); @@ -276,7 +276,7 @@ class CommsServer { } else if (message.cmd === 'set-custom-ar') { this.settings.active.keyboard.shortcuts.q.arg = message.ratio; this.settings.save(); - } else if (message.cmd === 'set-video-float') { + } else if (message.cmd === 'set-alignment') { this.sendToActive(message); } else if (message.cmd === 'autoar-start') { this.sendToActive(message); diff --git a/js/lib/VideoData.js b/js/lib/VideoData.js index 698c217..0fc38f9 100644 --- a/js/lib/VideoData.js +++ b/js/lib/VideoData.js @@ -123,6 +123,10 @@ class VideoData { this.resizer.setPanMode(mode); } + setVideoFloat(videoFloat) { + this.resizer.setVideoFloat(videoFloat); + } + restoreAr(){ this.resizer.restore(); } diff --git a/js/modules/ArDetect.js b/js/modules/ArDetect.js index 4f86794..aad1182 100644 --- a/js/modules/ArDetect.js +++ b/js/modules/ArDetect.js @@ -476,13 +476,14 @@ class ArDetector { var newCanvasWidth = window.innerHeight * (this.video.videoWidth / this.video.videoHeight); var newCanvasHeight = window.innerHeight; - if(this.resizer.videFloat === "center") + if (this.conf.resizer.videoFloat === "center") { this.canvasDrawWindowHOffset = Math.round((window.innerWidth - newCanvasWidth) * 0.5); - else if(this.resizer.videFloat == "left") + } else if (this.conf.resizer.videoFloat == "left") { this.canvasDrawWindowHOffset = 0; - else + } else { this.canvasDrawWindowHOffset = window.innerWidth - newCanvasWidth; - + } + this.setup(newCanvasWidth, newCanvasHeight); return; diff --git a/js/modules/PageInfo.js b/js/modules/PageInfo.js index 9f1a788..f42116b 100644 --- a/js/modules/PageInfo.js +++ b/js/modules/PageInfo.js @@ -235,6 +235,12 @@ class PageInfo { } } + setVideoFloat(videoFloat) { + for(var vd of this.videos) { + vd.setVideoFloat(videoFloat) + } + } + setPanMode(mode) { for(var vd of this.videos) { vd.setPanMode(mode); diff --git a/js/modules/Resizer.js b/js/modules/Resizer.js index b27b720..7cb2013 100644 --- a/js/modules/Resizer.js +++ b/js/modules/Resizer.js @@ -180,6 +180,11 @@ class Resizer { this.restore(); } + setVideoFloat(videoFloat) { + this.videoFloat = videoFloat; + this.restore(); + } + startCssWatcher(){ if (this.destroyed) { return; diff --git a/res/popup/js/popup.js b/res/popup/js/popup.js index becdc8b..d529993 100644 --- a/res/popup/js/popup.js +++ b/res/popup/js/popup.js @@ -738,11 +738,11 @@ document.addEventListener("click", (e) => { if (e.target.classList.contains("_align")) { command.cmd = "set-alignment"; - if (e.target.classList.contains("_align_left")) { + if (e.target.classList.contains("_align_video_left")) { command.mode = 'left'; - } else if (e.target.classList.contains("_align_center")) { + } else if (e.target.classList.contains("_align_video_center")) { command.mode = 'center'; - } else if (e.target.classList.contains("_align_right")) { + } else if (e.target.classList.contains("_align_video_right")) { command.mode = 'right'; } @@ -767,7 +767,7 @@ document.addEventListener("click", (e) => { VideoPanel.inputs.zoomSlider.value = 0; // logâ‚‚(1) command.cmd = 'set-zoom'; command.zoom = 1; - return; + return command; } //#endregion //#region show/hide custom ar