I have a problem with a project i'm working on. I'm not in any way a JS expert so i'm sorry if this is a stupid thing to ask.
I have 2 video's that are on top of each other. when i call the function "switch" it plays a "static" fade effect and then switches the visability of both of the videos.
it all works fine, but when i click the button to call the function very fast, the "static" effect gliches out and everything starts to bug out.
here is the code that i am using. it switches the class name to hide the video.
function Switch(){
if(videoNieuw.className == "show"){
playNoise(1280, 720);
btnswitch.className="controls now";
setTimeout(function(){
videoNieuw.className="hide";
videoOud.className = "show";
}, 500);
}else if(videoOud.className = "show"){
playNoise(1280, 720);
btnswitch.className="controls then";
setTimeout(function(){
videoOud.className = "hide";
videoNieuw.className="show";
}, 500);
}
}
The setTimeout is so the "static" fade has the time to fade a little bit and make things look smoother.
is there an alternative way so i can put this up without glitching?
clearTimeout.}else if(videoOud.className = "show"){- should be==?