首页 > 其他 > 详细

函数节流

时间:2016-07-05 20:49:24      阅读:168      评论:0      收藏:0      [点我收藏+]
// (来自)JavaScript高级程序设计 不支持匿名函数
function throttle(fn, context) {
    clearTimeout(fn.tId);
    fn.tId = setTimeout(function () {
        fn.call(context);
    }, 100);
}
// (来自)百度 不支持匿名函数
function throttle(fn) {
    var args, that, timer = null;
    return function () {
        clearTimeout(timer);
        args = arguments;
        that = this;
        timer = setTimeout(function () {
            fn.call(that, args);
        }, 100);
    };
}

 

函数节流

原文:http://www.cnblogs.com/shanchenba/p/5644862.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!