Skip to content

Commit b791bc1

Browse files
committed
Adding Fade Delay Pass Through w/ Examples
1 parent f681bbe commit b791bc1

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

FadeInView.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ class FadeInView extends Component {
1212

1313
componentDidMount() {
1414
const { viewOpacity } = this.state;
15-
const { onFadeComplete, duration = 500 } = this.props;
15+
const { onFadeComplete, duration = 500, delay } = this.props;
1616

1717
Animated.timing(
1818
viewOpacity,
1919
{
2020
toValue: 1,
2121
duration,
22+
delay
2223
},
2324
).start(onFadeComplete || (() => {}));
2425
}
@@ -38,6 +39,7 @@ class FadeInView extends Component {
3839
FadeInView.propTypes = {
3940
onFadeComplete: PropTypes.func,
4041
duration: PropTypes.number,
42+
delay: PropTypes.number,
4143
style: PropTypes.oneOfType([
4244
PropTypes.number,
4345
PropTypes.string,

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ A function that is called when the fade animation completes
1111
### `duration`
1212
The duration of the fade animation, **`500ms`** by default
1313

14+
### `delay`
15+
The time to wait (in milliseconds) before the fade starts, **`0ms`** by default
16+
1417
### `style`
1518
Style to be given to the view
1619

1720
## Usage
21+
22+
### Basic Usage
1823
```javascript
1924
import FadeInView from 'react-native-fade-in-view';
2025

@@ -28,3 +33,19 @@ const myFadeInComponent = () => (
2833
</FadeInView>
2934
);
3035
```
36+
37+
### Cascading List View
38+
```javascript
39+
import FadeInView from 'react-native-fade-in-view';
40+
41+
// Assuming items is an array of components
42+
const myFadeInList = () => (
43+
<ScrollView>
44+
{items.map((item, i) => (
45+
<FadeInView key={i} delay={i * 20}>
46+
{item}
47+
</FadeInView>
48+
))}
49+
</ScrollView>
50+
);
51+
```

0 commit comments

Comments
 (0)