Skip to content

Commit 1ad7b2c

Browse files
committed
feature:
- add easing add property
1 parent fb42f3f commit 1ad7b2c

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ here is the properties and the descriptions of it:
5252
| shouldEnterWithAnimation | `false` | `boolean` | `NO` | if it's `true`, then the first state of `visible` would be presented by animation |
5353
| style | `undefined` | `ViewStyle` | `NO` | optinal style for the fadeview itself |
5454
| bearingMoveDistance| 50 | `number` | `NO` | option distance when you pass the directional Bearing for entrance or leave |
55+
| easing | `Easing.inOut(Easing.linear)` | `EasingFunction` | `NO` | Change the Easing function of the animation here |
5556
| removeChildrenAfterDisapearance| `false` | `boolean` | `NO` | you can choose if you want the children view to be removed after disappearance |
5657
| children | `undefined` | `JSX.Element` | `JSX.Element[]` | `NO` | child component(s) in order to have the fade animation |
5758
| entranceBearing | `Bearing.Center` | `Bearing` | `NO` | entrance animation with can be determined by `Bearing` enum from the lib, values: `Top`, `Bottom`, `Left`, `Right` , `Center` |

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-fadeview-wrapper",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"author": "Ali Saeedifar <[email protected]>",
55
"description": "A handy fadeview component for the react native",
66
"main": "lib/index.js",

src/components/FadeView.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Animated, Easing, StyleProp, ViewProps, ViewStyle } from "react-native";
2+
import { Animated, Easing, EasingFunction, StyleProp, ViewProps, ViewStyle } from "react-native";
33

44
export enum Bearing {
55
Top,
@@ -14,6 +14,7 @@ type Props = ViewProps & {
1414
style?: StyleProp<ViewStyle>;
1515
children?: React.ReactNode;
1616
entranceBearing?: Bearing;
17+
easing?: EasingFunction;
1718
leaveBearing?: Bearing;
1819
fadeOutScale?: number;
1920
duration?: number;
@@ -30,6 +31,7 @@ const FadeView = ({
3031
visible,
3132
children,
3233
duration = 200,
34+
easing = Easing.inOut(Easing.linear),
3335
fadeOutScale = 1.1,
3436
shouldEnterWithAnimation,
3537
bearingMoveDistance = 50,
@@ -63,9 +65,9 @@ const FadeView = ({
6365
applyingVisibleState.current = visible;
6466

6567
theAnimation.current = Animated.timing(visibilityAnimValue, {
66-
toValue: visible ? 1 : 0,
68+
easing,
6769
duration,
68-
easing: Easing.inOut(Easing.linear),
70+
toValue: visible ? 1 : 0,
6971
useNativeDriver: true,
7072
});
7173

0 commit comments

Comments
 (0)