From 8845c347b175ebf9a92bcb153f0135f1660cd893 Mon Sep 17 00:00:00 2001 From: Website Deployment Script Date: Fri, 26 Aug 2016 02:45:04 +0000 Subject: [PATCH] Updated docs for next --- releases/next/docs/vibration.html | 45 ++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 7 deletions(-) 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 @@ -Vibration – React Native | A framework for building native apps using React

Vibration #

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.

Methods #

static vibrate(pattern, repeat) #

static cancel(0) #

Stop vibration

@platform android

You can edit the content above on GitHub and send us a pull request!

Examples #

Edit on GitHub
'use strict'; +Vibration – React Native | A framework for building native apps using React

Vibration #

Methods #

static vibrate(pattern, repeat) #

static cancel(0) #

Stop vibration

You can edit the content above on GitHub and send us a pull request!

Examples #

Edit on GitHub
'use strict'; var React = require('react'); var ReactNative = require('react-native'); @@ -10,12 +8,45 @@ add <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>