mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-21 00:23:00 +08:00
Merge pull request #50 from driftyco/add-vibration
feat(plugin): add vibration
This commit is contained in:
commit
521dba6d3b
37
src/plugins/vibration.ts
Normal file
37
src/plugins/vibration.ts
Normal file
@ -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<Number>} 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) {}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user