Skip to content

Commit a486bec

Browse files
committed
fix: 🐛 fix <ViewportObserverSensor> when threshold not spec
1 parent 9004447 commit a486bec

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/InfiniteScroll/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import {ViewportSensor} from '../ViewportSensor';
32
import {ViewportScrollSensor} from '../ViewportScrollSensor';
43

54
const h = React.createElement;

src/ViewportObserverSensor/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ export class ViewportObserverSensor extends Component<IViewportObserverSensorPro
5555
const entry = entries[0];
5656
const {intersectionRatio} = entry;
5757
const {threshold, onChange} = this.props;
58-
58+
const noThresholdAndTinyBitIsVisible = !!(!threshold && intersectionRatio);
59+
const visibleMoreOrEqualToThreshold = threshold
60+
? intersectionRatio >= threshold
61+
: intersectionRatio > threshold;
5962
const state = {
60-
visible: !!((!threshold && intersectionRatio) || (intersectionRatio >= threshold))
63+
visible: noThresholdAndTinyBitIsVisible || visibleMoreOrEqualToThreshold,
6164
};
6265

6366
this.setState(state);

0 commit comments

Comments
 (0)