diff --git a/releases/next/docs/vibration.html b/releases/next/docs/vibration.html index cb8598c63ce..70b285fe0c2 100644 --- a/releases/next/docs/vibration.html +++ b/releases/next/docs/vibration.html @@ -1,6 +1,4 @@ -
The Vibration API is exposed at Vibration.vibrate().
-The vibration is asynchronous so this method will return immediately.
There will be no effect on devices that do not support Vibration, eg. the simulator.
Note for android
-add <uses-permission android:name="android.permission.VIBRATE"/> to AndroidManifest.xml
Vibration patterns are currently unsupported.
You can edit the content above on GitHub and send us a pull request!
Examples # | Edit on GitHub |
You can edit the content above on GitHub and send us a pull request!
Examples # | Edit on GitHub |
<uses-permission android:name="android.permission.VIBRATE"
Text,
TouchableHighlight,
Vibration,
+ Platform,
} = ReactNative;
exports.framework = 'React';
exports.title = 'Vibration';
exports.description = 'Vibration API';
+
+var pattern, patternLiteral, patternDescription;
+if (Platform.OS === 'android') {
+ pattern = [0, 500, 200, 500];
+ patternLiteral = '[0, 500, 200, 500]';
+ patternDescription = `${patternLiteral}
+arg 0: duration to wait before turning the vibrator on.
+arg with odd: vibration length.
+arg with even: duration to wait before next vibration.
+`;
+} else {
+ pattern = [0, 1000, 2000, 3000];
+ patternLiteral = '[0, 1000, 2000, 3000]';
+ patternDescription = `${patternLiteral}
+vibration length on iOS is fixed.
+pattern controls durations BETWEEN each vibration only.
+
+arg 0: duration to wait before turning the vibrator on.
+subsequent args: duration to wait before next vibrattion.
+`;
+}
+
exports.examples = [
+ {
+ title: 'Pattern Descriptions',
+ render() {
+ return (
+ <View style={styles.wrapper}>
+ <Text>{patternDescription}</Text>
+ </View>
+ );
+ },
+ },
{
title: 'Vibration.vibrate()',
render() {
@@ -31,12 +62,12 @@ exports.examples },
},
{
- title: 'Vibration.vibrate([0, 500, 200, 500])',
+ title: `Vibration.vibrate(${patternLiteral})`,
render() {
return (
<TouchableHighlight
style={styles.wrapper}
- onPress={() => Vibration.vibrate([0, 500, 200, 500])}>
+ onPress={() => Vibration.vibrate(pattern)}>
<View style={styles.button}>
<Text>Vibrate once</Text>
</View>
@@ -45,12 +76,12 @@ exports.examples },
},
{
- title: 'Vibration.vibrate([0, 500, 200, 500], true)',
+ title: `Vibration.vibrate(${patternLiteral}, true)`,
render() {
return (
<TouchableHighlight
style={styles.wrapper}
- onPress={() => Vibration.vibrate([0, 500, 200, 500], true)}>
+ onPress={() => Vibration.vibrate(pattern, true)}>
<View style={styles.button}>
<Text>Vibrate until cancel</Text>
</View>