hakimel/stroll.js — pull request #18 by bastimeyer (2012-07-06 15:27:09+00:00)
Title: Fast scrolling bug + scroll events rather than reqAnimFrame

Hello!
I really like your project, it has some pretty nice effects. Its just awesome!

While playing around at the demopage I noticed some issues with scrolling up and down very fast. In some cases a few items inside the viewport still animate or just disappear because they still have classnames applied.
So I had a look at the code and I also noticed that you are using requestAnimationFrame to change the classList on every child node. The problem here is that the update function will be called over and over again even though the user is not scrolling.

I fixed the fast-scrolling-bug by adding a locking variable to the update function and I also fixed some tiny performance issues here and there.
The big change I made was to use scroll events instead of using requestAnimationFrame so the update function will now only be called while the user is scrolling. Because of that I also had to change the TouchList and its swipe behavior. The swipe machanism still uses reqAnimFrame but only to reduce the velocity of the swipe...

Overall I've managed to storten the code (TouchList now uses List's sync() and update() method).

Please have a look at the changes and tell me what you think. Thanks!