scrollToOffset
This commit is contained in:
@@ -113,11 +113,27 @@ export const FlatList = React.forwardRef(function FlatListImpl<ItemT>(
|
|||||||
props.dataSet.stableGutters = '1'
|
props.dataSet.stableGutters = '1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const nativeRef = React.useRef(null)
|
||||||
|
React.useImperativeHandle(
|
||||||
|
ref,
|
||||||
|
() => ({
|
||||||
|
scrollToOffset({animated, offset}) {
|
||||||
|
nativeRef.current.scrollTo({
|
||||||
|
x: 0,
|
||||||
|
y: offset,
|
||||||
|
animated,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
[],
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Animated.ScrollView
|
<Animated.ScrollView
|
||||||
{...props}
|
{...props}
|
||||||
style={[style, {overflowY: 'auto'}]}
|
style={[style, {overflowY: 'auto'}]}
|
||||||
ref={ref}>
|
ref={nativeRef}>
|
||||||
<View
|
<View
|
||||||
style={[styles.contentContainer, contentContainerStyle, pal.border]}>
|
style={[styles.contentContainer, contentContainerStyle, pal.border]}>
|
||||||
{data.map(item => (
|
{data.map(item => (
|
||||||
|
|||||||
Reference in New Issue
Block a user