You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ja...@apache.org on 2019/05/16 22:14:20 UTC
[cordova-plugin-vibration] 01/01: Improve README
This is an automated email from the ASF dual-hosted git repository.
janpio pushed a commit to branch janpio-improve_readme
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-vibration.git
commit dcbc12ea46b0c967c534b2bb74242dbc12578306
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Fri May 17 00:14:15 2019 +0200
Improve README
---
README.md | 66 ++++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 38 insertions(+), 28 deletions(-)
diff --git a/README.md b/README.md
index ac79b5a..cc959b4 100644
--- a/README.md
+++ b/README.md
@@ -27,38 +27,33 @@ description: Vibrate the device.
# cordova-plugin-vibration
-This plugin aligns with the W3C vibration specification http://www.w3.org/TR/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/
-This plugin provides a way to vibrate the device.
+The plugin defines a global object/method `navigator.vibrate`. Although in the global scope, it is not available until after the `deviceready` event.
-This plugin defines global objects including `navigator.vibrate`.
-
-Although in the global scope, they are not available until after the `deviceready` event.
```javascript
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(navigator.vibrate);
}
```
+
## Installation
+
```console
cordova plugin add cordova-plugin-vibration
```
## Supported Platforms
-navigator.vibrate
-
-- Android
- iOS
-- Windows
-
-
-The Android webview (API level 19 and up) supports the [W3C Vibration API](https://www.w3.org/TR/vibration/) natively and therefore, the Android specific implementation of this plugin has been dropped.
+- Windows Phone 8.1
+- Android
+ The Android webview (API level 19 and up) supports the [W3C Vibration API](https://www.w3.org/TR/vibration/) natively, so no Android specific implementation in this plugin is necessary.
-## vibrate
+## navigator.vibrate
-This function has three different functionalities based on parameters passed to it.
+This function has three different functionalities based on parameters passed to it:
### Standard vibrate
@@ -72,9 +67,10 @@ or
navigator.vibrate([time])
```
--__time__: Milliseconds to vibrate the device. _(Number)_
+- __time__: Milliseconds to vibrate the device. _(Number)_
#### Example
+
```javascript
// Vibrate for 3 seconds
navigator.vibrate(3000);
@@ -82,27 +78,33 @@ navigator.vibrate(3000);
// Vibrate for 3 seconds
navigator.vibrate([3000]);
```
-### Android Quirks
-
-Calls to `navigator.vibrate` will immediately return `false` if user hasn't tapped on the frame or any embedded frame yet. Please checkout https://issues.apache.org/jira/browse/CB-14022 for more information.
+#### Quirks
-#### iOS Quirks
+##### iOS Quirks
- __time__: Ignores the specified time and vibrates for a pre-set amount of time.
-```javascript
-navigator.vibrate(3000); // 3000 is ignored
-```
-#### Windows Quirks
+
+ ```javascript
+ navigator.vibrate(3000); // 3000 is ignored
+ ```
+
+##### Windows Quirks
- __time__: Max time is 5000ms (5s) and min time is 1ms
-```javascript
-navigator.vibrate(8000); // will be truncated to 5000
-```
+ ```javascript
+ 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. Please checkout https://issues.apache.org/jira/browse/CB-14022 for more information.
+
+### Vibrate with a pattern
-### Vibrate with a pattern (Android and Windows only)
Vibrates the device with a given pattern
+
```javascript
navigator.vibrate(pattern);
```
@@ -119,7 +121,11 @@ navigator.vibrate(pattern);
navigator.vibrate([1000, 1000, 3000, 1000, 5000]);
```
-### Cancel vibration (not supported in iOS)
+#### Quirks
+
+- Not supported on iOS
+
+### Cancel vibration
Immediately cancels any currently running vibration.
```javascript
@@ -134,3 +140,7 @@ 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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org