Steady.js事件处理工具
Steady.js 可实现无闪烁的 onscroll
事件处理,而不会有性能方面的损失。
基本使用方法:
<!DOCTYPE html> <html> <head> <title>Hello world!</title> </head> <body> <!-- some HTML things here --> <script type="text/javascript" src="Steady.js"></script> <script> var s = new Steady({ conditions: { "width": 400px, "scrollX": 0, "max-bottom": 200px }, throttle: 100, handler: fn }); // you cann conditions on the fly! s.addCondition('scrollX', 0); function fn(values, done) { var xhr = new XMLHttpRequest(); xhr.open('GET', 'imgs.html'); xhr.onreadystatechange = function() { if ( xhr.readyState == 4 ) { document.body.innerHTML += xhr.response; // telling Steady that we're done processing! done(); } }; xhr.send(); } </script> </body> </html>
评论