Basic usage

As long as your device support the Vibration API, usage is very simple.

The only functions to use is :

navigator.vibrate();

If you want to make a simple vibration:

// Vibrate for 300ms
navigator.vibrate([300]);
// or
navigator.vibrate(300);

For more complex pattern you can pass a pattern of vibrations followed by pauses:

// 'SOS' in morse code
navigator.vibrate([50,50,50,50,50,150,150,50,150,50,150,150,50,50,50,50,50]]); 

Sometimes smartphone actuator cannot play fast changes, so here is a slower version:

// a slower 'SOS' in morse code
navigator.vibrate([100,100,100,100,100,300,300,100,300,100,300,300,100,100,100,100,100]); 

To stop a vibration, just call the function with the value 0:

navigator.vibrate(0)

Next