@@ -14,6 +14,7 @@ export interface Props {
14
14
height ?: number | string ;
15
15
scrollableTarget ?: ReactNode ;
16
16
hasChildren ?: boolean ;
17
+ inverse ?: boolean ;
17
18
pullDownToRefresh ?: boolean ;
18
19
pullDownToRefreshContent ?: ReactNode ;
19
20
releaseToRefreshContent ?: ReactNode ;
@@ -234,6 +235,28 @@ export default class InfiniteScroll extends Component<Props, State> {
234
235
} ) ;
235
236
} ;
236
237
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
+
237
260
isElementAtBottom (
238
261
target : HTMLElement ,
239
262
scrollThreshold : string | number = 0.8
@@ -275,7 +298,9 @@ export default class InfiniteScroll extends Component<Props, State> {
275
298
// prevents multiple triggers.
276
299
if ( this . actionTriggered ) return ;
277
300
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 ) ;
279
304
280
305
// call the `next` function in the props to trigger the next data fetch
281
306
if ( atBottom && this . props . hasMore ) {
0 commit comments