-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdevice-orientation.html
68 lines (57 loc) · 1.81 KB
/
device-orientation.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html lang="en">
<head>
<title>Device orientation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;700&display=swap" rel="stylesheet">
<link rel="shortcut icon" type="image/png" href="logo.png"/>
<link rel="stylesheet" href="examples.css">
<script src="suica.js"></script>
<style>
suica {
position: relative;
}
div {
width: calc( 100% - 1em );
position: absolute;
padding: 0.5em;
border-bottom: 1px gray dotted;
}
</style>
</head>
<body>
<h1>Device orientation</h1>
<p>Retrieving mobile device orientation.</p>
<suica ontime="tick">
<div>
time=<span id="time">undefined</span>
<hr>
ori=<span id="ori">undefined</span>
<br>
acc=<span id="acc">undefined</span>
<br>
vel=<span id="vel">undefined</span>
<br>
pos=<span id="pos">undefined</span>
<hr>
<span id="info">undefined</span>
</div>
</suica>
<script>
function tick( t )
{
element('time').innerHTML = t.toFixed(1);
if( typeof device != 'undefined' )
{
element('ori').innerHTML = device.relativeOrientation.alpha+', '+device.relativeOrientation.beta+', '+device.relativeOrientation.gamma;
element('acc').innerHTML = device.relativeAcceleration.x+' '+device.relativeAcceleration.y+' '+device.relativeAcceleration.z;
element('vel').innerHTML = device.relativeVelocity.x+' '+device.relativeVelocity.y+' '+device.relativeVelocity.z;
element('pos').innerHTML = device.relativePosition.x+' '+device.relativePosition.y+' '+device.relativePosition.z;
}
}
</script>
</body>
</html>