@@ -22,14 +22,15 @@ const Platform = require('../Utilities/Platform');
22
22
23
23
let _vibrating : boolean = false ;
24
24
let _id : number = 0 ; // _id is necessary to prevent race condition.
25
+ const _default_vibration_length = 400 ;
25
26
26
27
function vibrateByPattern ( pattern : Array < number > , repeat : boolean = false ) {
27
28
if ( _vibrating ) {
28
29
return ;
29
30
}
30
31
_vibrating = true ;
31
32
if ( pattern [ 0 ] === 0 ) {
32
- NativeVibration . vibrate ( ) ;
33
+ NativeVibration . vibrate ( _default_vibration_length ) ;
33
34
pattern = pattern . slice ( 1 ) ;
34
35
}
35
36
if ( pattern . length === 0 ) {
@@ -48,7 +49,7 @@ function vibrateScheduler(
48
49
if ( ! _vibrating || id !== _id ) {
49
50
return ;
50
51
}
51
- NativeVibration . vibrate ( ) ;
52
+ NativeVibration . vibrate ( _default_vibration_length ) ;
52
53
if ( nextIndex >= pattern . length ) {
53
54
if ( repeat ) {
54
55
nextIndex = 0 ;
@@ -70,7 +71,7 @@ const Vibration = {
70
71
* See https://facebook.github.io/react-native/docs/vibration.html#vibrate
71
72
*/
72
73
vibrate : function (
73
- pattern : number | Array < number > = 400 ,
74
+ pattern : number | Array < number > = _default_vibration_length ,
74
75
repeat : boolean = false ,
75
76
) {
76
77
if ( Platform . OS === 'android' ) {
@@ -86,7 +87,7 @@ const Vibration = {
86
87
return ;
87
88
}
88
89
if ( typeof pattern === 'number' ) {
89
- NativeVibration . vibrate ( ) ;
90
+ NativeVibration . vibrate ( pattern ) ;
90
91
} else if ( Array . isArray ( pattern ) ) {
91
92
vibrateByPattern ( pattern , repeat ) ;
92
93
} else {
0 commit comments