-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvibrationAPI.html
47 lines (40 loc) · 1.74 KB
/
vibrationAPI.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
<!DOCTYPE HTML>
<html lang="en">
<head>
<!-- basic.html -->
<title>vibrationAPI</title>
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>The Vibration API</h1>
<p>
Almost every existing mobile device includes some vibration hardware, which allows the device to shake to provide feedback to the user. <br>
This Web-API provides control of this features to web apps and does nothing if the hardware does not support it. <br>
Vibration is described as a pattern of on/off intervals, e.g. the 'Vibrate Pattern' Button is described like this [300,100,300,100,300]:<br>
The device vibrates for 300ms than does nothing for 100ms and again.<br>
To acces this API use navigator.vibrate:<br>
<code>navigator.vibrate([300, 100, 300, 100, 300]);</code> <br>
Try it out below!
<br>
</p>
<button class="button" onclick="vibrate(1000)">Vibrate Single</button><br>
<button class="button" onclick="vibratePattern()">Vibrate Pattern</button><br>
<button class="button" onclick="vibrateStarWars()">May the vibration be with you</button><br>
<button class="button" onclick="itsame()">It's a me, Mariooo!</button>
<script>
function vibrate(ms) {
navigator.vibrate(ms);
}
function vibratePattern() {
navigator.vibrate([300, 100, 300, 100, 300]);
}
function vibrateStarWars() {
navigator.vibrate([500,110,500,110,450,110,200,110,170,40,450,110,200,110,170,40,500]);
}
function itsame() {
navigator.vibrate([125,75,125,275,200,275,125,75,125,275,200,600,200,600]);
}
</script>
<a href="index.html"> back </a>
</body>