向requestAnimationFrame的回调函数中传递参数

其实跟setTimeout类似,我们知道传参传的是一个函数,那么我们是不是可以用一个匿名函数来包裹这个函数的执行呢
function fn(fc){ console.log('fc:',fc) fc++; setTimeout(function(){ fn(fc) },1000) }

实例:
BallAnimate.prototype = {
  initialize: function() {
            var self = this;
            self.moveBalls(self);
        },
 
  moveBalls: function(self) {
            animateBall();
            function animateBall() {
       console.log('13');
       window.requestAnimationFrame(animateBall);
  }
}
 
posted @ 2017-04-06 14:41  善未易明  阅读(2507)  评论(0编辑  收藏  举报