Created
June 30, 2014 08:58
-
-
Save katapad/11e0db5ed37bf7e2051d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#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