diff --git a/css/react-native.css b/css/react-native.css index 1f10099b670..180661c750e 100644 --- a/css/react-native.css +++ b/css/react-native.css @@ -698,7 +698,7 @@ h1:hover .hash-link, h2:hover .hash-link, h3:hover .hash-link, h4:hover .hash-li font-size: 14px; float: left; width: 210px; - margin: 5px 48px 0 0; } + margin: 0 48px 0 0; } .nav-docs ul { list-style: none; margin: 0; @@ -722,7 +722,7 @@ h1:hover .hash-link, h2:hover .hash-link, h3:hover .hash-link, h4:hover .hash-li font-size: 16px; font-weight: 400; line-height: 20px; - margin-top: 12px; + margin-top: 0; margin-bottom: 5px; padding: 10px; background-color: #222; @@ -1539,6 +1539,22 @@ table.versions { text-align: center; background-color: rgba(5, 165, 209, 0.05); } +.banner-crna-ejected { + border: 1px solid #05A5D1; + border-radius: 3px; + margin-bottom: 40px; } + .banner-crna-ejected h3 { + font-size: 16px; + margin: 0; + padding: 0 10px; + background-color: #05A5D1; + color: white; } + .banner-crna-ejected p { + padding: 10px; + margin: 2px; + text-decoration: none !important; + background-color: white; } + .prism { white-space: pre-wrap; font-family: 'source-code-pro', Menlo, 'Courier New', Consolas, monospace; diff --git a/docs/accessibility.html b/docs/accessibility.html index 1fc623a4363..0ea85cef8ed 100644 --- a/docs/accessibility.html +++ b/docs/accessibility.html @@ -1,12 +1,11 @@ -Accessibility

Accessibility #

Native App Accessibility (iOS and Android) #

Both iOS and Android provide APIs for making apps accessible to people with disabilities. In addition, both platforms provide bundled assistive technologies, like the screen readers VoiceOver (iOS) and TalkBack (Android) for the visually impaired. Similarly, in React Native we have included APIs designed to provide developers with support for making apps more accessible. Take note, iOS and Android differ slightly in their approaches, and thus the React Native implementations may vary by platform.

In addition to this documentation, you might find this blog post about React Native accessibility to be useful.

Making Apps Accessible #

Accessibility properties #

accessible (iOS, Android) #

When true, indicates that the view is an accessibility element. When a view is an accessibility element, it groups its children into a single selectable component. By default, all touchable elements are accessible.

On Android, ‘accessible={true}’ property for a react-native View will be translated into native ‘focusable={true}’.

<View accessible={true}> +Accessibility

Accessibility #

Native App Accessibility (iOS and Android) #

Both iOS and Android provide APIs for making apps accessible to people with disabilities. In addition, both platforms provide bundled assistive technologies, like the screen readers VoiceOver (iOS) and TalkBack (Android) for the visually impaired. Similarly, in React Native we have included APIs designed to provide developers with support for making apps more accessible. Take note, iOS and Android differ slightly in their approaches, and thus the React Native implementations may vary by platform.

Making Apps Accessible #

Accessibility properties #

accessible (iOS, Android) #

When true, indicates that the view is an accessibility element. When a view is an accessibility element, it groups its children into a single selectable component. By default, all touchable elements are accessible.

On Android, ‘accessible={true}’ property for a react-native View will be translated into native ‘focusable={true}’.

<View accessible={true}> <Text>text one</Text> <Text>text two</Text> </View>

In the above example, we can't get accessibility focus separately on 'text one' and 'text two'. Instead we get focus on a parent view with 'accessible' property.

accessibilityLabel (iOS, Android) #

When a view is marked as accessible, it is a good practice to set an accessibilityLabel on the view, so that people who use VoiceOver know what element they have selected. VoiceOver will read this string when a user selects the associated element.

To use, set the accessibilityLabel property to a custom string on your View:

<TouchableOpacity accessible={true} accessibilityLabel={'Tap me!'} onPress={this._onPress}> <View style={styles.button}> <Text style={styles.buttonText}>Press me!</Text> </View> -</TouchableOpacity>

In the above example, the accessibilityLabel on the TouchableOpacity element would default to "Press me!". The label is constructed by concatenating all Text node children separated by spaces.

accessibilityTraits (iOS) #

Accessibility traits tell a person using VoiceOver what kind of element they have selected. Is this element a label? A button? A header? These questions are answered by accessibilityTraits.

To use, set the accessibilityTraits property to one of (or an array of) accessibility trait strings:

  • none Used when the element has no traits.
  • button Used when the element should be treated as a button.
  • link Used when the element should be treated as a link.
  • header Used when an element acts as a header for a content section (e.g. the title of a navigation bar).
  • search Used when the text field element should also be treated as a search field.
  • image Used when the element should be treated as an image. Can be combined with button or link, for example.
  • selected Used when the element is selected. For example, a selected row in a table or a selected button within a segmented control.
  • plays Used when the element plays its own sound when activated.
  • key Used when the element acts as a keyboard key.
  • text Used when the element should be treated as static text that cannot change.
  • summary Used when an element can be used to provide a quick summary of current conditions in the app when the app first launches. For example, when Weather first launches, the element with today's weather conditions is marked with this trait.
  • disabled Used when the control is not enabled and does not respond to user input.
  • frequentUpdates Used when the element frequently updates its label or value, but too often to send notifications. Allows an accessibility client to poll for changes. A stopwatch would be an example.
  • startsMedia Used when activating an element starts a media session (e.g. playing a movie, recording audio) that should not be interrupted by output from an assistive technology, like VoiceOver.
  • adjustable Used when an element can be "adjusted" (e.g. a slider).
  • allowsDirectInteraction Used when an element allows direct touch interaction for VoiceOver users (for example, a view representing a piano keyboard).
  • pageTurn Informs VoiceOver that it should scroll to the next page when it finishes reading the contents of the element.

accessibilityViewIsModal (iOS) #

A Boolean value indicating whether VoiceOver should ignore the elements within views that are siblings of the receiver.

For example, in a window that contains sibling views A and B, setting accessibilityViewIsModal to true on view B causes VoiceOver to ignore the elements in the view A. -On the other hand, if view B contains a child view C and you set accessibilityViewIsModal to true on view C, VoiceOver does not ignore the elements in view A.

onAccessibilityTap (iOS) #

Use this property to assign a custom function to be called when someone activates an accessible element by double tapping on it while it's selected.

onMagicTap (iOS) #

Assign this property to a custom function which will be called when someone performs the "magic tap" gesture, which is a double-tap with two fingers. A magic tap function should perform the most relevant action a user could take on a component. In the Phone app on iPhone, a magic tap answers a phone call, or ends the current one. If the selected element does not have an onMagicTap function, the system will traverse up the view hierarchy until it finds a view that does.

accessibilityComponentType (Android) #

In some cases, we also want to alert the end user of the type of selected component (i.e., that it is a “button”). If we were using native buttons, this would work automatically. Since we are using javascript, we need to provide a bit more context for TalkBack. To do so, you must specify the ‘accessibilityComponentType’ property for any UI component. For instances, we support ‘button’, ‘radiobutton_checked’ and ‘radiobutton_unchecked’ and so on.

<TouchableWithoutFeedback accessibilityComponentType=”button” +</TouchableOpacity>

In the above example, the accessibilityLabel on the TouchableOpacity element would default to "Press me!". The label is constructed by concatenating all Text node children separated by spaces.

accessibilityTraits (iOS) #

Accessibility traits tell a person using VoiceOver what kind of element they have selected. Is this element a label? A button? A header? These questions are answered by accessibilityTraits.

To use, set the accessibilityTraits property to one of (or an array of) accessibility trait strings:

  • none Used when the element has no traits.
  • button Used when the element should be treated as a button.
  • link Used when the element should be treated as a link.
  • header Used when an element acts as a header for a content section (e.g. the title of a navigation bar).
  • search Used when the text field element should also be treated as a search field.
  • image Used when the element should be treated as an image. Can be combined with button or link, for example.
  • selected Used when the element is selected. For example, a selected row in a table or a selected button within a segmented control.
  • plays Used when the element plays its own sound when activated.
  • key Used when the element acts as a keyboard key.
  • text Used when the element should be treated as static text that cannot change.
  • summary Used when an element can be used to provide a quick summary of current conditions in the app when the app first launches. For example, when Weather first launches, the element with today's weather conditions is marked with this trait.
  • disabled Used when the control is not enabled and does not respond to user input.
  • frequentUpdates Used when the element frequently updates its label or value, but too often to send notifications. Allows an accessibility client to poll for changes. A stopwatch would be an example.
  • startsMedia Used when activating an element starts a media session (e.g. playing a movie, recording audio) that should not be interrupted by output from an assistive technology, like VoiceOver.
  • adjustable Used when an element can be "adjusted" (e.g. a slider).
  • allowsDirectInteraction Used when an element allows direct touch interaction for VoiceOver users (for example, a view representing a piano keyboard).
  • pageTurn Informs VoiceOver that it should scroll to the next page when it finishes reading the contents of the element.

onAccessibilityTap (iOS) #

Use this property to assign a custom function to be called when someone activates an accessible element by double tapping on it while it's selected.

onMagicTap (iOS) #

Assign this property to a custom function which will be called when someone performs the "magic tap" gesture, which is a double-tap with two fingers. A magic tap function should perform the most relevant action a user could take on a component. In the Phone app on iPhone, a magic tap answers a phone call, or ends the current one. If the selected element does not have an onMagicTap function, the system will traverse up the view hierarchy until it finds a view that does.

accessibilityComponentType (Android) #

In some cases, we also want to alert the end user of the type of selected component (i.e., that it is a “button”). If we were using native buttons, this would work automatically. Since we are using javascript, we need to provide a bit more context for TalkBack. To do so, you must specify the ‘accessibilityComponentType’ property for any UI component. For instances, we support ‘button’, ‘radiobutton_checked’ and ‘radiobutton_unchecked’ and so on.

<TouchableWithoutFeedback accessibilityComponentType=”button” onPress={this._onPress}> <View style={styles.button}> <Text style={styles.buttonText}>Press me!</Text> @@ -27,7 +26,7 @@ On the other hand, if view B contains a child view C a backgroundColor: 'yellow'}} importantForAccessibility=”no-hide-descendants”> <Text> Second layout </Text> </View> -</View>

In the above example, the yellow layout and its descendants are completely invisible to TalkBack and all other accessibility services. So we can easily use overlapping views with the same parent without confusing TalkBack.

Checking if a Screen Reader is Enabled #

The AccessibilityInfo API allows you to determine whether or not a screen reader is currently active. See the AccessibilityInfo documentation for details.

Sending Accessibility Events (Android) #

Sometimes it is useful to trigger an accessibility event on a UI component (i.e. when a custom view appears on a screen or a custom radio button has been selected). Native UIManager module exposes a method ‘sendAccessibilityEvent’ for this purpose. It takes two arguments: view tag and a type of an event.

_onPress: function() { +</View>

In the above example, the yellow layout and its descendants are completely invisible to TalkBack and all other accessibility services. So we can easily use overlapping views with the same parent without confusing TalkBack.

Sending Accessibility Events (Android) #

Sometimes it is useful to trigger an accessibility event on a UI component (i.e. when a custom view appears on a screen or a custom radio button has been selected). Native UIManager module exposes a method ‘sendAccessibilityEvent’ for this purpose. It takes two arguments: view tag and a type of an event.

_onPress: function() { this.state.radioButton = this.state.radioButton === “radiobutton_checked” ? “radiobutton_unchecked” : “radiobutton_checked”; if (this.state.radioButton === “radiobutton_checked”) { @@ -39,7 +38,7 @@ On the other hand, if view B contains a child view C a <CustomRadioButton accessibleComponentType={this.state.radioButton} - onPress={this._onPress}/>

In the above example we've created a custom radio button that now behaves like a native one. More specifically, TalkBack now correctly announces changes to the radio button selection.

Testing VoiceOver Support (iOS) #

To enable VoiceOver, go to the Settings app on your iOS device. Tap General, then Accessibility. There you will find many tools that people use to use to make their devices more usable, such as bolder text, increased contrast, and VoiceOver.

To enable VoiceOver, tap on VoiceOver under "Vision" and toggle the switch that appears at the top.

At the very bottom of the Accessibility settings, there is an "Accessibility Shortcut". You can use this to toggle VoiceOver by triple clicking the Home button.

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

\ No newline at end of file diff --git a/docs/actionsheetios.html b/docs/actionsheetios.html index 5a14a6b16b9..c47b85f7ae0 100644 --- a/docs/actionsheetios.html +++ b/docs/actionsheetios.html @@ -1,4 +1,4 @@ -ActionSheetIOS

ActionSheetIOS #

Methods #

static showActionSheetWithOptions(options, callback) #

Display an iOS action sheet. The options object must contain one or more +ActionSheetIOS

ActionSheetIOS #

Methods #

static showActionSheetWithOptions(options, callback) #

Display an iOS action sheet. The options object must contain one or more of:

  • options (array of strings) - a list of button titles (required)
  • cancelButtonIndex (int) - index of cancel button in options
  • destructiveButtonIndex (int) - index of destructive button in options
  • title (string) - a title to show above the action sheet
  • message (string) - a message to show below the title

static showShareActionSheetWithOptions(options, failureCallback, successCallback) #

Display the iOS share sheet. The options object should contain one or both of message and url and can additionally have a subject or excludedActivityTypes:

  • url (string) - a URL to share
  • message (string) - a message to share
  • subject (string) - a subject for the message
  • excludedActivityTypes (array) - the activities to exclude from the ActionSheet

NOTE: if url points to a local file, or is a base64-encoded @@ -204,7 +204,7 @@ exports.examples return <ShareScreenshotExample />; } } -];

\ No newline at end of file diff --git a/docs/activityindicator.html b/docs/activityindicator.html index 5fdc8afff75..1731884c5c6 100644 --- a/docs/activityindicator.html +++ b/docs/activityindicator.html @@ -1,5 +1,5 @@ -ActivityIndicator

ActivityIndicator #

Displays a circular loading indicator.

Props #

animating?: bool #

Whether to show the indicator (true, the default) or hide it (false).

color?: [object Object] #

The foreground color of the spinner (default is gray).

size?: [object Object], [object Object] #

Size of the indicator (default is 'small'). -Passing a number to the size prop is only supported on Android.

ioshidesWhenStopped?: bool #

Whether the indicator should hide when not animating (true by default).

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

Examples #

Edit on GitHub
'use strict'; +ActivityIndicator

ActivityIndicator #

Displays a circular loading indicator.

Props #

animating?: bool #

Whether to show the indicator (true, the default) or hide it (false).

color?: color #

The foreground color of the spinner (default is gray).

size?: enum('small', 'large'), number #

Size of the indicator (default is 'small'). +Passing a number to the size prop is only supported on Android.

ioshidesWhenStopped?: bool #

Whether the indicator should hide when not animating (true by default).

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

Examples #

Edit on GitHub
'use strict'; import React, { Component } from 'react'; import { ActivityIndicator, StyleSheet, View } from 'react-native'; @@ -196,6 +196,6 @@ const styles = StyleSheet \ No newline at end of file diff --git a/docs/adsupportios.html b/docs/adsupportios.html index cdc870cca42..e2d796129f4 100644 --- a/docs/adsupportios.html +++ b/docs/adsupportios.html @@ -1,4 +1,4 @@ -AdSupportIOS

AdSupportIOS #

Methods #

static getAdvertisingId(onSuccess, onFailure) #

static getAdvertisingTrackingEnabled(onSuccess, onFailure) #

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

Examples #

Edit on GitHub
'use strict'; +AdSupportIOS

AdSupportIOS #

Methods #

static getAdvertisingId(onSuccess, onFailure) #

static getAdvertisingTrackingEnabled(onSuccess, onFailure) #

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'); @@ -100,6 +100,6 @@ class AdSupportIOSExample extends \ No newline at end of file diff --git a/docs/alert.html b/docs/alert.html index 9aabfec352c..786c35baec6 100644 --- a/docs/alert.html +++ b/docs/alert.html @@ -1,14 +1,12 @@ -Alert

Alert #

Launches an alert dialog with the specified title and message.

Optionally provide a list of buttons. Tapping any button will fire the +Alert

Alert #

Launches an alert dialog with the specified title and message.

Optionally provide a list of buttons. Tapping any button will fire the respective onPress callback and dismiss the alert. By default, the only button will be an 'OK' button.

This is an API that works both on iOS and Android and can show static alerts. To show an alert that prompts the user to enter some information, see AlertIOS; entering text in an alert is common on iOS only.

iOS #

On iOS you can specify any number of buttons. Each button can optionally specify a style, which is one of 'default', 'cancel' or 'destructive'.

Android #

On Android at most three buttons can be specified. Android has a concept -of a neutral, negative and a positive button:

  • If you specify one button, it will be the 'positive' one (such as 'OK')
  • Two buttons mean 'negative', 'positive' (such as 'Cancel', 'OK')
  • Three buttons mean 'neutral', 'negative', 'positive' (such as 'Later', 'Cancel', 'OK')

By default alerts on Android can be dismissed by tapping outside of the alert -box. This event can be handled by providing an optional options parameter, -with an onDismiss callback property { onDismiss: () => {} }.

Alternatively, the dismissing behavior can be disabled altogether by providing -an optional options parameter with the cancelable property set to false -i.e. { cancelable: false }

Example usage:

// Works on both iOS and Android +of a neutral, negative and a positive button:

  • If you specify one button, it will be the 'positive' one (such as 'OK')
  • Two buttons mean 'negative', 'positive' (such as 'Cancel', 'OK')
  • Three buttons mean 'neutral', 'negative', 'positive' (such as 'Later', 'Cancel', 'OK')

Note that by default alerts on Android can be dismissed by clicking outside of their alert box. +To prevent this behavior, you can provide +an optional options parameter { cancelable: false } to the Alert method.

Example usage:

// Works on both iOS and Android Alert.alert( 'Alert Title', 'My Alert Msg', @@ -169,6 +167,6 @@ module.exports \ No newline at end of file diff --git a/docs/alertios.html b/docs/alertios.html index 461975a8902..64598c0a33d 100644 --- a/docs/alertios.html +++ b/docs/alertios.html @@ -1,4 +1,4 @@ -AlertIOS

AlertIOS #

AlertIOS provides functionality to create an iOS alert dialog with a +AlertIOS

AlertIOS #

AlertIOS provides functionality to create an iOS alert dialog with a message or create a prompt for user input.

Creating an iOS alert:

AlertIOS.alert( 'Sync Complete', 'All your data are belong to us.' @@ -233,6 +233,6 @@ class PromptOptions extends \ No newline at end of file diff --git a/docs/android-building-from-source.html b/docs/android-building-from-source.html index 5a8e3021cac..03e9f00823f 100644 --- a/docs/android-building-from-source.html +++ b/docs/android-building-from-source.html @@ -1,4 +1,4 @@ -Building React Native from source

Building React Native from source #

You will need to build React Native from source if you want to work on a new feature/bug fix, try out the latest features which are not released yet, or maintain your own fork with patches that cannot be merged to the core.

Prerequisites #

Assuming you have the Android SDK installed, run android to open the Android SDK Manager.

Make sure you have the following installed:

  1. Android SDK version 23 (compileSdkVersion in build.gradle)
  2. SDK build tools version 23.0.1 (buildToolsVersion in build.gradle)
  3. Android Support Repository >= 17 (for Android Support Library)
  4. Android NDK (download links and installation instructions below)

Point Gradle to your Android SDK: #

Step 1: Set environment variables through your local shell.

Note: Files may vary based on shell flavor. See below for examples from common shells.

  • bash: .bash_profile or .bashrc
  • zsh: .zprofile or .zshrc
  • ksh: .profile or $ENV

Example:

export ANDROID_SDK=/Users/your_unix_name/android-sdk-macosx +Building React Native from source

Building React Native from source #

You will need to build React Native from source if you want to work on a new feature/bug fix, try out the latest features which are not released yet, or maintain your own fork with patches that cannot be merged to the core.

Prerequisites #

Assuming you have the Android SDK installed, run android to open the Android SDK Manager.

Make sure you have the following installed:

  1. Android SDK version 23 (compileSdkVersion in build.gradle)
  2. SDK build tools version 23.0.1 (buildToolsVersion in build.gradle)
  3. Android Support Repository >= 17 (for Android Support Library)
  4. Android NDK (download links and installation instructions below)

Point Gradle to your Android SDK: #

Step 1: Set environment variables through your local shell.

Note: Files may vary based on shell flavor. See below for examples from common shells.

  • bash: .bash_profile or .bashrc
  • zsh: .zprofile or .zshrc
  • ksh: .profile or $ENV

Example:

export ANDROID_SDK=/Users/your_unix_name/android-sdk-macosx export ANDROID_NDK=/Users/your_unix_name/android-ndk/android-ndk-r10e

Step 2: Create a local.properties file in the android directory of your react-native app with the following contents:

Example:

sdk.dir=/Users/your_unix_name/android-sdk-macosx ndk.dir=/Users/your_unix_name/android-ndk/android-ndk-r10e

Download links for Android NDK #

  1. Mac OS (64-bit) - http://dl.google.com/android/repository/android-ndk-r10e-darwin-x86_64.zip
  2. Linux (64-bit) - http://dl.google.com/android/repository/android-ndk-r10e-linux-x86_64.zip
  3. Windows (64-bit) - http://dl.google.com/android/repository/android-ndk-r10e-windows-x86_64.zip
  4. Windows (32-bit) - http://dl.google.com/android/repository/android-ndk-r10e-windows-x86.zip

You can find further instructions on the official page.

Building the source #

1. Installing the fork #

First, you need to install react-native from your fork. For example, to install the master branch from the official repo, run the following:

npm install --save github:facebook/react-native#master

Alternatively, you can clone the repo to your node_modules directory and run npm install inside the cloned repo.

2. Adding gradle dependencies #

Add gradle-download-task as dependency in android/build.gradle:

... dependencies { @@ -44,6 +44,6 @@ dependencies { apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.43" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.42" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/android-ui-performance.html b/docs/android-ui-performance.html index e65c145cf08..34cc423c798 100644 --- a/docs/android-ui-performance.html +++ b/docs/android-ui-performance.html @@ -1,19 +1 @@ -Profiling Android UI Performance

Profiling Android UI Performance #

We try our best to deliver buttery-smooth UI performance by default, but sometimes that just isn't possible. Remember, Android supports 10k+ different phones and is generalized to support software rendering: the framework architecture and need to generalize across many hardware targets unfortunately means you get less for free relative to iOS. But sometimes, there are things you can improve (and many times it's not native code's fault at all!).

The first step for debugging this jank is to answer the fundamental question of where your time is being spent during each 16ms frame. For that, we'll be using a standard Android profiling tool called systrace. But first...

Make sure that JS dev mode is OFF!

You should see __DEV__ === false, development-level warning are OFF, performance optimizations are ON in your application logs (which you can view using adb logcat)

Profiling with Systrace #

Systrace is a standard Android marker-based profiling tool (and is installed when you install the Android platform-tools package). Profiled code blocks are surrounded by markers start/end markers which are then visualized in a colorful chart format. Both the Android SDK and React Native framework provide standard markers that you can visualize.

Collecting a trace #

NOTE:

Systrace support was added in react-native v0.15. You will need to build with that version to collect a trace.

First, connect a device that exhibits the stuttering you want to investigate to your computer via USB and get it to the point right before the navigation/animation you want to profile. Run systrace as follows

$ <path_to_android_sdk>/platform-tools/systrace/systrace.py --time=10 -o trace.html sched gfx view -a <your_package_name>

A quick breakdown of this command:

  • time is the length of time the trace will be collected in seconds
  • sched, gfx, and view are the android SDK tags (collections of markers) we care about: sched gives you information about what's running on each core of your phone, gfx gives you graphics info such as frame boundaries, and view gives you information about measure, layout, and draw passes
  • -a <your_package_name> enables app-specific markers, specifically the ones built into the React Native framework. your_package_name can be found in the AndroidManifest.xml of your app and looks like com.example.app

Once the trace starts collecting, perform the animation or interaction you care about. At the end of the trace, systrace will give you a link to the trace which you can open in your browser.

Reading the trace #

After opening the trace in your browser (preferably Chrome), you should see something like this:

Example

If your trace .html file isn't opening correctly, check your browser console for the following:

ObjectObserveError

Since Object.observe was deprecated in recent browsers, you may have to open the file from the Google Chrome Tracing tool. You can do so by:

  • Opening tab in chrome chrome://tracing
  • Selecting load
  • Selecting the html file generated from the previous command.

HINT: Use the WASD keys to strafe and zoom

Enable VSync highlighting #

The first thing you should do is highlight the 16ms frame boundaries if you haven't already done that. Check this checkbox at the top right of the screen:

Enable VSync Highlighting

You should see zebra stripes as in the screenshot above. If you don't, try profiling on a different device: Samsung has been known to have issues displaying vsyncs while the Nexus series is generally pretty reliable.

Find your process #

Scroll until you see (part of) the name of your package. In this case, I was profiling com.facebook.adsmanager, which shows up as book.adsmanager because of silly thread name limits in the kernel.

On the left side, you'll see a set of threads which correspond to the timeline rows on the right. There are three/four threads we care about for our purposes: the UI thread (which has your package name or the name UI Thread), mqt_js and mqt_native_modules. If you're running on Android 5+, we also care about the Render Thread.

UI Thread #

This is where standard android measure/layout/draw happens. The thread name on the right will be your package name (in my case book.adsmanager) or UI Thread. The events that you see on this thread should look something like this and have to do with Choreographer, traversals, and DispatchUI:

UI Thread Example

JS Thread #

This is where JS is executed. The thread name will be either mqt_js or <...> depending on how cooperative the kernel on your device is being. To identify it if it doesn't have a name, look for things like JSCall, Bridge.executeJSCall, etc:

JS Thread Example

Native Modules Thread #

This is where native module calls (e.g. the UIManager) are executed. The thread name will be either mqt_native_modules or <...>. To identify it in the latter case, look for things like NativeCall, callJavaModuleMethod, and onBatchComplete:

Native Modules Thread Example

Bonus: Render Thread #

If you're using Android L (5.0) and up, you will also have a render thread in your application. This thread generates the actual OpenGL commands used to draw your UI. The thread name will be either RenderThread or <...>. To identify it in the latter case, look for things like DrawFrame and queueBuffer:

Render Thread Example

Identifying a culprit #

A smooth animation should look something like the following:

Smooth Animation

Each change in color is a frame -- remember that in order to display a frame, all our UI work needs to be done by the end of that 16ms period. Notice that no thread is working close to the frame boundary. An application rendering like this is rendering at 60FPS.

If you noticed chop, however, you might see something like this:

Choppy Animation from JS

Notice that the JS thread is executing basically all the time, and across frame boundaries! This app is not rendering at 60FPS. In this case, the problem lies in JS.

You might also see something like this:

Choppy Animation from UI

In this case, the UI and render threads are the ones that have work crossing frame boundaries. The UI that we're trying to render on each frame is requiring too much work to be done. In this case, the problem lies in the native views being rendered.

At this point, you'll have some very helpful information to inform your next steps.

JS Issues #

If you identified a JS problem, look for clues in the specific JS that you're executing. In the scenario above, we see RCTEventEmitter being called multiple times per frame. Here's a zoom-in of the JS thread from the trace above:

Too much JS

This doesn't seem right. Why is it being called so often? Are they actually different events? The answers to these questions will probably depend on your product code. And many times, you'll want to look into shouldComponentUpdate.

TODO: Add more tools for profiling JS

Native UI Issues #

If you identified a native UI problem, there are usually two scenarios:

  1. the UI you're trying to draw each frame involves to much work on the GPU, or
  2. You're constructing new UI during the animation/interaction (e.g. loading in new content during a scroll).

Too much GPU work #

In the first scenario, you'll see a trace that has the UI thread and/or Render Thread looking like this:

Overloaded GPU

Notice the long amount of time spent in DrawFrame that crosses frame boundaries. This is time spent waiting for the GPU to drain its command buffer from the previous frame.

To mitigate this, you should:

  • investigate using renderToHardwareTextureAndroid for complex, static content that is being animated/transformed (e.g. the Navigator slide/alpha animations)
  • make sure that you are not using needsOffscreenAlphaCompositing, which is disabled by default, as it greatly increases the per-frame load on the GPU in most cases.

If these don't help and you want to dig deeper into what the GPU is actually doing, you can check out Tracer for OpenGL ES.

Creating new views on the UI thread #

In the second scenario, you'll see something more like this:

Creating Views

Notice that first the JS thread thinks for a bit, then you see some work done on the native modules thread, followed by an expensive traversal on the UI thread.

There isn't an easy way to mitigate this unless you're able to postpone creating new UI until after the interaction, or you are able to simplify the UI you're creating. The react native team is working on a infrastructure level solution for this that will allow new UI to be created and configured off the main thread, allowing the interaction to continue smoothly.

Still stuck? #

If you are confused or stuck, please post ask on Stack Overflow with the react-native tag. If you are unable to get a response there, or find an issue with a core component, please File a Github issue.

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

\ No newline at end of file +Redirecting...

Redirecting...

Click here if you are not redirected. \ No newline at end of file diff --git a/docs/animated.html b/docs/animated.html index 2ef2eacaced..5112fd186f0 100644 --- a/docs/animated.html +++ b/docs/animated.html @@ -1,75 +1,67 @@ -Animated

Animated #

The Animated library is designed to make animations fluid, powerful, and -easy to build and maintain. Animated focuses on declarative relationships -between inputs and outputs, with configurable transforms in between, and -simple start/stop methods to control time-based animation execution.

The simplest workflow for creating an animation is to to create an -Animated.Value, hook it up to one or more style attributes of an animated -component, and then drive updates via animations using Animated.timing():

Animated.timing( // Animate value over time - this.state.fadeAnim, // The value to drive - { - toValue: 1, // Animate to final value of 1 - } -).start(); // Start the animation

Refer to the Animations guide to see -additional examples of Animated in action.

Overview #

There are two value types you can use with Animated:

Animated.Value can bind to style properties or other props, and can be -interpolated as well. A single Animated.Value can drive any number of -properties.

Configuring animations #

Animated provides three types of animation types. Each animation type -provides a particular animation curve that controls how your values animate -from their initial value to the final value:

In most cases, you will be using timing(). By default, it uses a symmetric -easeInOut curve that conveys the gradual acceleration of an object to full -speed and concludes by gradually decelerating to a stop.

Working with animations #

Animations are started by calling start() on your animation. start() -takes a completion callback that will be called when the animation is done. -If the animation finished running normally, the completion callback will be -invoked with {finished: true}. If the animation is done because stop() -was called on it before it could finish (e.g. because it was interrupted by a -gesture or another animation), then it will receive {finished: false}.

Using the native driver #

By using the native driver, we send everything about the animation to native -before starting the animation, allowing native code to perform the animation -on the UI thread without having to go through the bridge on every frame. -Once the animation has started, the JS thread can be blocked without -affecting the animation.

You can use the native driver by specifying useNativeDriver: true in your -animation configuration. See the -Animations guide to learn -more.

Animatable components #

Only animatable components can be animated. These special components do the -magic of binding the animated values to the properties, and do targeted -native updates to avoid the cost of the react render and reconciliation -process on every frame. They also handle cleanup on unmount so they are safe -by default.

Animated exports the following animatable components using the above -wrapper:

  • Animated.Image
  • Animated.ScrollView
  • Animated.Text
  • Animated.View

Composing animations #

Animations can also be combined in complex ways using composition functions:

Animations can also be chained together simply by setting the toValue of -one animation to be another Animated.Value. See -Tracking dynamic values in -the Animations guide.

By default, if one animation is stopped or interrupted, then all other -animations in the group are also stopped.

Combining animated values #

You can combine two animated values via addition, multiplication, division, -or modulo to make a new animated value:

Interpolation #

The interpolate() function allows input ranges to map to different output -ranges. By default, it will extrapolate the curve beyond the ranges given, -but you can also have it clamp the output value. It uses lineal interpolation -by default but also supports easing functions.

Read more about interpolation in the -Animation guide.

Handling gestures and other events #

Gestures, like panning or scrolling, and other events can map directly to -animated values using Animated.event(). This is done with a structured map -syntax so that values can be extracted from complex event objects. The first -level is an array to allow mapping across multiple args, and that array -contains nested objects.

For example, when working with horizontal scrolling gestures, you would do -the following in order to map event.nativeEvent.contentOffset.x to -scrollX (an Animated.Value):

onScroll={Animated.event( - // scrollX = e.nativeEvent.contentOffset.x - [{ nativeEvent: { - contentOffset: { - x: scrollX - } - } - }] - )}

Methods #

static decay(value, config) #

Animates a value from an initial velocity to zero based on a decay -coefficient.

Config is an object that may have the following options:

  • velocity: Initial velocity. Required.
  • deceleration: Rate of decay. Default 0.997.
  • useNativeDriver: Uses the native driver when true. Default false.

static timing(value, config) #

Animates a value along a timed easing curve. The -Easing module has tons of predefined curves, or you -can use your own function.

Config is an object that may have the following options:

  • duration: Length of animation (milliseconds). Default 500.
  • easing: Easing function to define curve. -Default is Easing.inOut(Easing.ease).
  • delay: Start the animation after delay (milliseconds). Default 0.
  • useNativeDriver: Uses the native driver when true. Default false.

static spring(value, config) #

Spring animation based on Rebound and -Origami. Tracks velocity state to -create fluid motions as the toValue updates, and can be chained together.

Config is an object that may have the following options:

  • friction: Controls "bounciness"/overshoot. Default 7.
  • tension: Controls speed. Default 40.
  • useNativeDriver: Uses the native driver when true. Default false.

static add(a, b) #

Creates a new Animated value composed from two Animated values added +Animated

Animated #

Animations are an important part of modern UX, and the Animated +library is designed to make them fluid, powerful, and easy to build and +maintain.

The simplest workflow is to create an Animated.Value, hook it up to one or +more style attributes of an animated component, and then drive updates either +via animations, such as Animated.timing, or by hooking into gestures like +panning or scrolling via Animated.event. Animated.Value can also bind to +props other than style, and can be interpolated as well. Here is a basic +example of a container view that will fade in when it's mounted:

class FadeInView extends React.Component { + constructor(props) { + super(props); + this.state = { + fadeAnim: new Animated.Value(0), // init opacity 0 + }; + } + componentDidMount() { + Animated.timing( // Uses easing functions + this.state.fadeAnim, // The value to drive + {toValue: 1} // Configuration + ).start(); // Don't forget start! + } + render() { + return ( + <Animated.View // Special animatable View + style={{opacity: this.state.fadeAnim}}> // Binds + {this.props.children} + </Animated.View> + ); + } + }

Note that only animatable components can be animated. View, Text, and +Image are already provided, and you can create custom ones with +createAnimatedComponent. These special components do the magic of binding +the animated values to the properties, and do targeted native updates to +avoid the cost of the react render and reconciliation process on every frame. +They also handle cleanup on unmount so they are safe by default.

Animations are heavily configurable. Custom and pre-defined easing +functions, delays, durations, decay factors, spring constants, and more can +all be tweaked depending on the type of animation.

A single Animated.Value can drive any number of properties, and each +property can be run through an interpolation first. An interpolation maps +input ranges to output ranges, typically using a linear interpolation but +also supports easing functions. By default, it will extrapolate the curve +beyond the ranges given, but you can also have it clamp the output value.

For example, you may want to think about your Animated.Value as going from +0 to 1, but animate the position from 150px to 0px and the opacity from 0 to +1. This can easily be done by modifying style in the example above like so:

style={{ + opacity: this.state.fadeAnim, // Binds directly + transform: [{ + translateY: this.state.fadeAnim.interpolate({ + inputRange: [0, 1], + outputRange: [150, 0] // 0 : 150, 0.5 : 75, 1 : 0 + }), + }], + }}>

Animations can also be combined in complex ways using composition functions +such as sequence and parallel, and can also be chained together simply +by setting the toValue of one animation to be another Animated.Value.

Animated.ValueXY is handy for 2D animations, like panning, and there are +other helpful additions like setOffset and getLayout to aid with typical +interaction patterns, like drag-and-drop.

You can see more example usage in AnimationExample.js, the Gratuitous +Animation App, and Animations documentation guide.

Note that Animated is designed to be fully serializable so that animations +can be run in a high performance way, independent of the normal JavaScript +event loop. This does influence the API, so keep that in mind when it seems a +little trickier to do something compared to a fully synchronous system. +Checkout Animated.Value.addListener as a way to work around some of these +limitations, but use it sparingly since it might have performance +implications in the future.

Methods #

static decay(value, config) #

Animates a value from an initial velocity to zero based on a decay +coefficient.

static timing(value, config) #

Animates a value along a timed easing curve. The Easing module has tons +of pre-defined curves, or you can use your own function.

static spring(value, config) #

Spring animation based on Rebound and Origami. Tracks velocity state to +create fluid motions as the toValue updates, and can be chained together.

static add(a, b) #

Creates a new Animated value composed from two Animated values added together.

static divide(a, b) #

Creates a new Animated value composed by dividing the first Animated value by the second Animated value.

static multiply(a, b) #

Creates a new Animated value composed from two Animated values multiplied together.

static modulo(a, modulus) #

Creates a new Animated value that is the (non-negative) modulo of the @@ -82,8 +74,8 @@ before starting the next. If the current running animation is stopped, no following animations will be started.

static parallel(animations, config?) #

Starts an array of animations all at the same time. By default, if one of the animations is stopped, they will all be stopped. You can override this with the stopTogether flag.

static stagger(time, animations) #

Array of animations may run in parallel (overlap), but are started in -sequence with successive delays. Nice for doing trailing effects.

static event(argMapping, config?) #

Takes an array of mappings and extracts values from each arg accordingly, -then calls setValue on the mapped outputs. e.g.

onScroll={Animated.event( +sequence with successive delays. Nice for doing trailing effects.

static event(argMapping, config?) #

Takes an array of mappings and extracts values from each arg accordingly, + then calls setValue on the mapped outputs. e.g.

onScroll={Animated.event( [{nativeEvent: {contentOffset: {x: this._scrollX}}}] {listener}, // Optional async listener ) @@ -91,8 +83,8 @@ then calls setValue on the mapped outputs. e.g.

: Animated.event([ null, // raw event arg ignored {dx: this._panX}, // gestureState arg - ]),

Config is an object that may have the following options:

  • listener: Optional async listener.
  • useNativeDriver: Uses the native driver when true. Default false.

static createAnimatedComponent(Component) #

Make any React component Animatable. Used to create Animated.View, etc.

Properties #

Value: [object Object] #

Standard value class for driving animations. Typically initialized with -new Animated.Value(0);

See also AnimatedValue.

ValueXY: [object Object] #

2D value class for driving 2D animations, such as pan gestures.

See also AnimatedValueXY.

Interpolation: [object Object] #

exported to use the Interpolation type in flow

See also AnimatedInterpolation.

class AnimatedValue #

    Standard value for driving animations. One Animated.Value can drive + ]),

static createAnimatedComponent(Component) #

Make any React component Animatable. Used to create Animated.View, etc.

Properties #

Value: AnimatedValue #

Standard value class for driving animations. Typically initialized with +new Animated.Value(0);

ValueXY: AnimatedValueXY #

2D value class for driving 2D animations, such as pan gestures.

class AnimatedValue #

    Standard value for driving animations. One Animated.Value can drive multiple properties in a synchronized fashion, but can only be driven by one mechanism at a time. Using a new mechanism (e.g. starting a new animation, or calling setValue) will stop any previous ones.

    Methods #

    constructor(value) #

    setValue(value) #

    Directly set the value. This will stop any animations running on the value @@ -108,7 +100,7 @@ state to match the animation position with layout.

    animate(animation, callback) #

    Typically only used internally, but could be used by a custom Animation class.

    stopTracking() #

    Typically only used internally.

    track(tracking) #

    Typically only used internally.

class AnimatedValueXY #

    2D Value for driving 2D animations, such as pan gestures. Almost identical API to normal Animated.Value, but multiplexed. Contains two regular -Animated.Values under the hood.

    Example #

    class DraggableView extends React.Component { +Animated.Values under the hood. Example:

    class DraggableView extends React.Component { constructor(props) { super(props); this.state = { @@ -137,9 +129,9 @@ API to normal Animated.Value, but multiplexed. Contains two regula </Animated.View> ); } - }

    Methods #

    constructor(valueIn?) #

    setValue(value) #

    setOffset(offset) #

    flattenOffset() #

    extractOffset() #

    stopAnimation(callback?) #

    addListener(callback) #

    removeListener(id) #

    removeAllListeners() #

    getLayout() #

    Converts {x, y} into {left, top} for use in style, e.g.

    style={this.state.anim.getLayout()}

    getTranslateTransform() #

    Converts {x, y} into a useable translation transform, e.g.

    style={{ + }

    Methods #

    constructor(valueIn?) #

    setValue(value) #

    setOffset(offset) #

    flattenOffset() #

    stopAnimation(callback?) #

    addListener(callback) #

    removeListener(id) #

    removeAllListeners() #

    getLayout() #

    Converts {x, y} into {left, top} for use in style, e.g.

    style={this.state.anim.getLayout()}

    getTranslateTransform() #

    Converts {x, y} into a useable translation transform, e.g.

    style={{ transform: this.state.anim.getTranslateTransform() - }}

class AnimatedInterpolation #

    Methods #

    constructor(parent, config) #

    interpolate(config) #

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

Examples #

Edit on GitHub
'use strict'; + }}

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'); @@ -375,6 +367,6 @@ exports.examples \ No newline at end of file diff --git a/docs/animations.html b/docs/animations.html index d8a4de369b1..2854216bcdd 100644 --- a/docs/animations.html +++ b/docs/animations.html @@ -1,71 +1,64 @@ -Animations

Animations #

Animations are very important to create a great user experience. -Stationary objects must overcome inertia as they start moving. -Objects in motion have momentum and rarely come to a stop immediately. -Animations allow you to convey physically believable motion in your interface.

React Native provides two complementary animation systems: -Animated for granular and interactive control of specific values, and -LayoutAnimation for animated global layout transactions.

Animated API #

The Animated API is designed to make it very easy to concisely express a wide variety of interesting animation and interaction patterns in a very performant way. -Animated focuses on declarative relationships between inputs and outputs, with configurable transforms in between, and simple start/stop methods to control time-based animation execution.

Animated exports four animatable component types: View, Text, Image, and ScrollView, but you can also create your own using Animated.createAnimatedComponent().

For example, a container view that fades in when it is mounted may look like this:

// FadeInView.js -import React, { Component } from 'react'; -import { - Animated, -} from 'react-native'; - -class FadeInView extends Component { +Animations

Animations #

Fluid, meaningful animations are essential to the mobile user experience. Like +everything in React Native, Animation APIs for React Native are currently under +development, but have started to coalesce around two complementary systems: +LayoutAnimation for animated global layout transactions, and Animated for +more granular and interactive control of specific values.

Animated #

The Animated library is designed to make it very easy to concisely express a +wide variety of interesting animation and interaction patterns in a very +performant way. Animated focuses on declarative relationships between inputs +and outputs, with configurable transforms in between, and simple start/stop +methods to control time-based animation execution. For example, a complete +component with a simple spring bounce on mount looks like this:

class Playground extends React.Component { constructor(props) { super(props); this.state = { - fadeAnim: new Animated.Value(0), // Initial value for opacity: 0 - }; + bounceValue: new Animated.Value(0), + }; } - componentDidMount() { - Animated.timing( // Animate over time - this.state.fadeAnim, // The animated value to drive - { - toValue: 1, // Animate to opacity: 1, or fully opaque - } - ).start(); // Starts the animation - } render() { return ( - <Animated.View // Special animatable View - style={{ - ...this.props.style, - opacity: this.state.fadeAnim, // Bind opacity to animated value - }} - > - {this.props.children} - </Animated.View> + <Animated.Image // Base: Image, Text, View + source={{uri: 'http://i.imgur.com/XMKOH81.jpg'}} + style={{ + flex: 1, + transform: [ // `transform` is an ordered array + {scale: this.state.bounceValue}, // Map `bounceValue` to `scale` + ] + }} + /> ); } -} - -module.exports = FadeInView;

You can then use your FadeInView in place of a View in your components, like so:

render() { - return ( - <FadeInView style={{width: 250, height: 50, backgroundColor: 'powderblue'}}> - <Text style={{fontSize: 28, textAlign: 'center', margin: 10}}>Fading in</Text> - </FadeInView> - ) -}

FadeInView

Let's break down what's happening here. -In the FadeInView constructor, a new Animated.Value called fadeAnim is initialized as part of state. -The opacity property on the View is mapped to this animated value. -Behind the scenes, the numeric value is extracted and used to set opacity.

When the component mounts, the opacity is set to 0. -Then, an easing animation is started on the fadeAnim animated value, -which will update all of its dependent mappings (in this case, just the opacity) on each frame as the value animates to the final value of 1.

This is done in an optimized way that is faster than calling setState and re-rendering.
Because the entire configuration is declarative, we will be able to implement further optimizations that serialize the configuration and runs the animation on a high-priority thread.

Configuring animations #

Animations are heavily configurable. Custom and predefined easing functions, delays, durations, decay factors, spring constants, and more can all be tweaked depending on the type of animation.

Animated provides several animation types, the most commonly used one being Animated.timing(). -It supports animating a value over time using one of various predefined easing functions, or you can use your own. -Easing functions are typically used in animation to convey gradual acceleration and deceleration of objects.

By default, timing will use a easeInOut curve that conveys gradual acceleration to full speed and concludes by gradually decelerating to a stop. -You can specify a different easing function by passing a easing parameter. -Custom duration or even a delay before the animation starts is also supported.

For example, if we want to create a 2-second long animation of an object that slightly backs up before moving to its final position:

Animated.timing( - this.state.xPosition, - { - toValue: 100, - easing: Easing.back, - duration: 2000, - } -).start();

Take a look at the Configuring animations section of the Animated API reference to learn more about all the config parameters supported by the built-in animations.

Composing animations #

Animations can be combined and played in sequence or in parallel. -Sequential animations can play immediately after the previous animation has finished, -or they can start after a specified delay. -The Animated API provides several methods, such as sequence() and delay(), -each of which simply take an array of animations to execute and automatically calls start()/stop() as needed.

For example, the following animation coasts to a stop, then it springs back while twirling in parallel:

Animated.sequence([ // decay, then spring to start and twirl + componentDidMount() { + this.state.bounceValue.setValue(1.5); // Start large + Animated.spring( // Base: spring, decay, timing + this.state.bounceValue, // Animate `bounceValue` + { + toValue: 0.8, // Animate to smaller size + friction: 1, // Bouncier spring + } + ).start(); // Start the animation + } +}

bounceValue is initialized as part of state in the constructor, and mapped +to the scale transform on the image. Behind the scenes, the numeric value is +extracted and used to set scale. When the component mounts, the scale is set to +1.5 and then a spring animation is started on bounceValue which will update +all of its dependent mappings on each frame as the spring animates (in this +case, just the scale). This is done in an optimized way that is faster than +calling setState and re-rendering. Because the entire configuration is +declarative, we will be able to implement further optimizations that serialize +the configuration and runs the animation on a high-priority thread.

Core API #

Most everything you need hangs directly off the Animated module. This +includes two value types, Value for single values and ValueXY for vectors, +three animation types, spring, decay, and timing, and three component +types, View, Text, and Image. You can make any other component animated with +Animated.createAnimatedComponent.

The three animation types can be used to create almost any animation curve you +want because each can be customized:

  • spring: Simple single-spring physics model that matches Origami.
    • friction: Controls "bounciness"/overshoot. Default 7.
    • tension: Controls speed. Default 40.
  • decay: Starts with an initial velocity and gradually slows to a stop.
    • velocity: Initial velocity. Required.
    • deceleration: Rate of decay. Default 0.997.
  • timing: Maps time range to easing value.
    • duration: Length of animation (milliseconds). Default 500.
    • easing: Easing function to define curve. See Easing module for several +predefined functions. iOS default is Easing.inOut(Easing.ease).
    • delay: Start the animation after delay (milliseconds). Default 0.

Animations are started by calling start. start takes a completion callback +that will be called when the animation is done. If the animation is done +because it finished running normally, the completion callback will be invoked +with {finished: true}, but if the animation is done because stop was called +on it before it could finish (e.g. because it was interrupted by a gesture or +another animation), then it will receive {finished: false}.

Composing Animations #

Animations can also be composed with parallel, sequence, stagger, and +delay, each of which simply take an array of animations to execute and +automatically calls start/stop as appropriate. For example:

Animated.sequence([ // spring to start and twirl after decay finishes Animated.decay(position, { // coast to a stop velocity: {x: gestureState.vx, y: gestureState.vy}, // velocity from gesture release deceleration: 0.997, @@ -78,117 +71,78 @@ each of which simply take an array of animations to execute and automatically ca toValue: 360, }), ]), -]).start(); // start the sequence group

If one animation is stopped or interrupted, then all other animations in the group are also stopped. -Animated.parallel has a stopTogether option that can be set to false to disable this.

You can find a full list of composition methods in the Composing animations section of the Animated API reference.

Combining animated values #

You can combine two animated values via addition, multiplication, division, or modulo to make a new animated value.

There are some cases where an animated value needs to invert another animated value for calculation. -An example is inverting a scale (2x --> 0.5x):

const a = Animated.Value(1); -const b = Animated.divide(1, a); - -Animated.spring(a, { - toValue: 2, -}).start();

Interpolation #

Each property can be run through an interpolation first. -An interpolation maps input ranges to output ranges, -typically using a linear interpolation but also supports easing functions. -By default, it will extrapolate the curve beyond the ranges given, but you can also have it clamp the output value.

A simple mapping to convert a 0-1 range to a 0-100 range would be:

value.interpolate({ +]).start(); // start the sequence group

By default, if one animation is stopped or interrupted, then all other +animations in the group are also stopped. Parallel has a stopTogether option +that can be set to false to disable this.

Interpolation #

Another powerful part of the Animated API is the interpolate function. It +allows input ranges to map to different output ranges. For example, a simple +mapping to convert a 0-1 range to a 0-100 range would be

value.interpolate({ inputRange: [0, 1], outputRange: [0, 100], -});

For example, you may want to think about your Animated.Value as going from 0 to 1, -but animate the position from 150px to 0px and the opacity from 0 to 1. -This can easily be done by modifying style from the example above like so:

style={{ - opacity: this.state.fadeAnim, // Binds directly - transform: [{ - translateY: this.state.fadeAnim.interpolate({ - inputRange: [0, 1], - outputRange: [150, 0] // 0 : 150, 0.5 : 75, 1 : 0 - }), - }], - }}

interpolate() supports multiple range segments as well, which is handy for defining dead zones and other handy tricks. -For example, to get an negation relationship at -300 that goes to 0 at -100, then back up to 1 at 0, and then back down to zero at 100 followed by a dead-zone that remains at 0 for everything beyond that, you could do:

value.interpolate({ +});

interpolate supports multiple range segments as well, which is handy for +defining dead zones and other handy tricks. For example, to get an negation +relationship at -300 that goes to 0 at -100, then back up to 1 at 0, and then +back down to zero at 100 followed by a dead-zone that remains at 0 for +everything beyond that, you could do:

value.interpolate({ inputRange: [-300, -100, 0, 100, 101], outputRange: [300, 0, 1, 0, 0], -});

Which would map like so:

Input | Output -------|------- - -400| 450 - -300| 300 - -200| 150 - -100| 0 - -50| 0.5 - 0| 1 - 50| 0.5 - 100| 0 - 101| 0 - 200| 0

interpolate() also supports mapping to strings, allowing you to animate colors as well as values with units. For example, if you wanted to animate a rotation you could do:

value.interpolate({ +});

Which would map like so:

InputOutput
-400450
-300300
-200150
-1000
-500.5
01
500.5
1000
1010
2000

interpolate also supports mapping to strings, allowing you to animate colors as well as values with units. For example, if you wanted to animate a rotation you could do:

value.interpolate({ inputRange: [0, 360], outputRange: ['0deg', '360deg'] -})

interpolate() also supports arbitrary easing functions, many of which are already implemented in the -Easing module. -interpolate() also has configurable behavior for extrapolating the outputRange. -You can set the extrapolation by setting the extrapolate, extrapolateLeft, or extrapolateRight options. -The default value is extend but you can use clamp to prevent the output value from exceeding outputRange.

Tracking dynamic values #

Animated values can also track other values. -Just set the toValue of an animation to another animated value instead of a plain number. -For example, a "Chat Heads" animation like the one used by Messenger on Android could be implemented with a spring() pinned on another animated value, or with timing() and a duration of 0 for rigid tracking. -They can also be composed with interpolations:

Animated.spring(follower, {toValue: leader}).start(); +})

interpolation also supports arbitrary easing functions, many of which are +already implemented in the +Easing +class including quadratic, exponential, and bezier curves as well as functions +like step and bounce. interpolation also has configurable behavior for +extrapolating the outputRange. You can set the extrapolation by setting the extrapolate, +extrapolateLeft or extrapolateRight options. The default value is +extend but you can use clamp to prevent the output value from exceeding +outputRange.

Tracking Dynamic Values #

Animated values can also track other values. Just set the toValue of an +animation to another animated value instead of a plain number, for example with +spring physics for an interaction like "Chat Heads", or via timing with +duration: 0 for rigid/instant tracking. They can also be composed with +interpolations:

Animated.spring(follower, {toValue: leader}).start(); Animated.timing(opacity, { toValue: pan.x.interpolate({ inputRange: [0, 300], outputRange: [1, 0], }), -}).start();

The leader and follower animated values would be implemented using Animated.ValueXY(). -ValueXY is a handy way to deal with 2D interactions, such as panning or dragging. -It is a simple wrapper that basically contains two Animated.Value instances and some helper functions that call through to them, -making ValueXY a drop-in replacement for Value in many cases. -It allows us to track both x and y values in the example above.

Tracking gestures #

Gestures, like panning or scrolling, and other events can map directly to animated values using Animated.event. -This is done with a structured map syntax so that values can be extracted from complex event objects. -The first level is an array to allow mapping across multiple args, and that array contains nested objects.

For example, when working with horizontal scrolling gestures, -you would do the following in order to map event.nativeEvent.contentOffset.x to scrollX (an Animated.Value):

onScroll={Animated.event( - // scrollX = e.nativeEvent.contentOffset.x - [{ nativeEvent: { - contentOffset: { - x: scrollX - } - } - }] - )}

When using PanResponder, you could use the following code to extract the x and y positions from gestureState.dx and gestureState.dy. -We use a null in the first position of the array, as we are only interested in the second argument passed to the PanResponder handler, -which is the gestureState.

onPanResponderMove={Animated.event( - [null, // ignore the native event +}).start();

ValueXY is a handy way to deal with 2D interactions, such as panning/dragging. +It is a simple wrapper that basically just contains two Animated.Value +instances and some helper functions that call through to them, making ValueXY +a drop-in replacement for Value in many cases. For example, in the code +snippet above, leader and follower could both be of type ValueXY and the x +and y values will both track as you would expect.

Input Events #

Animated.event is the input side of the Animated API, allowing gestures and +other events to map directly to animated values. This is done with a structured +map syntax so that values can be extracted from complex event objects. The +first level is an array to allow mapping across multiple args, and that array +contains nested objects. In the example, you can see that scrollX maps to +event.nativeEvent.contentOffset.x (event is normally the first arg to the +handler), and pan.x and pan.y map to gestureState.dx and gestureState.dy, +respectively (gestureState is the second arg passed to the PanResponder handler).

onScroll={Animated.event( + // scrollX = e.nativeEvent.contentOffset.x + [{nativeEvent: {contentOffset: {x: scrollX}}}] +)} +onPanResponderMove={Animated.event([ + null, // ignore the native event // extract dx and dy from gestureState // like 'pan.x = gestureState.dx, pan.y = gestureState.dy' {dx: pan.x, dy: pan.y} -])}

Responding to the current animation value #

You may notice that there is no obvious way to read the current value while animating. -This is because the value may only be known in the native runtime due to optimizations. -If you need to run JavaScript in response to the current value, there are two approaches:

  • spring.stopAnimation(callback) will stop the animation and invoke callback with the final value. This is useful when making gesture transitions.
  • spring.addListener(callback) will invoke callback asynchronously while the animation is running, providing a recent value. -This is useful for triggering state changes, -for example snapping a bobble to a new option as the user drags it closer, -because these larger state changes are less sensitive to a few frames of lag compared to continuous gestures like panning which need to run at 60 fps.

Animated is designed to be fully serializable so that animations can be run in a high performance way, independent of the normal JavaScript event loop. -This does influence the API, so keep that in mind when it seems a little trickier to do something compared to a fully synchronous system. -Check out Animated.Value.addListener as a way to work around some of these limitations, -but use it sparingly since it might have performance implications in the future.

Using the native driver #

The Animated API is designed to be serializable. -By using the native driver, -we send everything about the animation to native before starting the animation, -allowing native code to perform the animation on the UI thread without having to go through the bridge on every frame. -Once the animation has started, the JS thread can be blocked without affecting the animation.

Using the native driver for normal animations is quite simple. -Just add useNativeDriver: true to the animation config when starting it.

Animated.timing(this.state.animatedValue, { - toValue: 1, - duration: 500, - useNativeDriver: true, // <-- Add this -}).start();

Animated values are only compatible with one driver so if you use native driver when starting an animation on a value, -make sure every animation on that value also uses the native driver.

The native driver also works with Animated.event. -This is specially useful for animations that follow the scroll position as without the native driver, -the animation will always run a frame behind the gesture due to the async nature of React Native.

<Animated.ScrollView // <-- Use the Animated ScrollView wrapper - scrollEventThrottle={1} // <-- Use 1 here to make sure no events are ever missed - onScroll={Animated.event( - [{ nativeEvent: { contentOffset: { y: this.state.animatedValue } } }], - { useNativeDriver: true } // <-- Add this - )} -> - {content} -</Animated.ScrollView>

You can see the native driver in action by running the UIExplorer sample app, -then loading the Native Animated Example. -You can also take a look at the source code to learn how these examples were produced.

Caveats #

Not everything you can do with Animated is currently supported by the native driver. -The main limitation is that you can only animate non-layout properties: -things like transform, opacity and backgroundColor will work, but flexbox and position properties will not. -When using Animated.event, it will only work with direct events and not bubbling events. -This means it does not work with PanResponder but does work with things like ScrollView#onScroll.

Additional examples #

The UIExplorer sample app has various examples of Animated in use:

LayoutAnimation API #

LayoutAnimation allows you to globally configure create and update +]);

Responding to the Current Animation Value #

You may notice that there is no obvious way to read the current value while +animating - this is because the value may only be known in the native runtime +due to optimizations. If you need to run JavaScript in response to the current +value, there are two approaches:

  • spring.stopAnimation(callback) will stop the animation and invoke callback +with the final value - this is useful when making gesture transitions.
  • spring.addListener(callback) will invoke callback asynchronously while the +animation is running, providing a recent value. This is useful for triggering +state changes, for example snapping a bobble to a new option as the user drags +it closer, because these larger state changes are less sensitive to a few frames +of lag compared to continuous gestures like panning which need to run at 60fps.

Future Work #

As previously mentioned, we're planning on optimizing Animated under the hood to +make it even more performant. We would also like to experiment with more +declarative and higher level gestures and triggers, such as horizontal vs. +vertical panning.

The above API gives a powerful tool for expressing all sorts of animations in a +concise, robust, and performant way. Check out more example code in +UIExplorer/AnimationExample. Of course there may still be times where Animated +doesn't support what you need, and the following sections cover other animation +systems.

LayoutAnimation #

LayoutAnimation allows you to globally configure create and update animations that will be used for all views in the next render/layout cycle. This is useful for doing flexbox layout updates without bothering to measure or calculate specific properties in order to animate them directly, and is @@ -230,12 +184,132 @@ what you want.

Note that in order to get this to work on Android} }

Run this example

This example uses a preset value, you can customize the animations as you need, see LayoutAnimation.js -for more information.

Additional notes #

requestAnimationFrame #

requestAnimationFrame is a polyfill from the browser that you might be +for more information.

requestAnimationFrame #

requestAnimationFrame is a polyfill from the browser that you might be familiar with. It accepts a function as its only argument and calls that function before the next repaint. It is an essential building block for animations that underlies all of the JavaScript-based animation APIs. In general, you shouldn't need to call this yourself - the animation APIs will -manage frame updates for you.

setNativeProps #

As mentioned in the Direction Manipulation section, +manage frame updates for you.

react-tween-state (Not recommended - use Animated instead) #

react-tween-state is a +minimal library that does exactly what its name suggests: it tweens a +value in a component's state, starting at a from value and ending at +a to value. This means that it generates the values in between those +two values, and it sets the state on every requestAnimationFrame with +the intermediary value.

Tweening definition from Wikipedia

"... tweening is the process of generating intermediate frames between two +images to give the appearance that the first image evolves smoothly +into the second image. [Tweens] are the drawings between the key +frames which help to create the illusion of motion."

The most obvious way to animate from one value to another is linearly: +you subtract the end value from the start value and divide the result by +the number of frames over which the animation occurs, and then add that +value to the current value on each frame until the end value is reached. +Linear easing often looks awkward and unnatural, so react-tween-state +provides a selection of popular easing functions +that can be applied to make your animations more pleasing.

This library does not ship with React Native - in order to use it on +your project, you will need to install it with npm i react-tween-state +--save from your project directory.

import tweenState from 'react-tween-state'; +import reactMixin from 'react-mixin'; // https://github.com/brigand/react-mixin + +class App extends React.Component { + constructor(props) { + super(props); + this.state = { opacity: 1 }; + this._animateOpacity = this._animateOpacity.bind(this); + } + + _animateOpacity() { + this.tweenState('opacity', { + easing: tweenState.easingTypes.easeOutQuint, + duration: 1000, + endValue: this.state.opacity === 0.2 ? 1 : 0.2, + }); + } + + render() { + return ( + <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}> + <TouchableWithoutFeedback onPress={this._animateOpacity}> + <View ref={component => this._box = component} + style={{width: 200, height: 200, backgroundColor: 'red', + opacity: this.getTweeningValue('opacity')}} /> + </TouchableWithoutFeedback> + </View> + ) + } +} + +reactMixin.onClass(App, tweenState.Mixin);

Run this example

Here we animated the opacity, but as you might guess, we can animate any +numeric value. Read more about react-tween-state in its +README.

Rebound (Not recommended - use Animated instead) #

Rebound.js is a JavaScript port of +Rebound for Android. It is +similar in concept to react-tween-state: you have an initial value and +set an end value, then Rebound generates intermediate values that you can +use for your animation. Rebound is modeled after spring physics; we +don't provide a duration when animating with springs, it is +calculated for us depending on the spring tension, friction, current +value and end value. Rebound is used +internally +by React Native on Navigator and WarningBox.

Notice that Rebound animations can be interrupted - if you release in +the middle of a press, it will animate back from the current state to +the original value.

import rebound from 'rebound'; + +class App extends React.Component { + constructor(props) { + super(props); + this._onPressIn = this._onPressIn.bind(this); + this._onPressOut = this._onPressOut.bind(this); + } + // First we initialize the spring and add a listener, which calls + // setState whenever it updates + componentWillMount() { + // Initialize the spring that will drive animations + this.springSystem = new rebound.SpringSystem(); + this._scrollSpring = this.springSystem.createSpring(); + var springConfig = this._scrollSpring.getSpringConfig(); + springConfig.tension = 230; + springConfig.friction = 10; + + this._scrollSpring.addListener({ + onSpringUpdate: () => { + this.setState({scale: this._scrollSpring.getCurrentValue()}); + }, + }); + + // Initialize the spring value at 1 + this._scrollSpring.setCurrentValue(1); + } + + _onPressIn() { + this._scrollSpring.setEndValue(0.5); + } + + _onPressOut() { + this._scrollSpring.setEndValue(1); + } + + render() { + var imageStyle = { + width: 250, + height: 200, + transform: [{scaleX: this.state.scale}, {scaleY: this.state.scale}], + }; + + var imageUri = "img/ReboundExample.png"; + + return ( + <View style={styles.container}> + <TouchableWithoutFeedback onPressIn={this._onPressIn} + onPressOut={this._onPressOut}> + <Image source={{uri: imageUri}} style={imageStyle} /> + </TouchableWithoutFeedback> + </View> + ); + } +}

Run this example

You can also clamp the spring values so that they don't overshoot and +oscillate around the end value. In the above example, we would add +this._scrollSpring.setOvershootClampingEnabled(true) to change this. +See the below gif for an example of where in your interface you might +use this.

Screenshot from +react-native-scrollable-tab-view. +You can run a similar example here.

A sidenote about setNativeProps #

As mentioned in the Direction Manipulation section, setNativeProps allows us to modify properties of native-backed components (components that are actually backed by native views, unlike composite components) directly, without having to setState and @@ -275,7 +349,36 @@ computationally intensive work until after animations are complete, using the InteractionManager. You can monitor the frame rate by using the In-App Developer Menu "FPS -Monitor" tool.

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

\ No newline at end of file diff --git a/docs/appregistry.html b/docs/appregistry.html index 33141bde56d..85884f37a78 100644 --- a/docs/appregistry.html +++ b/docs/appregistry.html @@ -1,4 +1,4 @@ -AppRegistry

AppRegistry #

AppRegistry is the JS entry point to running all React Native apps. App +AppRegistry

AppRegistry #

AppRegistry is the JS entry point to running all React Native apps. App root components should register themselves with AppRegistry.registerComponent, then the native system can load the bundle for the app and then actually run the app when it's ready by invoking @@ -6,7 +6,7 @@ for the app and then actually run the app when it's ready by invoking AppRegistry.unmountApplicationComponentAtRootTag with the tag that was passed into runApplication. These should always be used as a pair.

AppRegistry should be required early in the require sequence to make sure the JS execution environment is setup before other modules are -required.

Methods #

static registerConfig(config) #

static registerComponent(appKey, component, section?) #

static registerRunnable(appKey, run) #

static registerSection(appKey, component) #

static getAppKeys() #

static getSectionKeys() #

static getSections() #

static getRunnable(appKey) #

static getRegistry() #

static runApplication(appKey, appParameters) #

static unmountApplicationComponentAtRootTag(rootTag) #

static registerHeadlessTask(taskKey, task) #

Register a headless task. A headless task is a bit of code that runs without a UI. +required.

Methods #

static registerConfig(config) #

static registerComponent(appKey, getComponentFunc) #

static registerRunnable(appKey, func) #

static getAppKeys() #

static runApplication(appKey, appParameters) #

static unmountApplicationComponentAtRootTag(rootTag) #

static registerHeadlessTask(taskKey, task) #

Register a headless task. A headless task is a bit of code that runs without a UI. @param taskKey the key associated with this task @param task a promise returning function that takes some data passed from the native side as the only argument; when the promise is resolved or rejected the native side is @@ -28,6 +28,6 @@ sure the JS execution environment is setup before other modules are apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.43" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.42" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/appstate.html b/docs/appstate.html index 553953a05a5..51badfb3d4e 100644 --- a/docs/appstate.html +++ b/docs/appstate.html @@ -1,4 +1,4 @@ -AppState

AppState #

AppState can tell you if the app is in the foreground or background, +AppState

AppState #

AppState can tell you if the app is in the foreground or background, and notify you when the state changes.

AppState is frequently used to determine the intent and proper behavior when handling push notifications.

App States #

source?: ImageSourcePropType #

The image source (either a remote URL or a local file resource).

This prop can also contain several remote URLs, specified together with their width and height and potentially with scale/other URI arguments. The native side will then choose the best uri to display based on the measured size of the image container. A cache property can be added to -control how networked request interacts with the local cache.

style?: style #

backfaceVisibility enum('visible', 'hidden')
backgroundColor [object Object]
borderBottomLeftRadius number
borderBottomRightRadius number
borderColor [object Object]
borderRadius number
borderTopLeftRadius number
borderTopRightRadius number
borderWidth number
opacity number
overflow enum('visible', 'hidden')
resizeMode Object.keys(ImageResizeMode)
tintColor [object Object]

Changes the color of all the non-transparent pixels to the tintColor.

androidoverlayColor string

When the image has rounded corners, specifying an overlayColor will +control how networked request interacts with the local cache.

style?: style #

backfaceVisibility enum('visible', 'hidden')
backgroundColor color
borderBottomLeftRadius number
borderBottomRightRadius number
borderColor color
borderRadius number
borderTopLeftRadius number
borderTopRightRadius number
borderWidth number
opacity number
overflow enum('visible', 'hidden')
resizeMode Object.keys(ImageResizeMode)
tintColor color

Changes the color of all the non-transparent pixels to the tintColor.

androidoverlayColor string

When the image has rounded corners, specifying an overlayColor will cause the remaining space in the corners to be filled with a solid color. This is useful in cases which are not supported by the Android implementation of rounded corners: @@ -85,25 +85,25 @@ background and setting the overlayColor to the same color as the background.

For details of how this works under the hood, see http://frescolib.org/docs/rounded-corners-and-circles.html

ImageResizeMode is an Enum for different image resizing modes, set via the resizeMode style property on Image components. The values are contain, cover, -stretch, center, repeat.

testID?: string #

A unique identifier for this element to be used in UI Automation -testing scripts.

androidresizeMethod?: enum('auto', 'resize', 'scale') #

The mechanism that should be used to resize the image when the image's dimensions +stretch, center, repeat.

testID?: string #

A unique identifier for this element to be used in UI Automation +testing scripts.

androidresizeMethod?: enum('auto', 'resize', 'scale') #

The mechanism that should be used to resize the image when the image's dimensions differ from the image view's dimensions. Defaults to auto.

  • auto: Use heuristics to pick between resize and scale.

  • resize: A software operation which changes the encoded image in memory before it gets decoded. This should be used instead of scale when the image is much larger than the view.

  • scale: The image gets drawn downscaled or upscaled. Compared to resize, scale is faster (usually hardware accelerated) and produces higher quality images. This should be used if the image is smaller than the view. It should also be used if the -image is slightly bigger than the view.

More details about resize and scale can be found at http://frescolib.org/docs/resizing-rotating.html.

iosaccessibilityLabel?: node #

The text that's read by the screen reader when the user interacts with -the image.

iosaccessible?: bool #

When true, indicates the image is an accessibility element.

iosblurRadius?: number #

blurRadius: the blur radius of the blur filter added to the image

ioscapInsets?: {top: number, left: number, bottom: number, right: number} #

When the image is resized, the corners of the size specified +image is slightly bigger than the view.

More details about resize and scale can be found at http://frescolib.org/docs/resizing-rotating.html.

iosaccessibilityLabel?: string #

The text that's read by the screen reader when the user interacts with +the image.

iosaccessible?: bool #

When true, indicates the image is an accessibility element.

iosblurRadius?: number #

blurRadius: the blur radius of the blur filter added to the image

ioscapInsets?: {top: number, left: number, bottom: number, right: number} #

When the image is resized, the corners of the size specified by capInsets will stay a fixed size, but the center content and borders of the image will be stretched. This is useful for creating resizable rounded buttons, shadows, and other resizable assets. More info in the -official Apple documentation.

iosdefaultSource?: [object Object], [object Object] #

A static image to display while loading the image source.

iosdefaultSource?: {uri: string, width: number, height: number, scale: number}, number #

A static image to display while loading the image source.

  • uri - a string representing the resource identifier for the image, which should be either a local file path or the name of a static image resource (which should be wrapped in the require('./path/to/image.png') function).
  • width, height - can be specified if known at build time, in which case these will be used to set the default <Image/> component dimensions.
  • scale - used to indicate the scale factor of the image. Defaults to 1.0 if -unspecified, meaning that one image pixel equates to one display point / DIP.
  • number - Opaque type returned by something like require('./image.jpg').

iosonPartialLoad?: function #

Invoked when a partial load of the image is complete. The definition of +unspecified, meaning that one image pixel equates to one display point / DIP.

  • number - Opaque type returned by something like require('./image.jpg').
  • iosonPartialLoad?: function #

    Invoked when a partial load of the image is complete. The definition of what constitutes a "partial load" is loader specific though this is meant -for progressive JPEG loads.

    iosonProgress?: function #

    Invoked on download progress with {nativeEvent: {loaded, total}}.

    Methods #

    static getSize(uri: string, success: function, failure: function): #

    Retrieve the width and height (in pixels) of an image prior to displaying it. +for progressive JPEG loads.

    iosonProgress?: function #

    Invoked on download progress with {nativeEvent: {loaded, total}}.

    Methods #

    static getSize(uri: string, success: function, failure: function): #

    Retrieve the width and height (in pixels) of an image prior to displaying it. This method can fail if the image cannot be found, or fails to download.

    In order to retrieve the image dimensions, the image may first need to be loaded or downloaded, after which it will be cached. This means that in principle you could use this method to preload images, however it is not @@ -829,7 +829,7 @@ exports.examples : '500', color: 'blue', }, -});

    \ No newline at end of file diff --git a/docs/imageeditor.html b/docs/imageeditor.html index b9133ff6150..dac42543188 100644 --- a/docs/imageeditor.html +++ b/docs/imageeditor.html @@ -1,4 +1,4 @@ -ImageEditor

    ImageEditor #

    Methods #

    static cropImage(uri, cropData, success, failure) #

    Crop the image specified by the URI param. If URI points to a remote +ImageEditor

    ImageEditor #

    Methods #

    static cropImage(uri, cropData, success, failure) #

    Crop the image specified by the URI param. If URI points to a remote image, it will be downloaded automatically. If the image cannot be loaded/downloaded, the failure callback will be called.

    If the cropping process is successful, the resultant cropped image will be stored in the ImageStore, and the URI returned in the success @@ -19,6 +19,6 @@ cropped image from the ImageStore when you are done with it.

    \ No newline at end of file diff --git a/docs/imagepickerios.html b/docs/imagepickerios.html index c651d629aa0..93e4733bd76 100644 --- a/docs/imagepickerios.html +++ b/docs/imagepickerios.html @@ -1,4 +1,4 @@ -ImagePickerIOS

    ImagePickerIOS #

    Methods #

    static canRecordVideos(callback) #

    static canUseCamera(callback) #

    static openCameraDialog(config, successCallback, cancelCallback) #

    static openSelectDialog(config, successCallback, cancelCallback) #

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

    ImagePickerIOS #

    Methods #

    static canRecordVideos(callback) #

    static canUseCamera(callback) #

    static openCameraDialog(config, successCallback, cancelCallback) #

    static openSelectDialog(config, successCallback, cancelCallback) #

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

    \ No newline at end of file diff --git a/docs/images.html b/docs/images.html index 672827050fe..ef2035c25a7 100644 --- a/docs/images.html +++ b/docs/images.html @@ -1,4 +1,4 @@ -Images

    Images #

    Static Image Resources #

    React Native provides a unified way of managing images and other media assets in your iOS and Android apps. To add a static image to your app, place it somewhere in your source code tree and reference it like this:

    <Image source={require('./my-icon.png')} />

    The image name is resolved the same way JS modules are resolved. In the example above, the packager will look for my-icon.png in the same folder as the component that requires it. Also, if you have my-icon.ios.png and my-icon.android.png, the packager will pick the correct file for the platform.

    You can also use the @2x and @3x suffixes to provide images for different screen densities. If you have the following file structure:

    . +Images

    Images #

    Static Image Resources #

    React Native provides a unified way of managing images and other media assets in your iOS and Android apps. To add a static image to your app, place it somewhere in your source code tree and reference it like this:

    <Image source={require('./my-icon.png')} />

    The image name is resolved the same way JS modules are resolved. In the example above, the packager will look for my-icon.png in the same folder as the component that requires it. Also, if you have my-icon.ios.png and my-icon.android.png, the packager will pick the correct file for the platform.

    You can also use the @2x and @3x suffixes to provide images for different screen densities. If you have the following file structure:

    . ├── button.js └── img ├── check@2x.png @@ -29,7 +29,7 @@ using local resources that are outside of Images.xcassets.

    < <Image source={...}> <Text>Inside</Text> </Image> -);

    iOS Border Radius Styles #

    Please note that the following corner specific, border radius style properties are currently ignored by iOS's image component:

    • borderTopLeftRadius
    • borderTopRightRadius
    • borderBottomLeftRadius
    • borderBottomRightRadius

    Off-thread Decoding #

    Image decoding can take more than a frame-worth of time. This is one of the major sources of frame drops on the web because decoding is done in the main thread. In React Native, image decoding is done in a different thread. In practice, you already need to handle the case when the image is not downloaded yet, so displaying the placeholder for a few more frames while it is decoding does not require any code change.

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

    \ No newline at end of file diff --git a/docs/imagestore.html b/docs/imagestore.html index 318e9da54e3..546bc34a6bf 100644 --- a/docs/imagestore.html +++ b/docs/imagestore.html @@ -1,4 +1,4 @@ -ImageStore

    ImageStore #

    Methods #

    static hasImageForTag(uri, callback) #

    Check if the ImageStore contains image data for the specified URI. +ImageStore

    ImageStore #

    Methods #

    static hasImageForTag(uri, callback) #

    Check if the ImageStore contains image data for the specified URI. @platform ios

    static removeImageForTag(uri) #

    Delete an image from the ImageStore. Images are stored in memory and must be manually removed when you are finished with them, otherwise they will continue to use up RAM until the app is terminated. It is safe to @@ -32,6 +32,6 @@ base64 data.

    You ca apiKey: '2c98749b4a1e588efec53b2acec13025', indexName: 'react-native-versions', inputSelector: '#algolia-doc-search', - algoliaOptions: { facetFilters: [ "tags:0.43" ], hitsPerPage: 5 } + algoliaOptions: { facetFilters: [ "tags:0.42" ], hitsPerPage: 5 } }); \ No newline at end of file diff --git a/docs/integration-with-existing-apps.html b/docs/integration-with-existing-apps.html index 5c1ca7f1a3e..ead4b58721f 100644 --- a/docs/integration-with-existing-apps.html +++ b/docs/integration-with-existing-apps.html @@ -1,4 +1,4 @@ -Integration With Existing Apps

    Integration With Existing Apps #

    +Integration With Existing Apps

    Integration With Existing Apps #