Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save abegehr/33f640caf59558b0862f8b55a2cce5a2 to your computer and use it in GitHub Desktop.
Save abegehr/33f640caf59558b0862f8b55a2cce5a2 to your computer and use it in GitHub Desktop.
CardStyleInterpolators.forHorizontalModal
export function forHorizontalModal({
current,
next,
inverted,
layouts: { screen }
}: StackCardInterpolationProps): StackCardInterpolatedStyle {
const translateFocused = multiply(
current.progress.interpolate({
inputRange: [0, 1],
outputRange: [screen.width, 0],
extrapolate: "clamp"
}),
inverted
);
const overlayOpacity = current.progress.interpolate({
inputRange: [0, 1],
outputRange: [0, 0.07],
extrapolate: "clamp"
});
const shadowOpacity = current.progress.interpolate({
inputRange: [0, 1],
outputRange: [0, 0.3],
extrapolate: "clamp"
});
return {
cardStyle: {
transform: [
// Translation for the animation of the current card
{ translateX: translateFocused },
// Translation for the animation of the card in back
{ translateX: 0 }
]
},
overlayStyle: { opacity: overlayOpacity },
shadowStyle: { shadowOpacity }
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment