-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
39 lines (34 loc) · 1.01 KB
/
main.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
const scrollUpBtn = document.getElementById("scrollToTop");
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};
function onScroll() {
if (window.scrollY > 235) {
scrollUpBtn.classList.remove("hidden");
} else {
scrollUpBtn.classList.add("hidden");
}
};
window.addEventListener("scroll", debounce(onScroll, 250));
document.getElementById('copyBtn').addEventListener('click', () => {
const copyText = document.getElementById('email');
const copySuccess = document.getElementById('copySuccess');
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand('copy');
copySuccess.classList.remove('hidden')
setTimeout(() => {
copySuccess.classList.add('hidden')
}, 2000);
})