-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
76 lines (55 loc) · 1.71 KB
/
index.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class Ball{
constructor(body){
this.body=document.querySelector("body")
}
createDot(){
let ball=document.createElement("img")
ball.src="heart.svg"
ball.className="ball"
this.body.appendChild(ball)
}
moveball(){
setTimeout(()=>{
let allball=document.querySelectorAll(".ball")
allball.forEach((ball)=>{
ball.className="moveball"
ball.style.transition="2s"
ball.style.height="20px"
ball.style.width="20px"
ball.style.borderRadius="100%"
ball.style.margin="50px"
ball.style.position="absolute"
let left = Math.random() * 1000;
ball.style.marginLeft=`${left}px`
let top=Math.random() * 1000
ball.style.marginTop=`${top}px`
})
},1000)
}
dialogue(){
let button=document.querySelector(".button")
button.onclick=()=>{
console.log("clicked")
let box=document.querySelector(".box")
box.style.display="inline"
}
}
}
ballmethod=new Ball()
ballmethod.createDot()
ballmethod.moveball()
ballmethod.dialogue()
setInterval(()=>{
ballmethod.createDot()
ballmethod.moveball()
},50)
setInterval(()=>{
let balls=document.querySelectorAll(".moveball")
balls.forEach((ball)=>{
ball.style.backgroundColor="white"
})
},3000)
setTimeout(()=>{
let blind=document.querySelector(".blindfold")
blind.style.width="0px"
},1000)