1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

scroll listener using window.requestAnimationFrame

This commit is contained in:
ruanyf 2015-10-14 18:51:59 +08:00
parent 7d31f94c82
commit ba19987cdb

View File

@ -286,8 +286,10 @@ function router() {
var sHeight = h - wh; var sHeight = h - wh;
$w.on('scroll', function() { $w.on('scroll', function() {
window.requestAnimationFrame(function(){
var perc = Math.max(0, Math.min(1, $w.scrollTop() / sHeight)); var perc = Math.max(0, Math.min(1, $w.scrollTop() / sHeight));
updateProgress(perc); updateProgress(perc);
});
}); });
function updateProgress(perc) { function updateProgress(perc) {