@@ -14,6 +14,7 @@ export interface Props {
1414 height ?: number | string ;
1515 scrollableTarget ?: ReactNode ;
1616 hasChildren ?: boolean ;
17+ inverse ?: boolean ;
1718 pullDownToRefresh ?: boolean ;
1819 pullDownToRefreshContent ?: ReactNode ;
1920 releaseToRefreshContent ?: ReactNode ;
@@ -234,6 +235,28 @@ export default class InfiniteScroll extends Component<Props, State> {
234235 } ) ;
235236 } ;
236237
238+ isElementAtTop ( target : HTMLElement , scrollThreshold : string | number = 0.8 ) {
239+ const clientHeight =
240+ target === document . body || target === document . documentElement
241+ ? window . screen . availHeight
242+ : target . clientHeight ;
243+
244+ const threshold = parseThreshold ( scrollThreshold ) ;
245+
246+ if ( threshold . unit === ThresholdUnits . Pixel ) {
247+ return (
248+ target . scrollTop <
249+ threshold . value + clientHeight - target . scrollHeight ||
250+ target . scrollTop === 0
251+ ) ;
252+ }
253+ //targe.scrollTop for brave support
254+ return (
255+ target . scrollTop < threshold . value + clientHeight - target . scrollHeight ||
256+ target . scrollTop === 0
257+ ) ;
258+ }
259+
237260 isElementAtBottom (
238261 target : HTMLElement ,
239262 scrollThreshold : string | number = 0.8
@@ -275,7 +298,9 @@ export default class InfiniteScroll extends Component<Props, State> {
275298 // prevents multiple triggers.
276299 if ( this . actionTriggered ) return ;
277300
278- const atBottom = this . isElementAtBottom ( target , this . props . scrollThreshold ) ;
301+ const atBottom = this . props . inverse
302+ ? this . isElementAtTop ( target , this . props . scrollThreshold )
303+ : this . isElementAtBottom ( target , this . props . scrollThreshold ) ;
279304
280305 // call the `next` function in the props to trigger the next data fetch
281306 if ( atBottom && this . props . hasMore ) {
0 commit comments