Refresh on scroll-to-top by active section press (#1807)
parent
445f976881
commit
4de852ded8
|
@ -393,12 +393,8 @@ const FeedSection = React.forwardRef<SectionRef, FeedSectionProps>(
|
||||||
|
|
||||||
const onScrollToTop = useCallback(() => {
|
const onScrollToTop = useCallback(() => {
|
||||||
scrollElRef.current?.scrollToOffset({offset: -headerHeight})
|
scrollElRef.current?.scrollToOffset({offset: -headerHeight})
|
||||||
}, [scrollElRef, headerHeight])
|
|
||||||
|
|
||||||
const onPressLoadLatest = React.useCallback(() => {
|
|
||||||
onScrollToTop()
|
|
||||||
feed.refresh()
|
feed.refresh()
|
||||||
}, [feed, onScrollToTop])
|
}, [feed, scrollElRef, headerHeight])
|
||||||
|
|
||||||
React.useImperativeHandle(ref, () => ({
|
React.useImperativeHandle(ref, () => ({
|
||||||
scrollToTop: onScrollToTop,
|
scrollToTop: onScrollToTop,
|
||||||
|
@ -420,7 +416,7 @@ const FeedSection = React.forwardRef<SectionRef, FeedSectionProps>(
|
||||||
/>
|
/>
|
||||||
{(isScrolledDown || hasNew) && (
|
{(isScrolledDown || hasNew) && (
|
||||||
<LoadLatestBtn
|
<LoadLatestBtn
|
||||||
onPress={onPressLoadLatest}
|
onPress={onScrollToTop}
|
||||||
label="Load new posts"
|
label="Load new posts"
|
||||||
showIndicator={hasNew}
|
showIndicator={hasNew}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -558,13 +558,8 @@ const FeedSection = React.forwardRef<SectionRef, FeedSectionProps>(
|
||||||
|
|
||||||
const onScrollToTop = useCallback(() => {
|
const onScrollToTop = useCallback(() => {
|
||||||
scrollElRef.current?.scrollToOffset({offset: -headerHeight})
|
scrollElRef.current?.scrollToOffset({offset: -headerHeight})
|
||||||
}, [scrollElRef, headerHeight])
|
|
||||||
|
|
||||||
const onPressLoadLatest = React.useCallback(() => {
|
|
||||||
onScrollToTop()
|
|
||||||
feed.refresh()
|
feed.refresh()
|
||||||
}, [feed, onScrollToTop])
|
}, [feed, scrollElRef, headerHeight])
|
||||||
|
|
||||||
React.useImperativeHandle(ref, () => ({
|
React.useImperativeHandle(ref, () => ({
|
||||||
scrollToTop: onScrollToTop,
|
scrollToTop: onScrollToTop,
|
||||||
}))
|
}))
|
||||||
|
@ -586,7 +581,7 @@ const FeedSection = React.forwardRef<SectionRef, FeedSectionProps>(
|
||||||
/>
|
/>
|
||||||
{(isScrolledDown || hasNew) && (
|
{(isScrolledDown || hasNew) && (
|
||||||
<LoadLatestBtn
|
<LoadLatestBtn
|
||||||
onPress={onPressLoadLatest}
|
onPress={onScrollToTop}
|
||||||
label="Load new posts"
|
label="Load new posts"
|
||||||
showIndicator={hasNew}
|
showIndicator={hasNew}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue