From 3cc4ee4196edbaaf8298719ffdda1d7ff0cd17b4 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Sun, 13 Mar 2016 15:53:03 -0400 Subject: [PATCH] feat(plugin): add vibration --- src/plugins/vibration.ts | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/plugins/vibration.ts diff --git a/src/plugins/vibration.ts b/src/plugins/vibration.ts new file mode 100644 index 000000000..cac11e08c --- /dev/null +++ b/src/plugins/vibration.ts @@ -0,0 +1,37 @@ +import {Plugin, Cordova} from './plugin' +/** + * @name Vibration + * @description Vibrates the device + * @usage + * ```ts + * // Vibrate the device for a second + * Vibration.vibrate(1000); + * + * // Vibrate 2 seconds + * // Pause for 1 second + * // Vibrate for 2 seconds + * // Patterns work on Android and Windows only + * Vibration.vibrate([2000,1000,2000]); + * + * // Stop any current vibrations immediately + * // Works on Android and Windows only + * Vibration.vibrate(0); + * ``` + */ +@Plugin({ + plugin: 'cordova-plugin-vibration', + pluginRef: 'navigator.vibrate', + repo: 'https://github.com/apache/cordova-plugin-vibration' +}) +export class Vibration { + + /** + * Vibrates the device for given amount of time. + * @param time {Number|Array} Milliseconds to vibrate the device. If passed an array of numbers, it will define a vibration pattern. Pass 0 to stop any vibration immediately. + */ + @Cordova({ + sync: true + }) + static vibrate(time : any) {} + +} \ No newline at end of file