1 | import { I18nManager } from 'react-native';
|
2 | export const getCombinedStyles = _ref => {
|
3 | let {
|
4 | isAnimatedFromRight,
|
5 | isIconStatic,
|
6 | distance,
|
7 | animFAB
|
8 | } = _ref;
|
9 | const {
|
10 | isRTL
|
11 | } = I18nManager;
|
12 | const defaultPositionStyles = {
|
13 | left: -distance,
|
14 | right: undefined
|
15 | };
|
16 | const combinedStyles = {
|
17 | innerWrapper: { ...defaultPositionStyles
|
18 | },
|
19 | iconWrapper: { ...defaultPositionStyles
|
20 | },
|
21 | absoluteFill: {}
|
22 | };
|
23 | const animatedFromRight = isAnimatedFromRight && !isRTL;
|
24 | const animatedFromRightRTL = isAnimatedFromRight && isRTL;
|
25 | const animatedFromLeft = !isAnimatedFromRight && !isRTL;
|
26 | const animatedFromLeftRTL = !isAnimatedFromRight && isRTL;
|
27 |
|
28 | if (animatedFromRight) {
|
29 | combinedStyles.innerWrapper.transform = [{
|
30 | translateX: animFAB.interpolate({
|
31 | inputRange: [distance, 0],
|
32 | outputRange: [distance, 0]
|
33 | })
|
34 | }];
|
35 | combinedStyles.iconWrapper.transform = [{
|
36 | translateX: isIconStatic ? 0 : animFAB
|
37 | }];
|
38 | combinedStyles.absoluteFill.transform = [{
|
39 | translateX: animFAB.interpolate({
|
40 | inputRange: [distance, 0],
|
41 | outputRange: [Math.abs(distance) / 2, Math.abs(distance)]
|
42 | })
|
43 | }];
|
44 | } else if (animatedFromRightRTL) {
|
45 | combinedStyles.iconWrapper.transform = [{
|
46 | translateX: isIconStatic ? 0 : animFAB.interpolate({
|
47 | inputRange: [distance, 0],
|
48 | outputRange: [-distance, 0]
|
49 | })
|
50 | }];
|
51 | combinedStyles.innerWrapper.transform = [{
|
52 | translateX: animFAB.interpolate({
|
53 | inputRange: [distance, 0],
|
54 | outputRange: [-distance, 0]
|
55 | })
|
56 | }];
|
57 | combinedStyles.absoluteFill.transform = [{
|
58 | translateX: animFAB.interpolate({
|
59 | inputRange: [distance, 0],
|
60 | outputRange: [0, distance]
|
61 | })
|
62 | }];
|
63 | } else if (animatedFromLeft) {
|
64 | combinedStyles.iconWrapper.transform = [{
|
65 | translateX: isIconStatic ? distance : animFAB.interpolate({
|
66 | inputRange: [0, distance],
|
67 | outputRange: [distance, distance * 2]
|
68 | })
|
69 | }];
|
70 | combinedStyles.innerWrapper.transform = [{
|
71 | translateX: animFAB
|
72 | }];
|
73 | combinedStyles.absoluteFill.transform = [{
|
74 | translateX: animFAB.interpolate({
|
75 | inputRange: [0, distance],
|
76 | outputRange: [0, Math.abs(distance) / 2]
|
77 | })
|
78 | }];
|
79 | } else if (animatedFromLeftRTL) {
|
80 | combinedStyles.iconWrapper.transform = [{
|
81 | translateX: isIconStatic ? animFAB.interpolate({
|
82 | inputRange: [0, distance],
|
83 | outputRange: [-distance, -distance * 2]
|
84 | }) : -distance
|
85 | }];
|
86 | combinedStyles.innerWrapper.transform = [{
|
87 | translateX: animFAB.interpolate({
|
88 | inputRange: [0, distance],
|
89 | outputRange: [0, -distance]
|
90 | })
|
91 | }];
|
92 | combinedStyles.absoluteFill.transform = [{
|
93 | translateX: animFAB.interpolate({
|
94 | inputRange: [0, distance],
|
95 | outputRange: [0, -distance]
|
96 | })
|
97 | }];
|
98 | }
|
99 |
|
100 | return combinedStyles;
|
101 | };
|
102 |
|
\ | No newline at end of file |