start grid

This commit is contained in:
2023-04-02 23:54:41 +08:00
parent 4e230ed7e7
commit c44aaf5177
8 changed files with 649 additions and 25 deletions

View File

@ -9,6 +9,28 @@ function isPositive(n) {
return !isNaN(n) && n > 0;
}
function isMobile() {
return /mobile/i.test(navigator.userAgent);
}
function throttle(method, delay = 100, context = g, ...args) {
if (method == null) {
return;
}
method.tiid && clearTimeout(method.tiid);
const current = new Date();
if (method.tdate == null || current - method.tdate > delay) {
method.apply(context, args);
method.tdate = current;
} else {
method.tiid = setTimeout(() => method.apply(context, args), delay);
}
}
function truncate(v) {
return (v > 0 ? Math.floor : Math.ceil)(v);
}
export {
// cookie
getCookie,
@ -29,5 +51,9 @@ export {
padStart,
// variables
g as global,
isPositive
isPositive,
isMobile,
// functions
throttle,
truncate
}