position: sticky

This commit is contained in:
Dan Abramov
2023-12-07 17:14:09 +00:00
parent 87e40a6bac
commit 8b23b73aec
+13 -12
View File
@@ -256,14 +256,16 @@ let PagerTabBar = ({
], ],
})) }))
return ( return (
<Animated.View <>
pointerEvents="box-none" <View
style={[ onLayout={onHeaderOnlyLayout}
isMobile ? styles.tabBarMobile : styles.tabBarDesktop, pointerEvents="box-none"
isWeb ? null : headerTransform, style={{
isWeb ? null : {position: 'absolute'}, width: '100%',
]}> marginLeft: 'auto',
<View onLayout={onHeaderOnlyLayout} pointerEvents="box-none"> marginRight: 'auto',
width: 598,
}}>
{renderHeader?.()} {renderHeader?.()}
</View> </View>
<View <View
@@ -275,7 +277,8 @@ let PagerTabBar = ({
opacity: isHeaderReady ? 1 : 0, opacity: isHeaderReady ? 1 : 0,
pointerEvents: isHeaderReady ? 'auto' : 'none', pointerEvents: isHeaderReady ? 'auto' : 'none',
}, },
isWeb ? {position: 'sticky', top: 0} : null, isWeb ? {position: 'sticky', top: 0, zIndex: 1} : null,
{width: '100%', marginLeft: 'auto', marginRight: 'auto', width: 598},
]}> ]}>
<TabBar <TabBar
testID={testID} testID={testID}
@@ -285,7 +288,7 @@ let PagerTabBar = ({
onPressSelected={onCurrentPageSelected} onPressSelected={onCurrentPageSelected}
/> />
</View> </View>
</Animated.View> </>
) )
} }
PagerTabBar = React.memo(PagerTabBar) PagerTabBar = React.memo(PagerTabBar)
@@ -341,8 +344,6 @@ const styles = StyleSheet.create({
zIndex: 1, zIndex: 1,
top: 0, top: 0,
// @ts-ignore Web only -prf // @ts-ignore Web only -prf
left: 'calc(50% - 299px)',
width: 598,
}, },
}) })