Skip to content

Instantly share code, notes, and snippets.

@alexmcpherson
Created June 4, 2014 22:53
Show Gist options
  • Save alexmcpherson/e53815f9c455b3891cba to your computer and use it in GitHub Desktop.
Save alexmcpherson/e53815f9c455b3891cba to your computer and use it in GitHub Desktop.
Scrolling speed effect
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