srifqi.github.io/experiment/vibration_test.html

73 lines
3.3 KiB
HTML

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>Web Vibration API - Experiments - srifqi</title>
<meta charset="utf-8">
<meta name="author" content="srifqi">
<meta name="description" content="Vibrate your device from Web!">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">
<link rel="stylesheet" href="/main.css">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"name": "Experiments",
"item": "https://srifqi.github.io/experiment/"
}, {
"@type": "ListItem",
"position": 2,
"name": "Web Vibration API"
}]
}
</script>
</head>
<body style="border: 0; max-width: 100%;">
<header><h1>Web Vibration API Experiment</h1></header>
<main>
<nav>
<ul class="left-menu">
<li><div><a href="/">Home</a></div></li>
<li><div><a href="./">Experiments</a></div><ul>
<li><a href="localoutlierfactor.html">LOF (Statistics)</a></li>
<li><a href="dip_contrast_enhancement.html">Contrast Enhance</a></li>
<li><a href="dip_edge_detection.html">Edge Detection</a></li>
<li><a href="dip_smoothing.html">Image Smoothing</a></li>
<li><a href="dip_grey_transform.html">Grey Transform</a></li>
<li><a href="genetic_algorithm.html">Genetic Algorithm</a></li>
<li class="active"><a href="vibration_test.html">Web Vibration API</a></li>
<li><a href="addition_game.html">Addition Game</a></li>
<li><a href="negative_lens.html">Negative Lens</a></li>
<li><a href="positive_lens.html">Positive Lens</a></li>
<li><a href="waterdrop.html">Waterdrop</a></li>
<li><a href="drive_a_car.html">Drive A Car</a></li>
</ul></li>
<li><div><a href="/minetest.html">Minetest</a></div></li>
<li><div><a href="/library.html">Libraries</a></div></li>
</ul>
</nav>
<section style="max-width: calc(100% - 16px);">
<aside>
<table>
<thead>
<tr><th colspan="2">Web Vibration API</th></tr>
</thead>
<tbody>
<tr><th>Type</th><td>API testing</td></tr>
<tr><th>Date</th><td><time datetime="2020-08-08">8 August 2020</time></td></tr>
</tbody>
</table>
</aside>
<p>I was browsing on the Web when suddenly an advertisement showed up and vibrate my phone. I was confused for a second because it said that there is a virus inside my phone. Knowing that it is an advertisement, I ignored that. But, I did not know that you can vibrate your device from Web!</p>
<p>This was created to demonstrate <a href="https://developer.mozilla.org/docs/Web/API/Vibration_API" target="_blank" rel="noopener">Web Vibration API</a>. It consists of a function, <code>navigator.vibrate()</code>, to do vibration for some amount of time.</p>
<p>Since the API only allows to vibrate for a finite amount of time, a timer is scheduled to re-vibrate the device (using <code>setTimeout()</code> function). To prevent gap between vibration, the length of each vibration is doubled. It is fine because the <code>vibrate()</code> function will reset the duration.</p>
<p><span class="italic">Try different vibration cycle</span></p>
<p><a href="bare/vibration_test.html" target="_blank">open in new window</a></p>
<iframe style="width: 500px; height: 600px;" src="bare/vibration_test.html" title="The experiment"></iframe>
</section>
</main>
</body>
</html>