Skip to content

Commit ecf1947

Browse files
author
Andrew Kirkpatrick
authored
Create motiontest.html
1 parent b9788e9 commit ecf1947

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

motiontest.html

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
<style type="text/css">
6+
7+
.slidecontainer {
8+
width:100%;
9+
}
10+
</style>
11+
12+
<title>WCAG Failure Example of Motion Sensor</title>
13+
</head>
14+
<body>
15+
16+
<pre class="output"></pre>
17+
18+
<h1>Slider Motion Sensor Failure Example </h1>
19+
20+
<p>Open this slider on a device with a motion sensor, such as a smart phone or tablet. Tilt the device to the right and left to adjust the slider value. The decrease and increase buttons also adjust the value. There is no way to deactivate the motion sensor.</p>
21+
<p>Note: This example may not work across all browsers.</p>
22+
23+
<div class="slidecontainer">
24+
<button type="button" name="decrease" onclick="decreaseFunction()">Decrease Value</button>
25+
<input type="range" min="1" max="100" value="50" class="slider" id="motionSlider">
26+
<button type="button" name="increase" onclick="increaseFunction()">Increase Value</button>
27+
<p aria-live="polite">Slider Value: <span id="demo"></span></p>
28+
</div>
29+
30+
<script>
31+
32+
//slider behavior
33+
var slider = document.getElementById("motionSlider");
34+
var output = document.getElementById("demo");
35+
output.innerHTML = slider.value;
36+
slider.oninput = function() {
37+
output.innerHTML = this.value;
38+
}
39+
40+
function increaseFunction() {slider.value++; output.innerHTML = slider.value;}
41+
function decreaseFunction() {slider.value--; output.innerHTML = slider.value;}
42+
43+
//slider motion detection
44+
function handleOrientation(event) {
45+
46+
var x = event.gamma;
47+
48+
if (x > 20) {slider.value++; output.innerHTML = slider.value;}
49+
else if (x < -20) {slider.value--; output.innerHTML = slider.value;} }
50+
51+
52+
window.addEventListener('deviceorientation', handleOrientation);
53+
54+
</script>
55+
</body>
56+
</html>

0 commit comments

Comments
 (0)