feat(settings): add a new option to disable invert filter

This commit is contained in:
Haoyu Xu
2021-08-03 16:51:33 -04:00
parent ec1eb17691
commit 8c955a603a
3 changed files with 11 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ var Settings = (function () {
this.opacity = parseFloat(getComputedStyle(this.logoEl).opacity) * 100; this.opacity = parseFloat(getComputedStyle(this.logoEl).opacity) * 100;
this.el = document.createElement("div"); this.el = document.createElement("div");
this.spinePlayerLoaded = false; this.spinePlayerLoaded = false;
this.invertFilter = true;
} }
Settings.prototype.validateConfig = function () { Settings.prototype.validateConfig = function () {
if (typeof this.logoEl === "string") if (typeof this.logoEl === "string")
@@ -46,6 +47,7 @@ var Settings = (function () {
Settings.prototype.setLogo = function (url, removeInvert) { Settings.prototype.setLogo = function (url, removeInvert) {
this.logoEl.src = url; this.logoEl.src = url;
this.resizeLogo(this.ratio); this.resizeLogo(this.ratio);
if (!this.invertFilter) return;
if (removeInvert) { if (removeInvert) {
this.logoEl.style.filter = "invert(0)"; this.logoEl.style.filter = "invert(0)";
} else { } else {
@@ -63,6 +65,10 @@ var Settings = (function () {
var opacity = parseFloat(value); var opacity = parseFloat(value);
this.logoEl.style.opacity = opacity / 100; this.logoEl.style.opacity = opacity / 100;
}; };
Settings.prototype.disableInvertFilter = function (el) {
this.logoEl.style.filter = "invert(0)";
this.invertFilter = false;
};
Settings.prototype.positionReset = function () { Settings.prototype.positionReset = function () {
if (this.spinePlayerLoaded) if (this.spinePlayerLoaded)
this.spinePlayer.updateViewport(window.operatorSettings.viewport) this.spinePlayer.updateViewport(window.operatorSettings.viewport)

View File

@@ -24,9 +24,12 @@ body {
position: fixed; position: fixed;
left: 0; left: 0;
top: 0; top: 0;
z-index: -1;
}
.invert-filter {
filter: invert(1); filter: invert(1);
opacity: 0.3; opacity: 0.3;
z-index: -1;
} }
.widget-wrapper { .widget-wrapper {

View File

@@ -13,7 +13,7 @@
<body> <body>
<div id="dev" style="position: fixed;left: 0;top: 0;background-color: white;"></div> <div id="dev" style="position: fixed;left: 0;top: 0;background-color: white;"></div>
<image src="./operator/{operator_logo}.png" class="logo" id="logo" alt="operator logo" /> <image src="./operator/{operator_logo}.png" class="logo invert-filter" id="logo" alt="operator logo" />
<div id="widget-wrapper" style="width: 100%; height: 100%;"> <div id="widget-wrapper" style="width: 100%; height: 100%;">
<div id="container" style="width: 100%; height: 100%;"></div> <div id="container" style="width: 100%; height: 100%;"></div>
</div> </div>