Skip to content

Instantly share code, notes, and snippets.

@katapad
Created June 30, 2014 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katapad/11e0db5ed37bf7e2051d to your computer and use it in GitHub Desktop.
Save katapad/11e0db5ed37bf7e2051d to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://zeptojs.com/zepto.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
button {
padding: 1em;
}
.button {
margin-top: 2em;
text-align: center;
}
</style>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
</head>
<body>
<h1>Vibe使えるかテスト</h1>
<div id="output"> </div>
<div class="button">
<button id="vibration">震えます</button>
</div>
<div class="button">
<button id="vibration2">すごく震えます</button>
</div>
</body>
</html>
$('#output').text('このブラウザでは使えません')
navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate;
$(function(){
if ("vibrate" in navigator) {
navigator.vibrate(1000);
$('#output').text('このブラウザでは使えます!')
$('#vibration').on('click', function(){
navigator.vibrate(1000);
});
$('#vibration2').on('click', function(){
navigator.vibrate([500,500,500,1000,500,500,1000]);
});
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment