Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div id="overlay"></div>
</body>
</html>
 
#overlay {
    background-color: red;
    opacity:1;
    width:100%;
    height: 100%;
    position:absolute;
    left:0;
    top:0;
}
 
var timerId;
function fadeOut() {
  var overlay=document.getElementById("overlay");
  var style = window.getComputedStyle(overlay);
  var opacity=style.getPropertyValue("opacity");
  if(opacity>0){
    overlay.style.opacity = opacity - 0.01;
    timerId = setTimeout(fadeOut,10);
  }
}
function fadeIn() {
  var overlay=document.getElementById("overlay");
  var style = window.getComputedStyle(overlay);
  var opacity= +overlay.style.opacity;
  if (opacity<1) {
    overlay.style.opacity = opacity + 0.01;
    timerId = setTimeout(fadeIn,10);
  }
}
var fadingOut = false;
addEventListener('click', function() {
  clearTimeout(timerId);
  console.log('click');
  if (fadingOut) {
    fadeIn();
    console.log('fading in', fadingOut);
  } else {
    fadeOut();
    console.log('fading out');
  }
  fadingOut = !fadingOut;
}, false);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers