-
Notifications
You must be signed in to change notification settings - Fork 1
/
ch03r03.html
43 lines (39 loc) · 919 Bytes
/
ch03r03.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
<!DOCTYPE html>
<html>
<head>
<title>Gesture Rotation</title>
<meta charset="utf-8" name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0">
<style type="text/css">
#main {
text-align: center;
}
#someElm {
margin-top: 50px;
margin-left: 50px;
width: 200px;
height: 500px;
background: #ccc;
position: absolute;
}
</style>
</head>
<body>
<div id="main">
<div id="someElm">
</div>
</div>
<script type="text/javascript">
var rotation =0 ;
var node = document.getElementById('someElm');
node.ongesturechange = function(e){
var node = e.target;
node.style.webkitTransform = "rotate(" + e.rotation + "deg)";
node.innerHTML = e.rotation;
};
node.ongestureend = function(e){
// Update the values for the next time a gesture happens
rotation = (rotation + e.rotation) % 360;
};
</script>
</body>
</html>