Skip to content

Commit d5bacbb

Browse files
committed
FlatList(step 3): worked well when scroll
1 parent a2a0e3b commit d5bacbb

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Libraries/Lists/VirtualizedList.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
const Batchinator = require('Batchinator');
3636
import React from 'react';
37+
import ReactDOM from 'react-dom';
3738
import findNodeHandle from 'ReactfindNodeHandle';
3839
import RefreshControl from 'ReactRefreshControl';
3940
import ScrollView from 'ReactScrollView';
@@ -561,9 +562,16 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
561562
this.props.onScroll(e);
562563
}
563564
const timestamp = e.timeStamp;
564-
const visibleLength = this._selectLength(e.nativeEvent.layoutMeasurement);
565-
const contentLength = this._selectLength(e.nativeEvent.contentSize);
566-
const offset = this._selectOffset(e.nativeEvent.contentOffset);
565+
let target = ReactDOM.findDOMNode(this._scrollRef);
566+
const visibleLength = target[
567+
!this.props.horizontal ? 'offsetHeight' : 'offsetWidth'
568+
];
569+
const contentLength = target[
570+
!this.props.horizontal ? 'scrollHeight' : 'scrollWidth'
571+
];
572+
const offset = target[
573+
!this.props.horizontal ? 'scrollTop' : 'scrollLeft'
574+
];
567575
const dt = Math.max(1, timestamp - this._scrollMetrics.timestamp);
568576
if (dt > 500 && this._scrollMetrics.dt > 500 && (contentLength > (5 * visibleLength)) &&
569577
!this._hasWarned.perf) {

0 commit comments

Comments
 (0)