Created
June 20, 2019 12:48
-
-
Save tomhicks/9e256a2fd030dfbf774de65fee65be04 to your computer and use it in GitHub Desktop.
Bouncy header helper functions
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
import {Animated} from "react-native" | |
export function getSpoingyTransform( | |
scrollY: Animated.Value, | |
headerHeight: number, | |
) { | |
return [ | |
{ | |
translateY: scrollY.interpolate({ | |
inputRange: [-headerHeight, 0, 1], | |
outputRange: [-headerHeight / 2, 0, 0.5], | |
}), | |
}, | |
{ | |
scale: scrollY.interpolate({ | |
inputRange: [-headerHeight, 0, 1], | |
outputRange: [2, 1, 1], | |
}), | |
}, | |
] | |
} | |
export function captureScroll(scrollY: Animated.Value) { | |
return { | |
onScroll: Animated.event( | |
[ | |
{ | |
nativeEvent: { | |
contentOffset: { | |
y: scrollY, | |
}, | |
}, | |
}, | |
], | |
{useNativeDriver: true}, | |
), | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment