标签:滚动 缺陷 new 设定 turn rev div resize time
function debounce(fn, delay) { var timer; return function() { var that = this; var args = arguments; clearTimeout(timer); timer = setTimeout(function() { fn.apply(that, args); }, delay); } }
function throttle(fn, interval) { var previousTime = +new Date() return function () { var that = this var args = arguments var now = +new Date() if (now - previousTime >= interval) { previousTime = now fn.apply(that, args) } } }
function throttle(fn, interval) { var previousTime = +new Date() return function () { var that = this var args = arguments var now = +new Date() if (now - previousTime >= interval) { previousTime = now fn.apply(that, args) } } }
function throttle(fn, interval) { var previousTime = +new Date() return function () { var that = this var args = arguments var now = +new Date() if (now - previousTime >= interval) { previousTime = now fn.apply(that, args) } } }
原文地址: 节流和防抖的实现
标签:滚动 缺陷 new 设定 turn rev div resize time
原文地址:https://www.cnblogs.com/chengbo-x/p/9796931.html