Skip to content

Commit 03e8854

Browse files
committed
moving transitions example
1 parent 2e86417 commit 03e8854

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

transitions/js-transitions.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width">
6+
<title>JavaScript transitions demo</title>
7+
<style>
8+
body {
9+
background-color: #fff;
10+
color: #333;
11+
font: 1.2em / 1.5 Helvetica Neue, Helvetica, Arial, sans-serif;
12+
padding: 0;
13+
margin: 0;
14+
}
15+
16+
h1 {
17+
font-size: 1.2em;
18+
}
19+
20+
main {
21+
max-width: 960px;
22+
margin: 0 auto;
23+
padding: 20px;
24+
}
25+
26+
.ball {
27+
border-radius: 25px;
28+
width: 50px;
29+
height: 50px;
30+
background: #c00;
31+
position: absolute;
32+
top: 0;
33+
left: 0;
34+
transition: transform 1s;
35+
}
36+
</style>
37+
</head>
38+
<body>
39+
<main>
40+
<h1>Click anywhere to move the ball</h1>
41+
<div id="foo" class="ball"></div>
42+
</main>
43+
44+
</body>
45+
<script>
46+
var f = document.getElementById('foo');
47+
document.addEventListener('click', function(ev){
48+
f.style.transform = 'translateY('+(ev.clientY-25)+'px)';
49+
f.style.transform += 'translateX('+(ev.clientX-25)+'px)';
50+
},false);
51+
</script>
52+
</html>

0 commit comments

Comments
 (0)