Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bouncy header helper functions
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
You can’t perform that action at this time.