Haptics API
chevron down
 

Haptics API

Variable: vibration

Type: Vibration

The Haptics API allows developers to control the device's vibration motor.

import { vibration } from "haptics";
vibration.start("ring");

Interface: Vibration

Functions of the device's vibration motor.

Methods

start()

start(pattern: VibrationPatternName)

Returns: boolean

Start a vibration pattern by name.

Available patterns:

  • "alert"
  • "bump"
  • "confirmation"
  • "confirmation-max"
  • "nudge"
  • "nudge-max"
  • "ping"
  • "ring"
stop()

Returns: void

Stop a playing vibration pattern.

If the vibration motor is currently playing a pattern, it will stop. It the vibration motor is not playing anything, this has no effect.

VibrationPatternName

String: "alert" | "bump" | "confirmation" | "confirmation-max" | "nudge" | "nudge-max" | "ping" | "ring"

List of all available vibration pattern names.