Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <div>Scroll down!</div>
  <div></div>
  <div></div>
  <div></div>
  <div class="target left">></div>
  <div class="target right"><</div>
  <div class="target zoom">X</div>
  <div></div>
  <div></div>
  <div></div>
  <div>Scroll up!</div>
</body>
</html>
 
let targets = document.querySelectorAll('.target');
window.addEventListener("scroll", function(){
  let doc = document.documentElement;
  let top = (window.pageYOffset || doc.scrollTop)  - (doc.clientTop || 0);
  
  let windowHeight = window.innerHeight;
  
  for (i = 0; i < targets.length; ++i) {
    let target = targets[i];
    if(target.offsetTop < (top + (windowHeight/2))) {
      target.classList.add("visible");
    }
    else {
      target.classList.remove("visible");
    }
  }
});
Output

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

Dismiss x
public
Bin info
DJAxelpro
0viewers