delay JS延迟执行

 window.onscroll = function () {
    throttle(trrigerAdd,window);
};
function trrigerAdd(){
    var $dHeight = document.documentElement.clientHeight;
    var $aHeight = document.documentElement.offsetHeight;
    var $scrolly = document.documentElement.scrollTop || document.body.scrollTop;
    if (($aHeight - $dHeight) - $scrolly <= 2) {
        orderinfor.index[orderinfor.currentState]++;
    }
}
function throttle(method,context){
    clearTimeout(method.tId);
    console.log(method.tId);
    method.tId=setTimeout(function(){
        method.call(context);
    },500);

原文地址:https://www.cnblogs.com/csniper/p/8022221.html