Skip to content

Commit

Permalink
little smoother
Browse files Browse the repository at this point in the history
  • Loading branch information
Elmer Bulthuis committed Mar 18, 2015
1 parent c62110e commit 30e5098
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions public/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
window.document.addEventListener('scroll', function(e) {
//document.getElementById('train').style.transform = 'translate3d(0,' + e.target.body.scrollTop + 'px,0)';
document.getElementById('train').style.top = (e.target.body.scrollTop - 150) + 'px';
window.addEventListener('load', function() {
var trainElement = document.getElementById('train');
var animationFrame;
window.addEventListener('scroll', function(e) {
window.cancelAnimationFrame(animationFrame);
animationFrame = window.requestAnimationFrame(function() {
//document.getElementById('train').style.transform = 'translate3d(0,' + window.pageYOffset + 'px,0)';
trainElement.style.top = (window.pageYOffset - 150) + 'px';
});
});
});

0 comments on commit 30e5098

Please sign in to comment.