-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathmodalCardStyleInterpolator.js
46 lines (42 loc) · 1.26 KB
/
modalCardStyleInterpolator.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
import {Animated} from 'react-native';
import variables from '../../../styles/variables';
import getCardStyles from '../../../styles/cardStyles';
import themeColors from '../../../styles/themes/default';
export default (
isSmallScreenWidth,
isFullScreenModal,
{
current: {progress},
inverted,
layouts: {
screen,
},
},
) => {
const translateX = Animated.multiply(progress.interpolate({
inputRange: [0, 1],
outputRange: [isSmallScreenWidth ? screen.width : variables.sideBarWidth, 0],
extrapolate: 'clamp',
}), inverted);
const opacity = Animated.multiply(progress, inverted);
const cardStyle = getCardStyles(isSmallScreenWidth, screen.width);
if (isFullScreenModal && !isSmallScreenWidth) {
cardStyle.opacity = opacity;
} else {
cardStyle.transform = [{translateX}];
}
return ({
containerStyle: {
overflow: 'hidden',
},
cardStyle,
overlayStyle: {
backgroundColor: themeColors.overlay,
opacity: progress.interpolate({
inputRange: [0, 1],
outputRange: [0, variables.overlayOpacity],
extrapolate: 'clamp',
}),
},
});
};