Skip to content

Commit 0ce769f

Browse files
committed
Upgraded README and added scripts to get first time dev experience to work.
1 parent 3f57269 commit 0ce769f

File tree

2 files changed

+66
-41
lines changed

2 files changed

+66
-41
lines changed

README.md

Lines changed: 65 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
Declarative animations for React Native and React Native Web.
1313

14-
*NOTE: This is a pre-release and should not be used in production.*
14+
_NOTE: This is a pre-release and should not be used in production._
1515

1616
## Installation
1717

@@ -38,25 +38,27 @@ yarn add react-native-fluid-transitions
3838

3939
Getting your first transitions set up is really easy:
4040

41-
``` js
42-
import React, {useState} from 'react';
43-
import { StyleSheet } from 'react-native';
44-
import Fluid from 'react-native-fluid-transitions';
41+
```js
42+
import React, { useState } from "react";
43+
import { StyleSheet } from "react-native";
44+
import Fluid from "react-native-fluid-transitions";
4545

4646
const styles = StyleSheet.create({
47-
active: { width: 100, height: 100, backgroundColor: 'aqua' },
48-
inactive: { width: 50, height: 50, backgroundColor: 'gold' },
47+
active: { width: 100, height: 100, backgroundColor: "aqua" },
48+
inactive: { width: 50, height: 50, backgroundColor: "gold" },
4949
});
5050

5151
const MyComponent = () => {
5252
const [active, setActive] = useState(false);
5353
const toggle = () => setActive(a => !a);
5454

55-
return <Fluid.View
56-
style={active ? styles.active : styles.inactive}
57-
onPress={toggle}
58-
/>
59-
}
55+
return (
56+
<Fluid.View
57+
style={active ? styles.active : styles.inactive}
58+
onPress={toggle}
59+
/>
60+
);
61+
};
6062
```
6163

6264
Try using this component in your app and tap the box. The component should automatically interpolate between the two styles - including using predefined animations that should work for the different style properties.
@@ -70,7 +72,7 @@ API reference for `Fluid.*` components:
7072
- Fluid.Text
7173
- Fluid.ScrollView
7274

73-
### Fluid.*
75+
### Fluid.\*
7476

7577
`Fluid.*` components are the basic building blocks of react-native-fluid-transitions. They all implement the same properties as their corresponding React Native components.
7678

@@ -101,34 +103,36 @@ If you want more control over how animations are played, you can build your own
101103

102104
A simple example illustrates how states and configuration can be used to build transitions:
103105

104-
``` js
105-
import React from 'react';
106-
import { StyleSheet } from 'react-native';
107-
import Fluid, { useFluidState, useFluidConfig } from 'react-native-fluid-transitions';
106+
```js
107+
import React from "react";
108+
import { StyleSheet } from "react-native";
109+
import Fluid, {
110+
useFluidState,
111+
useFluidConfig,
112+
} from "react-native-fluid-transitions";
108113

109114
const styles = StyleSheet.create({
110-
active: { width: 100, height: 100, backgroundColor: 'aqua' },
111-
inactive: { width: 50, height: 50, backgroundColor: 'gold' },
115+
active: { width: 100, height: 100, backgroundColor: "aqua" },
116+
inactive: { width: 50, height: 50, backgroundColor: "gold" },
112117
});
113118

114119
const MyComponent = () => {
115120
const [activeState, setActiveState] = useFluidState(false);
116121
const toggle = () => setActiveState(s => !s);
117122

118-
const config = useFluidConfig(
119-
WhenState(activeState, styles.active),
120-
);
123+
const config = useFluidConfig(WhenState(activeState, styles.active));
121124

122125
return (
123-
<Fluid.View
126+
<Fluid.View
124127
onPress={toggle}
125128
config={config}
126129
states={activeState}
127130
style={styles.inactive}
128131
/>
129132
);
130-
}
133+
};
131134
```
135+
132136
#### <a name="States">States</a>
133137

134138
A fluid state works as a regular React Native state, and can be created with the hook <a href="#useFluidState">`useFluidState`</a>. It returns a state variable and a function for updating the state. This object can be passed along to the Fluid.View through the state property.
@@ -153,7 +157,6 @@ A configuration object consists of the following types:
153157
| childAnimation | Describes how child animations should be ordered |
154158
| interpolation | Describes interpolations that should be on at all times. Typically used for interpolations that are driven by a ScrollView or gesture. |
155159

156-
157160
#### <a name="When">When</a>
158161

159162
The when configuration field can contain different types of configuration. The when configuration field is created using the `WhenState` function. This function has several different overloads:
@@ -210,13 +213,12 @@ An animation type is a description of the animation function to run a given anim
210213
211214
**Timing Animation**
212215
213-
| Field | Description | Type |
214-
| -------- | --------------------------------------------------- | ------------------ |
215-
| type | Type of animation | 'timing' |
216-
| duration | Duration in number of milliseconds | number |
217-
| delay | Delay before starting the animation in milliseconds | number (optional) |
218-
| easing | Curve to apply to the animation | Easing (optional) |
219-
216+
| Field | Description | Type |
217+
| -------- | --------------------------------------------------- | ----------------- |
218+
| type | Type of animation | 'timing' |
219+
| duration | Duration in number of milliseconds | number |
220+
| delay | Delay before starting the animation in milliseconds | number (optional) |
221+
| easing | Curve to apply to the animation | Easing (optional) |
220222
221223
**Spring Animation**
222224
@@ -234,7 +236,7 @@ If you want an interpolation to run when a state change occurs, you can add `OnE
234236
**Creates a new onEnter / onExit element describing the interpolation that should be run when the state changes to / from active.**
235237
236238
```js
237-
function (state, interpolation, options?)
239+
function (state, interpolation, options?)
238240
```
239241
240242
Where the parameters <a href="#States">state</a>, <a href="#InterpolationType">interpolation</a> and <a href="#Options">options</a> shares the same types as the `When` element.
@@ -256,31 +258,36 @@ const config = useFluidConfig(
256258
When animations are played in the context of a parent `Fluid.View`, you can control how these animations should be played by changing the child configuration. There are three different types of child configuration available:
257259
258260
```js
259-
Sequential()
261+
Sequential();
260262
```
261263
262264
```js
263-
Paralell()
265+
Paralell();
264266
```
265267
266268
```js
267269
Staggered(staggerMs? | staggerFunction?, direction)
268270
```
269271
270272
## Value Interpolations
273+
271274
One of the more advanced techniques when building animations and transitions in React Native is when you need your interpolation to depend on a gesture value or a scrolliew position. In `react-native-fluid-transitions` this is already taken care of for you.
272275
273276
Given a view tree that contains a header and a scroll view:
274277
275278
```js
276279
const label = Label("myScrollView");
277280
return (
278-
<Fluid.View>
279-
  <Fluid.View config={config} staticStyle={styles.header}/>
280-
  <Fluid.ScrollView label={label}>      
281-
    {children}
282-
  </Fluid.ScrollView>
283-
</Fluid.View>);
281+
<Fluid.View>
282+
  
283+
<Fluid.View config={config} staticStyle={styles.header} />
284+
  
285+
<Fluid.ScrollView label={label}>
286+
           {children}
287+
  
288+
</Fluid.ScrollView>
289+
</Fluid.View>
290+
);
284291
```
285292
286293
You can add interpolations to the header component's configuration using the scroll position from the scroll view:
@@ -296,3 +303,20 @@ const config = useFluidConfig(
296303
```
297304
298305
A `Fluid.ScrollView` exposes two values, `ScrollY` and `ScrollX`.
306+
307+
# Examples
308+
309+
Getting started developing with the examples:
310+
311+
**To set up and install:**
312+
313+
`yarn bootstrap`
314+
315+
**Start watchers:**
316+
317+
`yarn dev`
318+
319+
**Run on iOS / Android:**
320+
321+
`yarn run-android`
322+
`yarn run-ios`

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.1.1",
44
"private": true,
55
"scripts": {
6+
"bootstrap": "yarn && cd ios && pod install && cd .. && cd src/packages/animated && tsc && cd ../transitions && tsc && cd ../gestures && tsc && cd ../navigation && tsc && cd ../svg && tsc && cd ..",
67
"dev": "concurrently \"cd src/packages/animated && tsc --watch\" \"cd src/packages/transitions && tsc --watch\" \"cd src/packages/gestures && tsc --watch\" \"cd src/packages/navigation && tsc --watch\" \"cd src/packages/svg && tsc --watch\"",
78
"web": "concurrently \"cd src/web && yarn start\"",
89
"run-ios": "react-native run-ios",

0 commit comments

Comments
 (0)