|
@@ -17,6 +17,7 @@ type SectionFooterLoadProps = {
|
|
label: string
|
|
label: string
|
|
fetchMore: () => Promise<void>
|
|
fetchMore: () => Promise<void>
|
|
reachedEnd: boolean
|
|
reachedEnd: boolean
|
|
|
|
+ loadingTriggerOffset?: number
|
|
}
|
|
}
|
|
|
|
|
|
type SectionFooterPaginationProps = {
|
|
type SectionFooterPaginationProps = {
|
|
@@ -27,6 +28,7 @@ type SectionFooterInfiniteLoadingProps = {
|
|
type: 'infinite'
|
|
type: 'infinite'
|
|
fetchMore: () => Promise<void>
|
|
fetchMore: () => Promise<void>
|
|
reachedEnd: boolean
|
|
reachedEnd: boolean
|
|
|
|
+ loadingTriggerOffset?: number
|
|
}
|
|
}
|
|
|
|
|
|
export type SectionFooterProps =
|
|
export type SectionFooterProps =
|
|
@@ -35,9 +37,11 @@ export type SectionFooterProps =
|
|
| SectionFooterPaginationProps
|
|
| SectionFooterPaginationProps
|
|
| SectionFooterInfiniteLoadingProps
|
|
| SectionFooterInfiniteLoadingProps
|
|
|
|
|
|
-const InfiniteLoaderMargin = styled.div`
|
|
|
|
|
|
+const InfiniteLoaderMargin = styled.div<{ loadingTriggerOffset?: number }>`
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 1px;
|
|
height: 1px;
|
|
|
|
+ position: absolute;
|
|
|
|
+ bottom: ${({ loadingTriggerOffset }) => (loadingTriggerOffset ? `${loadingTriggerOffset}px` : 0)};
|
|
`
|
|
`
|
|
export const SectionFooter = (props: SectionFooterProps) => {
|
|
export const SectionFooter = (props: SectionFooterProps) => {
|
|
const [isSwitchedToInfinite, setIsSwitchedToInfinite] = useState(false)
|
|
const [isSwitchedToInfinite, setIsSwitchedToInfinite] = useState(false)
|
|
@@ -76,12 +80,12 @@ export const SectionFooter = (props: SectionFooterProps) => {
|
|
{props.label}
|
|
{props.label}
|
|
</Button>
|
|
</Button>
|
|
) : (
|
|
) : (
|
|
- <InfiniteLoaderMargin ref={ref} />
|
|
|
|
|
|
+ <InfiniteLoaderMargin ref={ref} loadingTriggerOffset={props.loadingTriggerOffset} />
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
if (props.type === 'infinite' && !props.reachedEnd && !isLoading) {
|
|
if (props.type === 'infinite' && !props.reachedEnd && !isLoading) {
|
|
- return <InfiniteLoaderMargin ref={ref} />
|
|
|
|
|
|
+ return <InfiniteLoaderMargin ref={ref} loadingTriggerOffset={props.loadingTriggerOffset} />
|
|
}
|
|
}
|
|
|
|
|
|
if (props.type === 'link') {
|
|
if (props.type === 'link') {
|