-
Notifications
You must be signed in to change notification settings - Fork 515
/
CollapsingHeader.js
52 lines (47 loc) · 1.5 KB
/
CollapsingHeader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import React, { Component } from 'react';
import { StyleSheet, View, Animated } from 'react-native';
import Interactable from 'react-native-interactable';
export default class CollapsingHeader extends Component {
constructor(props) {
super(props);
this._deltaY = new Animated.Value(0);
}
render() {
return (
<View style={styles.container}>
<View style={{backgroundColor: 'red', height: 250, alignItems: 'center'}}>
<Animated.View style={{
transform: [
{
translateY: this._deltaY.interpolate({
inputRange: [-150, -150, 0, 0],
outputRange: [-50, -50, 0, 0]
})
},
{
scale: this._deltaY.interpolate({
inputRange: [-150, -150, 0, 0],
outputRange: [0.3, 0.3, 1, 1]
})
}
]
}}>
<View style={{width: 150, height: 150, backgroundColor: 'blue', borderRadius: 75, marginTop: 50}} />
</Animated.View>
</View>
<Interactable.View
verticalOnly={true}
snapTo={[{y: 0}, {y: -150}]}
animatedValueY={this._deltaY}>
<View style={{left: 0, right: 0, height: 600, backgroundColor: '#e0e0e0'}} />
</Interactable.View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
}
});