-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.js
39 lines (35 loc) · 928 Bytes
/
util.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
export function _$(selector, all, target = document) {
return all ? target.querySelectorAll(selector) : target.querySelector(selector);
}
export function _$c(target) {
return {
add(className) {
target.classList.add(className);
},
remove(className) {
target.classList.remove(className);
}
}
}
export function __$(target) {
return {
on(event, func) {
target.addEventListener(event, func);
},
show(className = 'on-block') {
target.classList.add(className);
},
hide(className = 'on-block') {
target.classList.remove(className);
}
}
}
export const _$e = {
timer: null,
debounce(delayTime, funcThis, func) {
if (this.timer) clearTimeout(this.timer);
this.timer = setTimeout(() => {
func.call(funcThis);
}, delayTime);
}
}