All Projects → apache → Cordova Plugin Vibration

apache / Cordova Plugin Vibration

Licence: apache-2.0
Apache Cordova Plugin vibration

Programming Languages

javascript
184084 projects - #8 most used programming language
java
68154 projects - #9 most used programming language
csharp
926 projects
cplusplus
227 projects

Projects that are alternatives of or similar to Cordova Plugin Vibration

Cordova App Harness
[DEPRECATED] Apache Cordova app harness
Stars: ✭ 49 (-55.05%)
Mutual labels:  library, mobile, cordova
Cordova Mobile Spec
Apache Cordova mobile-spec
Stars: ✭ 57 (-47.71%)
Mutual labels:  library, mobile, cordova
Cordova Weinre
Mirror of Apache Weinre
Stars: ✭ 506 (+364.22%)
Mutual labels:  library, mobile, cordova
Cordova Cli
Apache Cordova CLI
Stars: ✭ 861 (+689.91%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Splashscreen
Apache Cordova Plugin splashscreen
Stars: ✭ 602 (+452.29%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Whitelist
Apache Cordova plugin whitelist
Stars: ✭ 442 (+305.5%)
Mutual labels:  library, mobile, cordova
Cordova Firefoxos
[DEPRECATED] Apache Cordova firefoxos
Stars: ✭ 41 (-62.39%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Media
Apache Cordova Plugin media
Stars: ✭ 338 (+210.09%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Test Framework
Apache Cordova
Stars: ✭ 66 (-39.45%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Geolocation
Apache Cordova Plugin geolocation
Stars: ✭ 584 (+435.78%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Camera
Apache Cordova Plugin camera
Stars: ✭ 879 (+706.42%)
Mutual labels:  library, mobile, cordova
Cordova Plugin File
Apache Cordova Plugin file
Stars: ✭ 664 (+509.17%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Network Information
Apache Cordova Plugin network-information
Stars: ✭ 429 (+293.58%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Inappbrowser
Apache Cordova Plugin inappbrowser
Stars: ✭ 994 (+811.93%)
Mutual labels:  library, mobile, cordova
Cordova Plugman
Apache Cordova Plugman
Stars: ✭ 379 (+247.71%)
Mutual labels:  library, mobile, cordova
Cordova Plugin File Transfer
Apache Cordova Plugin file-transfer
Stars: ✭ 537 (+392.66%)
Mutual labels:  library, mobile, cordova
Cordova
Apache Cordova
Stars: ✭ 291 (+166.97%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Device
Apache Cordova Plugin device
Stars: ✭ 327 (+200%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Statusbar
Apache Cordova
Stars: ✭ 581 (+433.03%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Wkwebview Engine
[DEPRECATED] Apache Cordova wkwebview engine plugin
Stars: ✭ 607 (+456.88%)
Mutual labels:  library, mobile, cordova

title: Vibration description: Vibrate the device.

AppVeyor Travis CI
Build status Build Status

cordova-plugin-vibration

This plugin provides a way to vibrate the device. Its API aligns with the W3C vibration specification at http://www.w3.org/TR/vibration/

The plugin defines a global object/method navigator.vibrate. Although in the global scope, it is not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(navigator.vibrate);
}

Installation

cordova plugin add cordova-plugin-vibration

Supported Platforms

  • iOS
  • Windows Phone
  • Android
    The Android webview (API level 19 and up) supports the W3C Vibration API natively, so no Android specific implementation in this plugin is necessary.

navigator.vibrate

This function has three different functionalities based on parameters passed to it:

Standard vibrate

Vibrates the device for a given amount of time.

navigator.vibrate(time)

or

navigator.vibrate([time])
  • time: Milliseconds to vibrate the device. (Number)

Example

// Vibrate for 3 seconds
navigator.vibrate(3000);

// Vibrate for 3 seconds
navigator.vibrate([3000]);

Quirks

iOS Quirks
  • time: Ignores the specified time and vibrates for a pre-set amount of time.

    navigator.vibrate(3000); // 3000 is ignored
    
Windows Phone Quirks
  • time: Max time is 5000ms (5s) and min time is 1ms

    navigator.vibrate(8000); // will be truncated to 5000
    
Android Quirks

Calls to navigator.vibrate will immediately return false if user hasn't tapped on the frame or any embedded frame yet.

See https://www.chromestatus.com/feature/5644273861001216

Vibrate with a pattern

Vibrates the device with a given pattern

navigator.vibrate(pattern);
  • pattern: Sequence of durations (in milliseconds) for which to turn on or off the vibrator. (Array of Numbers)

Example

// Vibrate for 1 second
// Wait for 1 second
// Vibrate for 3 seconds
// Wait for 1 second
// Vibrate for 5 seconds
navigator.vibrate([1000, 1000, 3000, 1000, 5000]);

Quirks

  • Not supported on iOS

Cancel vibration

Immediately cancels any currently running vibration.

navigator.vibrate(0)

or

navigator.vibrate([])

or

navigator.vibrate([0])

Passing in a parameter of 0, an empty array, or an array with one element of value 0 will cancel any vibrations.

Quirks

  • Not supported on iOS
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].