-
Notifications
You must be signed in to change notification settings - Fork 583
/
Copy pathAnimatableHeaderLargeTitle.tsx
37 lines (34 loc) · 1.11 KB
/
AnimatableHeaderLargeTitle.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { useSpace, Text } from "@artsy/palette-mobile"
import Animated, { Extrapolate, interpolate, useAnimatedStyle } from "react-native-reanimated"
import { useAnimatableHeaderContext } from "./AnimatableHeaderContext"
export const AnimatableHeaderLargeTitle = () => {
const space = useSpace()
const { scrollOffsetY, largeTitleVerticalOffset, setLargeTitleHeight, largeTitleEndEdge, title } =
useAnimatableHeaderContext()
const disappearAnim = useAnimatedStyle(() => {
"worklet"
return {
opacity: interpolate(scrollOffsetY.value, [0, largeTitleEndEdge], [1, 0], Extrapolate.CLAMP),
}
}, [largeTitleEndEdge])
return (
<Animated.View
style={[
{
paddingHorizontal: space(2),
paddingTop: space(1),
paddingBottom: largeTitleVerticalOffset,
justifyContent: "center",
},
disappearAnim,
]}
onLayout={(event) => {
setLargeTitleHeight(event.nativeEvent.layout.height)
}}
>
<Text testID="animated-header-large-title" variant="lg-display">
{title}
</Text>
</Animated.View>
)
}