Skip to content

Instantly share code, notes, and snippets.

@aliemir
Last active April 3, 2020 14:33
Show Gist options
  • Save aliemir/d1d92bca1cd2bb7da8a98d2ab1abc2fc to your computer and use it in GitHub Desktop.
Save aliemir/d1d92bca1cd2bb7da8a98d2ab1abc2fc to your computer and use it in GitHub Desktop.
React Native Animated Interpolation Ornegi
const SearchView = ({navigation}) => {
const heroAnim = useRef(new Animated.Value(1)).current
const [isSearchFocus, setSearchFocus] = useState(false)
useEffect(() => {
if(isSearchFocus) {
Animated.timing(heroAnim, {
toValue: 1,
duration: 230,
useNativeDriver: false,
}).start()
} else {
Animated.timing(heroAnim, {
toValue: 0,
duration: 230,
useNativeDriver: false,
}).start()
}
}, [heroAnim, isSearchFocus]);
return (
{/*...*/}
<Box
as={Animated.View}
height={heroAnim.interpolate({
inputRange: [0,1],
outputRange: [0,230]
})}
{/*...*/}
>
<Box
as={Animated.View}
//Burada gerek yok ama göstermek için kullanmak istedim.
opacity={heroAnim.interpolate({
inputRange: [0,1],
outputRange: [0,1]
})}
>
<Bg>{/*...*/}</Bg>
</Box>
</Box>
{/*...*/}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment