Hey I have two ScrollViews within each other. When the outer one scrolls down to a certain point I am disabling ScrollView so that only the next one can scroll. The issue I am having is how to enable scrolling for the outer won if a User wants to scroll back up. My code is as follows:
export const ScrollViewExample: React.FC<Props> = ({ navigation, route }: Props) => { const [prevScrollY, setPrevScrollY] = useState<number>(0); const [scrollable, setScrollable] = useState<boolean>(true); const handleScroll = (e: NativeSyntheticEvent<NativeScrollEvent>) => { const { y } = e.nativeEvent.contentOffset; if (y >= prevScrollY) { if (y > 454) setScrollable(false); setPrevScrollY(y); } else { if (y < prevScrollY) setScrollable(true); } }; return (<ScrollView onScroll={(e) => handleScroll(e)} scrollEventThrottle={16} scrollEnabled={scrollable}> // Content<ScrollView> // More Content</ScrollView></ScrollView> );};
It works great going down, but obviously I can't trigger scrollable to be true again by relying on a scroll.
Any ideas?