From 6b91444f3cde7f1169cd0f0b230a73d495c2b85d Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Thu, 5 Nov 2020 23:12:03 +0100 Subject: [PATCH] Set, unset base class functions --- src/ext/lib/video-data/PlayerData.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/ext/lib/video-data/PlayerData.js b/src/ext/lib/video-data/PlayerData.js index 5527bc4..10dbf4e 100644 --- a/src/ext/lib/video-data/PlayerData.js +++ b/src/ext/lib/video-data/PlayerData.js @@ -73,6 +73,29 @@ class PlayerData { } + setBaseClass() { + if (!this.dimensions) { + // TODO: determine how to handle this edge case. Fallback to 'base-wide-screen' might + // be better option than doing nothing + return; + } + // note that we should never allow both narrow-screen and wide-screen classes on the video + // element at _any_ time. That may break some sites even more. + + if (this.video.videoWidth / this.videoHeight <= this.dimensions.width / this.dimensions.height) { + this.video.classList.remove('uw-ultrawidify-base-narrow-screen'); + this.video.classList.add('uw-ultrawidify-base-wide-screen'); + } else { + this.video.classList.remove('uw-ultrawidify-base-wide-screen'); + this.video.classList.add('uw-ultrawidify-base-narrow-screen'); + } + } + + unsetBaseClass() { + this.video.classList.remove('uw-ultrawidify-base-narrow-screen'); + this.video.classList.remove('uw-ultrawidify-base-wide-screen'); + } + static isFullScreen(){ return ( window.innerHeight == window.screen.height && window.innerWidth == window.screen.width); }