瀏覽代碼

Tweak background filters

Thomas Dy 6 年之前
父節點
當前提交
c86b0d2d31
共有 2 個文件被更改,包括 5 次插入5 次删除
  1. 4 0
      dist/style.css
  2. 1 5
      src/background.ts

+ 4 - 0
dist/style.css

@@ -29,6 +29,10 @@
   background-size: cover;
 }
 
+#background div.image {
+  filter: brightness(70%) contrast(70%);
+}
+
 #background div.show {
   opacity: 1;
 }

+ 1 - 5
src/background.ts

@@ -1,7 +1,6 @@
 namespace background {
   export class BackgroundManager {
     element: HTMLElement;
-    filter: HTMLElement;
     last: HTMLElement | null;
     next: HTMLElement;
     fnContext: util.FnContext = new util.FnContext();
@@ -9,10 +8,7 @@ namespace background {
     constructor(element: HTMLElement) {
       this.element = element;
       this.last = null;
-      this.filter = document.createElement('div');
-      this.filter.className = 'filter';
       this.next = document.createElement('div');
-      this.element.appendChild(this.filter);
       this.element.appendChild(this.next);
     }
 
@@ -27,7 +23,7 @@ namespace background {
       if (background.indexOf('.') >= 0) {
         this.next.style.backgroundImage = `url(${background})`;
         this.next.style.backgroundColor = 'black';
-        this.next.style.filter = 'contrast(70%) brightness(70%)';
+        this.next.classList.add('image');
       } else {
         this.next.style.backgroundColor = background;
       }