I am trying to achieve this background effect, which changes the similar backgrounds and the result is glitchy, old TV like effect, which can be seen on this page.
In css file I have: noise-bck--1
,noise-bck--2
,noise-bck--3
which have different backgrounds, and in JavaScript I tried to loop over them with setInterval
but something is wrong.
The images from the effect are available on these links, please download them:
Here is my snippet:
(function() {
var frontBck = document.querySelector('.noise-bck');
var count = 0;
var i;
i = setInterval(update, 100);
function update() {
frontBck.classList.remove('noise-bck--1');
frontBck.classList.remove('noise-bck--2');
frontBck.classList.remove('noise-bck--3');
count++;
frontBck.classList.add('noise-bck--' + count);
if (count == 4) {
count = 1;
}
}
}());
body {
margin: 0;
padding: 0;
font-size: 100%;
}
.noise-bck {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.noise-bck--1 {
background-image: url('bg1.png');
}
.noise-bck--2 {
background-image: url('bg2.png');
}
.noise-bck--3 {
background-image: url('bg3.png');
}
<div class="noise-bck"></div>