-
Notifications
You must be signed in to change notification settings - Fork 0
/
testrun.html
48 lines (47 loc) · 1.17 KB
/
testrun.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>testrun</title>
<style>
div{
height: 50px;
width: 50px;
}
.div1{
background-color: red;
position: absolute;
left: 100px;
top: 500px;
}
.div2{
background-color: blue;
position: absolute;
left: 100px;
animation: move 6s linear infinite;
}
@keyframes move {
from{transform: translateY(-100px);}
to{transform: translateY(1000px);}
}
</style>
</head>
<body>
<div class="div1"></div>
<div class="div2"></div>
</body>
<script>
const div1=document.querySelector(".div1");
const div2=document.querySelector(".div2");
function collide(){
const elem=document.elementFromPoint(100,500);
if(elem.className==='div2'){
console.log(elem);
div2.style.animation="none";
div2.style.transform="translateY(450px)";
}
}
setInterval(collide,100);
</script>
</html>