Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/ScrollViewIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default ({
scrollIndicatorStyle = {},
...props
}) => {
const { onScroll, ...propsToSpread } = props;
const [fadeAnim] = useState(
new Animated.Value(shouldIndicatorHide ? 0 : 1),
);
Expand All @@ -33,14 +32,7 @@ export default ({
setScrollIndicatorContainerHeight,
] = useState(1);

const handleScroll = (value) => {
const {nativeEvent: { contentOffset }} = value;
/**
* Propagating onScroll event upwards in case onScroll prop is provided
*/
if (onScroll && typeof onScroll === 'function') {
onScroll(value);
}
const handleScroll = ({ contentOffset }) => {
//Calculation scroll indicator position based on child height and scrollView view height)
const movePercent =
contentOffset.y /
Expand Down Expand Up @@ -99,12 +91,15 @@ export default ({
onLayout={e =>
setVisibleScrollPartHeight(e.nativeEvent.layout.height)
}
onScroll={handleScroll}
onScroll={(e) => {
props.onScrollListener(e)
handleScroll(e.nativeEvent)
}}
scrollEventThrottle={16}
onMomentumScrollEnd={() => runHideTimer()}
onScrollBeginDrag={() => showIndicator()}
showsVerticalScrollIndicator={false}
{...propsToSpread}
{...props}
>
{children}
</ScrollView>
Expand Down