Last active
February 26, 2020 20:03
-
-
Save ajsmth/e509dadfbff574a4d2b53d86c8f520fb to your computer and use it in GitHub Desktop.
Controlling the hero section - Final
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
const clampHeroSection = Animated.add( | |
// we want to make the hero section maintain its position on scroll | |
// we can do this by setting its translateY value to whatever the scroll value is | |
scrollY.current, | |
// shift it up by subtracting points until we've scrolled beyond the search section, and clamp it after that | |
scrollY.current.interpolate({ | |
inputRange: [0, SEARCH_PLAYLISTS_HEIGHT], | |
outputRange: [0, -SEARCH_PLAYLISTS_HEIGHT], | |
// we also want it to shift down when the user pulls down, so we clamp the above range with 'extrapolateRight' | |
// using just 'extrapolate' would clamp the scroll value in both directions | |
extrapolateRight: 'clamp', | |
}), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment