<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div style = "height: 2000px;width: 300px;"></div>
<script>
function debounce(fun) {
var temp = true;
return function A(){
if(temp){
temp = false;
setTimeout(function(){
fun()
temp = true;
},500);
}
}
};
var ss = debounce(function(){
console.log("b");
})
window.onscroll = function(){
ss();
}
</script>
</body>
</html>
<html>
<head>
<title></title>
</head>
<body>
<div style = "height: 2000px;width: 300px;"></div>
<script>
function debounce(fun) {
var temp = true;
return function A(){
if(temp){
temp = false;
setTimeout(function(){
fun()
temp = true;
},500);
}
}
};
var ss = debounce(function(){
console.log("b");
})
window.onscroll = function(){
ss();
}
</script>
</body>
</html>