Closed Drzaln closed 4 years ago
@Drzaln Try it NOTE: Only work on iOS https://streamable.com/4s2ny
import React from "react";
import {
Platform,
ScrollView,
} from "react-native";
export class ScrollViewHandler extends React.Component {
constructor(props) {
super(props);
this.state = {
isScrollToTop: true,
};
}
onScroll = ({ contentOffset }) => {
const isTop = contentOffset.y === 0;
if (this.state.isScrollToTop === isTop) {
return;
}
this.setState({
isScrollToTop: isTop,
});
};
render() {
let dragHandler = {};
if (this.state.isScrollToTop && Platform.OS === "ios") {
dragHandler = this.props.dragHandler;
}
return (
<ScrollView
{...this.props}
{...dragHandler}
disableScrollViewPanResponder={this.state.isScrollToTop}
bounces={false}
scrollEventThrottle={16}
onScroll={e => this.onScroll(e.nativeEvent)}
showsVerticalScrollIndicator={false}
>
{this.props.children}
</ScrollView>
);
}
}
Issue Description
Hi, i've tried to correct this issue for almost two weeks, and i still not get the expected result. I want the scrollView not scroll if not reach top area and vice versa.
Steps to Reproduce / Code Snippets / Screenshots
This is some snippet from the code.
This is screen record