From 61d43c17a6d73f1c380fa70633abde49b88b5e6d Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 5 Feb 2021 16:17:02 +0100 Subject: added controls --- largePiPEnergy.plugin.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/largePiPEnergy.plugin.js b/largePiPEnergy.plugin.js index ae07cf2..de4bc52 100644 --- a/largePiPEnergy.plugin.js +++ b/largePiPEnergy.plugin.js @@ -10,6 +10,9 @@ module.exports = class largePiPEnergy { constructor() { this.size = 320; + this.resizeStep = 0.3; + this.resizeTransitionSpeed = 300; + this.aspectRatio = [16, 9]; } start() { @@ -20,23 +23,23 @@ module.exports = class largePiPEnergy { ".da-pictureInPicture .da-pictureInPictureVideo {", ` width: calc(var(--largePiPEnergySize) * 1px);`, " height: unset;", - " padding-bottom: 56.25%;", - " transition: width .3s;", + ` padding-bottom: calc(${this.aspectRatio[1]} / ${this.aspectRatio[0]} * 100%);`, + ` transition: width ${this.resizeTransitionSpeed}ms;`, "}" - ].join("\n")) + ].join("\n")); setInterval(() => { var element = document.getElementsByClassName("da-pictureInPictureWindow")[0]; if (!element) return; element.onmousewheel = event => { - this.size -= event.deltaY / 3; - document.documentElement.style.setProperty("--largePiPEnergySize", `${this.size}`) - console.log(event.deltaY) + this.size -= event.deltaY * this.resizeStep; + document.documentElement.style.setProperty("--largePiPEnergySize", `${this.size}`); + console.log(event.deltaY); } }, 1e3); // this is a crappy solution but i'll fix this tomorrow or something } stop() { - BdApi.clearCSS("largePiPEnergy") + BdApi.clearCSS("largePiPEnergy"); } } -- cgit v1.2.3