How can I control the amplitude/strength of vibration with the web Vibration API?

739 Views Asked by At

Our web app uses the Vibrate API for a subtle button press effect:

window.navigator.vibrate(5);

But on my new phone, it feels less subtle, and more like my phone is trying to jump out of my hand. The problem is that the window.navigator.vibrate API does not let me set the amplitude/strength of the vibration; it only lets me set the duration.

With Android's VibrationEffect, you can set the "amplitude". With iOS's Core Haptics, you can set "intensity" and "sharpness".

How can I set the amplitude/strength/sharpness/intensity of a vibration using the web Vibrate API?

1

There are 1 best solutions below

1
phuzi On BEST ANSWER

Taking a look at the spec there's nothing that appears to allow you to control anything more than the pattern of vibrations.

From the spec W3C

typedef (unsigned long or sequence<unsigned long>) VibratePattern;

partial interface Navigator {
    boolean vibrate (VibratePattern pattern);
};

The vibrate() method steps are to run the processing vibration patterns algorithm. A vibration pattern is represented by a VibratePattern object.