forked from zoharlevin/react-native-animated-header-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimatedText.js
43 lines (36 loc) · 1.17 KB
/
AnimatedText.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
import React from 'react';
import { StyleSheet, Text, View, Animated } from 'react-native';
import {withSelfMeasure} from './utils/selfMeasureBehavior';
import {compose} from 'recompose';
import buildTransform from './utils/buildTransform';
const AnimatedText = ({
animationRange,
onLayoutSetMeasurements,
elementX,
elementY,
elementHeight,
elementWidth,}) => {
const animateText = buildTransform(animationRange, elementX, elementY, elementHeight, elementWidth, 20, 70, 0.7);
const animateOpacity = {
opacity: animationRange.interpolate({
inputRange: [0, 0.9, 1],
outputRange: [1, 0, 1],
}),
};
return (
<Animated.Text
style={[styles.text, animateText, animateOpacity]}
onLayout={event => onLayoutSetMeasurements(event)} >
This is Animated Text
</Animated.Text>
)
}
const styles = StyleSheet.create({
text: {
fontSize: 20,
color: '#696969',
fontWeight: 'bold'
}
});
const enhance = compose(withSelfMeasure);
export default enhance(AnimatedText);