-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Endurance-Soft/feateru/waterfall-animation…
…s-addition feat(ui): Add waterfall animation to Home and Search screens
- Loading branch information
Showing
11 changed files
with
315 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { useEffect, useRef } from 'react'; | ||
import { Animated, StyleSheet } from 'react-native'; | ||
|
||
const AnimatedComponent = ({ delay, children, style }) => { | ||
const fadeAnim = useRef(new Animated.Value(0)).current; | ||
const yPosition = useRef(new Animated.Value(20)).current; | ||
|
||
useEffect(() => { | ||
const timer = setTimeout(() => { | ||
Animated.parallel([ | ||
Animated.timing(fadeAnim, { | ||
toValue: 1, | ||
duration: 300, | ||
useNativeDriver: true, | ||
}), | ||
Animated.timing(yPosition, { | ||
toValue: 0, | ||
duration: 300, | ||
useNativeDriver: true, | ||
}), | ||
]).start(); | ||
}, delay); | ||
|
||
return () => clearTimeout(timer); | ||
}, [delay]); | ||
|
||
return ( | ||
<Animated.View | ||
style={[ | ||
{ | ||
opacity: fadeAnim, | ||
transform: [{ translateY: yPosition }], | ||
}, | ||
style, | ||
]} | ||
> | ||
{children} | ||
</Animated.View> | ||
); | ||
}; | ||
|
||
export default AnimatedComponent; | ||
|
||
// import AnimatedComponent from './AnimatedComponent'; | ||
// <AnimatedComponent delay={0}></AnimatedComponent> | ||
// la animacion del componente que lo utiliza dura 300ml, | ||
// lo ideal es que el timepo de los componentes que continuan | ||
// la cascada tengan una diferencia de 200ml segun el orden vertical que tienen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { useEffect, useRef } from 'react'; | ||
import { Animated, Text, StyleSheet } from 'react-native'; | ||
|
||
const CascadingFadeInView = ({ children, delay = 0, style, animationKey }) => { | ||
const fadeAnim = useRef(new Animated.Value(0)).current; | ||
const yPosition = useRef(new Animated.Value(20)).current; | ||
|
||
useEffect(() => { | ||
fadeAnim.setValue(0); | ||
yPosition.setValue(20); | ||
|
||
const timer = setTimeout(() => { | ||
Animated.parallel([ | ||
Animated.timing(fadeAnim, { | ||
toValue: 1, | ||
duration: 300, | ||
useNativeDriver: true, | ||
}), | ||
Animated.timing(yPosition, { | ||
toValue: 0, | ||
duration: 200, | ||
useNativeDriver: true, | ||
}), | ||
]).start(); | ||
}, delay); | ||
|
||
return () => clearTimeout(timer); | ||
}, [animationKey]); | ||
|
||
return ( | ||
<Animated.View | ||
style={[ | ||
style, | ||
{ | ||
opacity: fadeAnim, | ||
transform: [{ translateY: yPosition }], | ||
}, | ||
]} | ||
> | ||
{children} | ||
</Animated.View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
}); | ||
|
||
export default CascadingFadeInView; | ||
|
||
// import Cascading from '../animation/CascadingFadeInView'; | ||
// import { useFocusEffect } from '@react-navigation/native'; | ||
|
||
|
||
// const [animationKey, setAnimationKey] = useState(Date.now()); | ||
// useFocusEffect( | ||
// useCallback(() => { | ||
// setAnimationKey(Date.now()); | ||
// }, []) | ||
// ); | ||
|
||
{/* <Cascading delay={100} animationKey={animationKey}> | ||
</Cascading> */} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import { View, Text, StyleSheet } from 'react-native'; | ||
import AnimatedComponent from '../animation/AnimatedComponent'; | ||
|
||
const CascadingEffectScreen = () => { | ||
return ( | ||
<View style={styles.container}> | ||
<AnimatedComponent delay={0}> | ||
<Text>Texto que aparece inmediatamente</Text> | ||
</AnimatedComponent> | ||
<AnimatedComponent delay={200} style={styles.delayedText}> | ||
<Text>Texto que aparece después de 2 segundos</Text> | ||
</AnimatedComponent> | ||
<AnimatedComponent delay={400} style={styles.delayedText}> | ||
<Text>Texto que aparece después de 2 segundos</Text> | ||
</AnimatedComponent> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
delayedText: { | ||
marginTop: 20, // Espacio entre los textos animados | ||
}, | ||
}); | ||
|
||
export default CascadingEffectScreen; |
Oops, something went wrong.