How to manage the vibration on a device?

■ Summary
-The following code snippet demonstrates how to use the vibration.

■ Reference Site
- http://www.w3.org/TR/2012/WD-vibration-20120202/
 function basicVibration()
 {
    // Vibrate for 3 seconds 
    navigator.vibrate(3000);
 }

 function patternVibration1()
 {
    // Vibrate in a give pattern : 1 sec on, 0.5 sec off, 2 sec on
    navigator.vibrate([1000, 500, 2000]);
 } 
 
 function patternVibration2()
 {
    // Vibrate in a given pattern: 1 sec on, 1 sec off, 2 sec on, 2 sec off, 1 sec on
    navigator.vibrate([1000, 1000, 2000, 2000, 1000]);
 } 

 function stopVibration()
 {
    // Cancels any existing vibrations
    navigator.vibrate(0);
 } 




Responses

0 Replies