Skip to content

Add w3c_vibration.js #177

@craigmit

Description

@craigmit

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions