0.0.2
This commit is contained in:
parent
912cbac798
commit
0c803bf677
10
src/CRT.ts
10
src/CRT.ts
|
@ -48,7 +48,7 @@ export class CRT implements IEffect {
|
||||||
#${this.wrapperId} {
|
#${this.wrapperId} {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
#${this.containerId}::before {
|
#${this.wrapperId} > #${this.containerId}::before {
|
||||||
content: " ";
|
content: " ";
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -70,7 +70,7 @@ export class CRT implements IEffect {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
${this.makeFlickerFrames()}
|
${this.makeFlickerFrames()}
|
||||||
#${this.containerId}::after {
|
#${this.wrapperId} > #${this.containerId}::after {
|
||||||
content: " ";
|
content: " ";
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -85,7 +85,7 @@ export class CRT implements IEffect {
|
||||||
animation: flicker_${this.styleId} 0.15s infinite;
|
animation: flicker_${this.styleId} 0.15s infinite;
|
||||||
}
|
}
|
||||||
${this.makeSeparationFrames()}
|
${this.makeSeparationFrames()}
|
||||||
#${this.containerId} {
|
#${this.wrapperId} > #${this.containerId} {
|
||||||
animation: separation_${this.styleId} 1.6s infinite;
|
animation: separation_${this.styleId} 1.6s infinite;
|
||||||
}
|
}
|
||||||
`).appendTo($('body'));
|
`).appendTo($('body'));
|
||||||
|
@ -111,10 +111,14 @@ export class CRT implements IEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
public execute(): void {
|
public execute(): void {
|
||||||
|
if(!$(`#${this.wrapperId}`).length) {
|
||||||
$(`#${this.containerId}`).wrap($('<div />').attr('id', this.wrapperId));
|
$(`#${this.containerId}`).wrap($('<div />').attr('id', this.wrapperId));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public stop(): void {
|
public stop(): void {
|
||||||
|
if($(`#${this.wrapperId}`).length) {
|
||||||
$(`#${this.containerId}`).unwrap(`#${this.wrapperId}`);
|
$(`#${this.containerId}`).unwrap(`#${this.wrapperId}`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang='en'>
|
||||||
|
<head>
|
||||||
|
<title>CRT Test</title>
|
||||||
|
<meta charset='utf-8'>
|
||||||
|
<script src='../build/spooky.min.js'></script>
|
||||||
|
<script>
|
||||||
|
var crt;
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
crt = new Spooky.CRT({
|
||||||
|
containerId: 'crt',
|
||||||
|
screenDoorColor: '#040',
|
||||||
|
screenDoorSize: 4,
|
||||||
|
screenDoorOpacity: 0.5,
|
||||||
|
separationColor: '#ff0',
|
||||||
|
separationBlur: 3,
|
||||||
|
separationDistance: 8,
|
||||||
|
separationOpacity: 0.25
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
#crt {
|
||||||
|
padding: 2em;
|
||||||
|
background-color: #020;
|
||||||
|
color: #0f0;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 3em;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id='crt'>
|
||||||
|
This is an old CRT monitor.
|
||||||
|
</div>
|
||||||
|
<button onclick='crt.execute()'>Start</button>
|
||||||
|
<button onclick='crt.stop()'>Stop</button>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue