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 class="a"></div>
  
  <div class="b"></div>
  
</body>
</html>
 
.a {
  position: fixed;
  width: 50px;
  height: 50px;
  background: red;
  top: 50px;
}
.b {
  margin-top: 30vh;
  width: 50px;
  height: 50px;
  background: blue;
}
body {
  height: 100vh;
}
 
window.addEventListener('scroll', function () {
  console.log('win y:' + window.scrollY);
var b = document.querySelector('.b').getBoundingClientRect();
console.log(b);
/*
console.log('(b.top+b.height)', (b.top+b.height));
  console.log('window.scrollY - 50', window.scrollY - 50)
*/
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers