Created
June 4, 2014 22:53
-
-
Save alexmcpherson/e53815f9c455b3891cba to your computer and use it in GitHub Desktop.
Scrolling speed effect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var last = 0 | |
var offsets = [] | |
$('#content').css('transition', 'all .1s') | |
$(window).scroll(function(){ | |
offsets.push(Math.abs(window.scrollY - last)) | |
last = window.scrollY | |
}) | |
setInterval(function() { | |
var total = 0 | |
for (var i = 0, len = offsets.length; i < len; i++) { | |
total += offsets[i] | |
} | |
console.log(total) | |
offsets = [] | |
$('#content').width(980 / (1 + total / 500)) | |
}, 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment