start grid
This commit is contained in:
@ -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
|
||||
}
|
Reference in New Issue
Block a user