html2app • JS Bridge
    Preparing search index...

    Variable VibrationConst

    Vibration: {
        vibrate(duration?: number, amplitude?: number): MessageResponse<{}>;
        vibrateWithPattern(
            pattern: number[],
            intensities?: number[],
        ): Promise<MessageResponse<{}>>;
        hasVibrator(): Promise<boolean>;
        hasAmplitudeControl(): Promise<boolean>;
        hasCustomVibrationsSupport(): Promise<boolean>;
    } = ...

    Device vibration plugin.

    Type Declaration

    • vibrate: function
      • Vibrate the device for a specific duration and amplitude.

        Parameters

        • duration: number = 500

          Vibration duration in milliseconds (default: 500ms)

        • amplitude: number = -1

          Vibration strength 1-255, or -1 for device default

        Returns MessageResponse<{}>

        ok: false if amplitude is out of range. Otherwise ok: true once the command is sent, even on a device without a vibrator.

    • vibrateWithPattern: function
      • Vibrate the device with a custom pattern

        Parameters

        • pattern: number[]

          Pulse durations (ms) in [wait, vibrate, wait, vibrate, ...] format.

        • Optionalintensities: number[]

          Optional vibration strengths (0-255). If provided, must be the same length as the pattern array.

        Returns Promise<MessageResponse<{}>>

        A promise that resolves when the vibration command is sent.

    • hasVibrator: function
      • Check whether the device has a vibrator.

        Returns Promise<boolean>

        true if the device has a vibrator. false if it does not, or if the check fails.

    • hasAmplitudeControl: function
      • Check whether the device can vibrate at a chosen strength, which vibrate's amplitude and vibrateWithPattern's intensities need.

        Returns Promise<boolean>

        true if the device supports amplitude control. false if it does not, or if the check fails.

    • hasCustomVibrationsSupport: function
      • Check whether the device supports custom vibration patterns, as used by vibrateWithPattern.

        Returns Promise<boolean>

        true if custom patterns are supported. false if they are not, or if the check fails.

    Provides haptic feedback control for the device. Requires the vibration plugin to be enabled in the app configuration.

    vibrate returns ok as soon as the command is sent. It does not report whether the device has a vibrator. Call Vibration.hasVibrator first when that matters.

    import { Vibration } from '@yandeu/js-bridge/lib/plugins/vibration.js'

    Vibration.vibrate(100)