elemental2
elemental2 copied to clipboard
Add w3c_vibration.js
JavaScript has navigator.vibrate ( https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vibrate ), however, Elemental2 doesn't have it.
It exists in the closure-compiler here: https://github.com/google/closure-compiler/blob/master/externs/browser/w3c_vibration.js
Can we pleae add it to Elemental2?
Until it's added, we need to us JSInterop:
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public interface NavigatorVibrate {
@JsMethod
boolean vibrate(double milliseconds);
@JsMethod
boolean vibrate(double[] pattern);
}
NavigatorVibrate nav = Js.cast(DomGlobal.navigator);
nav.vibrate(80);