Skip to content

Commit

Permalink
fix: conditionally set scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
MuckT committed Mar 19, 2024
1 parent ce2177b commit fc03d3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/dappsExplorer/DAppsExplorerScreenSearchFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export function DAppsExplorerScreenSearchFilter({ navigation, route }: Props) {
const horizontalScrollView = useRef<ScrollView>(null)
const dappRankingsBottomSheetRef = useRef<BottomSheetRefType>(null)

const onScroll = Animated.event([{ nativeEvent: { contentOffset: { y: scrollPositionValue } } }])
const dispatch = useDispatch()
const loading = useSelector(dappsListLoadingSelector)
const error = useSelector(dappsListErrorSelector)
Expand Down Expand Up @@ -154,8 +153,11 @@ export function DAppsExplorerScreenSearchFilter({ navigation, route }: Props) {
}

const handleScroll = useAnimatedScrollHandler((event) => {
onScroll()
scrollPosition.value = event.contentOffset.y
if (isTabNavigator) {
scrollPosition.value = event.contentOffset.y
} else {
Animated.event([{ nativeEvent: { contentOffset: { y: scrollPositionValue } } }])
}
})

useScrollAwareHeader({
Expand Down Expand Up @@ -288,7 +290,7 @@ export function DAppsExplorerScreenSearchFilter({ navigation, route }: Props) {
// Workaround iOS setting an incorrect automatic inset at the top
scrollIndicatorInsets={{ top: 0.01 }}
scrollEventThrottle={16}
onScroll={isTabNavigator ? handleScroll : onScroll}
onScroll={handleScroll}
sections={sections}
renderItem={({ item: dapp, index, section }) => {
return (
Expand Down
10 changes: 6 additions & 4 deletions src/home/WalletHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ function WalletHome({ navigation, route }: Props) {

const insets = useSafeAreaInsets()
const scrollPositionValue = useRef(new Animated.Value(0)).current
const onScroll = Animated.event([{ nativeEvent: { contentOffset: { y: scrollPositionValue } } }])

const dispatch = useDispatch()

Expand Down Expand Up @@ -107,8 +106,11 @@ function WalletHome({ navigation, route }: Props) {
}

const handleScroll = useAnimatedScrollHandler((event) => {
onScroll()
scrollPosition.value = event.contentOffset.y
if (isTabNavigator) {
scrollPosition.value = event.contentOffset.y
} else {
Animated.event([{ nativeEvent: { contentOffset: { y: scrollPositionValue } } }])
}
})

useScrollAwareHeader({
Expand Down Expand Up @@ -237,7 +239,7 @@ function WalletHome({ navigation, route }: Props) {
// Workaround iOS setting an incorrect automatic inset at the top
scrollIndicatorInsets={{ top: 0.01 }}
scrollEventThrottle={16}
onScroll={isTabNavigator ? handleScroll : onScroll}
onScroll={handleScroll}
refreshControl={refresh}
onRefresh={onRefresh}
refreshing={isLoading}
Expand Down

0 comments on commit fc03d3e

Please sign in to comment.