Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
61 lines (54 loc) · 1.37 KB
/
Copy pathscript.js
File metadata and controls
61 lines (54 loc) · 1.37 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
function runCounter(id, max){
let c=0;const el=document.getElementById(id);
const i=setInterval(()=>{
c+=Math.ceil(max/60);
if(c>=max){el.textContent=max;clearInterval(i);}
else el.textContent=c;
},30);
}
runCounter("forms",1200)
runCounter("users",600)
runCounter("emails",9800)
function copyCode(){
const code = document.getElementById("codeBox").innerText;
navigator.clipboard.writeText(code)
alert("Code copied ✅")
}
function scrollToSection(id){
document.getElementById(id).scrollIntoView({behavior:"smooth"})
}
// particles
const canvas=document.createElement("canvas")
canvas.style.position="fixed"
canvas.style.inset="0"
canvas.style.zIndex="-1"
document.body.appendChild(canvas)
const ctx=canvas.getContext("2d")
function resize(){
canvas.width=innerWidth
canvas.height=innerHeight
}
resize()
window.addEventListener("resize",resize)
const dots=new Array(80).fill().map(()=>({
x:Math.random()*innerWidth,
y:Math.random()*innerHeight,
r:Math.random()*2+1,
dx:Math.random()-.5,
dy:Math.random()-.5
}))
function animate(){
ctx.clearRect(0,0,canvas.width,canvas.height)
ctx.fillStyle="#00ffe1"
dots.forEach(d=>{
d.x+=d.dx
d.y+=d.dy
if(d.x<0||d.x>innerWidth)d.dx*=-1
if(d.y<0||d.y>innerHeight)d.dy*=-1
ctx.beginPath()
ctx.arc(d.x,d.y,d.r,0,Math.PI*2)
ctx.fill()
})
requestAnimationFrame(animate)
}
animate()