From 0c803bf6775ab239bb9533cb5dc916c5cad4dcd2 Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Sun, 14 Jun 2020 14:25:44 -0500 Subject: [PATCH] 0.0.2 --- src/CRT.ts | 14 +++++++++----- test/CRT.html | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 test/CRT.html diff --git a/src/CRT.ts b/src/CRT.ts index 6a1572e..6060041 100644 --- a/src/CRT.ts +++ b/src/CRT.ts @@ -48,7 +48,7 @@ export class CRT implements IEffect { #${this.wrapperId} { position: relative; } - #${this.containerId}::before { + #${this.wrapperId} > #${this.containerId}::before { content: " "; display: block; position: absolute; @@ -70,7 +70,7 @@ export class CRT implements IEffect { pointer-events: none; } ${this.makeFlickerFrames()} - #${this.containerId}::after { + #${this.wrapperId} > #${this.containerId}::after { content: " "; display: block; position: absolute; @@ -85,7 +85,7 @@ export class CRT implements IEffect { animation: flicker_${this.styleId} 0.15s infinite; } ${this.makeSeparationFrames()} - #${this.containerId} { + #${this.wrapperId} > #${this.containerId} { animation: separation_${this.styleId} 1.6s infinite; } `).appendTo($('body')); @@ -111,10 +111,14 @@ export class CRT implements IEffect { } public execute(): void { - $(`#${this.containerId}`).wrap($('
').attr('id', this.wrapperId)); + if(!$(`#${this.wrapperId}`).length) { + $(`#${this.containerId}`).wrap($('
').attr('id', this.wrapperId)); + } } public stop(): void { - $(`#${this.containerId}`).unwrap(`#${this.wrapperId}`); + if($(`#${this.wrapperId}`).length) { + $(`#${this.containerId}`).unwrap(`#${this.wrapperId}`); + } } } diff --git a/test/CRT.html b/test/CRT.html new file mode 100644 index 0000000..b73d013 --- /dev/null +++ b/test/CRT.html @@ -0,0 +1,39 @@ + + + + CRT Test + + + + + + +
+ This is an old CRT monitor. +
+ + + +