> RequestAnimationFrame powered iScroll v4.1
Please allow me a quick digression before adventuring into the iScroll news. It came to my attention that iscroll.js has been included into a couple of big projects without the copyright notice. The script is MIT licensed, the most liberal license out there. You can use, alter, distribute, sell the code free of charge without restrictions. All I ask is to place buried (but accessible) somewhere the copyright/permission notice.
You can place it into the script itself, you can place it in an about/bibliography/credits page, you can even just link to it, but you are required to show it somewhere. If you can’t directly include it into the application a quick mention in your dev blog might do the trick. I’m open minded, be creative.
If for any reason you absolutely need to remove the notice, please contact me and let me know why you need to strip it out. I’m sure we can find an arrangement (no, that doesn’t involve money).
Don’t believe my words? Believe your eyes, in the source code they include an old version of iScroll (so Apple seems to care about copyright only when they are the copyright holders).
The copyright notice is *not* to pump my ego. Showing the open source license lets people know that they can re-use the script freely.
Now, back to business. iScroll 4.1.
requestAnimationFrame is a relatively new function available in some modern browsers that should guarantee a smooth animation. Basically, as soon as the first frame has been drawn you ask the hardware to paint the next one, you are not forcing the device to animate at a speed that it can’t handle. You may argue that webkit doesn’t support requestAnimationFrame, but fear not, iScroll gracefully degrades to less fortunate browsers. Hopefully Apple will support it in future releases.
This new technique also gives us back the shrinking scrollbars (scrollbars resize when dragging over the boundaries) and a slightly better performance on Android (transitionEnd seems a bit dodgy on the google phone).
Zoom has also changed. I’m not using gesture events anymore but I’m tracking each finger from within touch events. Fingers tracking (believe it or not) is easier to handle than gestures, the code is more compact, touches do not overlap with gestures, and everyone’s happier.
v4.1 also introduces a wider browsers compatibility. Firefox, Opera, Chrome and Safari are almost 100% supported. IE9 will be the next step. The code needed to achieve desktop compatibility does not impact mobile performance, so there’s no reason not to include it.
There are still some glitches here and there (especially in the zoom), but the core should be rather future proof, so let the forks and pull requests begin. In this regard, I wanted to thank once again all those who submitted bug reports and suggestions. I was working on this new version (that if you look at the diff is almost a complete rewrite) and I wasn’t able to directly merge your code, but I took inspiration from all your submissions!
In the coming days I’ll update the documentation to match the new features. In the meantime if you are using “pull to refresh” do not update! The functionality has been removed from the core and will be soon reintegrated as a plugin. For all the others… go get it or look at the demo.