OLD | NEW |
---|---|
(Empty) | |
1 <html> | |
2 <head> | |
3 <title>DeviceOrientationAbsolute test</title> | |
4 <script type="text/javascript"> | |
5 function checkOrientationAbsoluteEvent(event) { | |
6 // Return true iff the orientation is close enough to (3, 4, 5). | |
Michael van Ouwerkerk
2017/03/16 10:42:32
nit: 3, 4, 5 or 4, 5, 6?
timvolodine
2017/03/16 15:50:02
indeed 4,5,6 thanks for catching this!
Done.
| |
7 return Math.abs(event.alpha - 4) < 0.01 && | |
8 Math.abs(event.beta - 5) < 0.01 && | |
9 Math.abs(event.gamma - 6) < 0.01 && | |
10 event.absolute == true; | |
11 } | |
12 | |
13 function onOrientationAbsolute(event) { | |
14 if (checkOrientationAbsoluteEvent(event)) { | |
15 window.removeEventListener('deviceorientationabsolute', onOrientationA bsolute); | |
16 pass(); | |
17 } else { | |
18 fail(); | |
19 } | |
20 } | |
21 | |
22 function pass() { | |
23 document.getElementById('status').innerHTML = 'PASS'; | |
24 document.location = '#pass'; | |
25 } | |
26 | |
27 function fail() { | |
28 document.location = '#fail'; | |
29 } | |
30 </script> | |
31 </head> | |
32 <body onLoad="window.addEventListener('deviceorientationabsolute', onOrientati onAbsolute)"> | |
33 <div id="status">FAIL</div> | |
34 </body> | |
35 </html> | |
OLD | NEW |