further reduce overhead

This commit is contained in:
MathMan05
2024-07-31 23:13:02 -05:00
parent 08d25f5082
commit ac4094394c
2 changed files with 85 additions and 71 deletions

View File

@@ -908,7 +908,9 @@ class Channel {
} }
Channel.setupcontextmenu(); Channel.setupcontextmenu();
export { Channel }; export { Channel };
function fixsvgtheme() { {
let last;
function fixsvgtheme() {
const things = document.getElementsByClassName("svgtheme"); const things = document.getElementsByClassName("svgtheme");
//console.log(things); //console.log(things);
if (things.length) { if (things.length) {
@@ -946,9 +948,14 @@ function fixsvgtheme() {
const rot = Math.floor(h * 60) + "deg"; const rot = Math.floor(h * 60) + "deg";
const invert = .5 - (s / 2) + ""; const invert = .5 - (s / 2) + "";
const brightness = Math.floor((l * 200)) + "%"; const brightness = Math.floor((l * 200)) + "%";
const current = rot + invert + brightness;
if (current !== last) {
last = current;
document.documentElement.style.setProperty('--rot', rot); document.documentElement.style.setProperty('--rot', rot);
document.documentElement.style.setProperty('--invert', invert); document.documentElement.style.setProperty('--invert', invert);
document.documentElement.style.setProperty('--brightness', brightness); document.documentElement.style.setProperty('--brightness', brightness);
} }
}
}
setInterval(fixsvgtheme, 100);
} }
setInterval(fixsvgtheme, 100);

View File

@@ -899,7 +899,9 @@ class Channel{
} }
Channel.setupcontextmenu(); Channel.setupcontextmenu();
export {Channel}; export {Channel};
function fixsvgtheme(){ {
let last:string;
function fixsvgtheme(){
const things=document.getElementsByClassName("svgtheme"); const things=document.getElementsByClassName("svgtheme");
//console.log(things); //console.log(things);
if(things.length){ if(things.length){
@@ -934,9 +936,14 @@ function fixsvgtheme(){
const rot=Math.floor(h*60)+"deg"; const rot=Math.floor(h*60)+"deg";
const invert=.5-(s/2)+""; const invert=.5-(s/2)+"";
const brightness=Math.floor((l*200))+"%"; const brightness=Math.floor((l*200))+"%";
const current=rot+invert+brightness;
if(current!==last){
last=current;
document.documentElement.style.setProperty('--rot', rot); document.documentElement.style.setProperty('--rot', rot);
document.documentElement.style.setProperty('--invert', invert); document.documentElement.style.setProperty('--invert', invert);
document.documentElement.style.setProperty('--brightness', brightness); document.documentElement.style.setProperty('--brightness', brightness);
} }
}
}
setInterval(fixsvgtheme,100);
} }
setInterval(fixsvgtheme,100);