-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathremotepointer.html
39 lines (39 loc) · 1.2 KB
/
remotepointer.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"></mata>
<style>
html, body {
margin: 0;
width: 100%;
height: 100%;
}
#pointer{
position:absolute;
border-radius:100%;
width: 20px;
height: 20px;
background: red;
}
#msg {
position: absolute;
overflow: visible;
}
</style>
</head>
<body>
<div id="pointer"></div>
<div id="msg"></div>
<script>
window.ondeviceorientation = (evt) => {
msg.innerHTML = '<br><br><p>' + (evt.beta) + '</p><br><p>' + (evt.gamma) + '</p>';
var b = -Math.max(-90, Math.min(evt.beta, 0));
var g = Math.max(0, Math.min(evt.gamma, 50));
var a = 45 + Math.max(-45, Math.min(evt.alpha, 45));
pointer.style.left = (a / 90 * 100) + '%';
pointer.style.top = (b / 90 * 100) + '%';
}
</script>
</body>
</html>