January 6, 2013
I recently saw a post on Twitter from @chpwn that described the alogorithm that Apple uses for its “rubber band” or “bungee” scrolling.
b = (1.0 – (1.0 / ((x * c / d) + 1.0))) * d
| (function() { | |
| var defaultFrameRate = 20, // fps lock for old browsers | |
| // This is the default fallback throttle function | |
| framerateThrottle = function(callback) { | |
| return _.throttle(callback, 1 / (defaultFrameRate * 1000)); | |
| }; | |
| // Feature detection - should have requestAnimationFrame | |
| if (window.requestAnimationFrame) { | |
| framerateThrottle = function(callback) { |