forked from zoharlevin/react-native-animated-header-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimatedHeader.js
53 lines (46 loc) · 1.44 KB
/
AnimatedHeader.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
53
import React from 'react';
import { StyleSheet, Text, View, Animated } from 'react-native';
import AnimatedText from './AnimatedText';
import AnimatedImage from './AnimatedImage';
const HeaderBackground = ({animationRange}) => {
const animateHeader = {
transform: [
{
translateY: animationRange.interpolate({
inputRange: [0, 1],
outputRange: [0, -100],
}),
},
],
};
return <Animated.View style={[styles.headerBackground, animateHeader]} />;
};
const AnimatedHeader = ({animationRange}) =>
<View style={styles.container} pointerEvents="none">
<HeaderBackground animationRange={animationRange} />
<Animated.View style={styles.container} pointerEvents="none">
<AnimatedText animationRange={animationRange}/>
<AnimatedImage animationRange={animationRange}/>
</Animated.View>
</View>
const styles = StyleSheet.create({
container: {
position: 'absolute',
flex: 0,
zIndex: 2,
height:200,
width:'100%',
backgroundColor: 'transparent',
justifyContent: 'center',
alignItems: 'center'
},
headerBackground: {
position: 'absolute',
flex: 0,
height: 200,
width: '100%',
backgroundColor: 'white',
zIndex: 2,
}
});
export default AnimatedHeader;