/*
Onscroll
OnResize
Input
。。。。。
Throttle function
Let high-frequency events reduce triggers into low-frequency events
var bstop = true;
Window.onscroll = function () {
if (!bstop) {
Return
}
Bstop = false;
SetTimeout (() =>{
var t = Document.documentElement.scrollTop | | Document.body.scrollTop;
Console.log (t);
Bstop = true;
},300)
}
function stabilization
When high frequency events are triggered, we do not need to know the process of frequent triggering, just need to know the final result
*/
var timer = null;
Window.onscroll = function () {
if (timer) {
Cleartimeout (timer);
}
Timer = SetTimeout (() =>{
var t = Document.documentElement.scrollTop | | Document.body.scrollTop;
Console.log (t);
},300)
}
</script>
/*
Lazy functions and the function of curry
*/
function GetStyle (obj,attr) {
if (Obj.currentstyle) {
return obj.currentstyle[attr]
}else{
Return getComputedStyle (Obj,false) [attr];
}
}
function GetStyle (obj,attr) {
if (Obj.currentstyle) {
GetStyle = function (obj,attr) {
return obj.currentstyle[attr];
}
}else{
GetStyle = function (obj,attr) {
Return getComputedStyle (Obj,false) [attr];
}
}
Return GetStyle (OBJ,ATTR);
}
Throttling function & Anti-shake function curry function