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>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
  <p>scroll</p>
</body>
</html>
 
p {
  margin: 50px 0;
  background: #ff0;
}
 
// Reference: http://www.html5rocks.com/en/tutorials/speed/animations/
var last_known_scroll_position = 0;
var ticking = false;
function doSomething(scroll_pos) {
  // do something with the scroll position
  console.log( scroll_pos)
}
window.addEventListener('scroll', function(e) {
  last_known_scroll_position = window.scrollY;
  if (!ticking) {
    window.requestAnimationFrame(function() {
      doSomething(last_known_scroll_position);
      ticking = false;
    });
  }
  ticking = true;
});
Output

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

Dismiss x
public
Bin info
oooooopro
0viewers