2 changed files with 40 additions and 10 deletions
@ -0,0 +1,25 @@ |
|||||
|
import React from "react"; |
||||
|
import { Animated, Easing} from "react-native"; |
||||
|
import { useEffect, useState } from "react"; |
||||
|
|
||||
|
function LeftToRight(props){ |
||||
|
const [xPosition, setXPosition] = useState(new Animated.Value(props.origin)); |
||||
|
|
||||
|
useEffect(() => { |
||||
|
Animated.timing(xPosition, { |
||||
|
toValue: 0, |
||||
|
easing: Easing.back(), |
||||
|
duration: props.duration, |
||||
|
useNativeDriver: true |
||||
|
}).start(); |
||||
|
}, []); |
||||
|
|
||||
|
|
||||
|
return ( |
||||
|
<Animated.View style={{ transform: [{ translateX: xPosition }]}}> |
||||
|
{props.children} |
||||
|
</Animated.View> |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
export default LeftToRight; |
Loading…
Reference in new issue