Browse files

Fix deltatime calculation.

This is necessary to fix an extraneous warning when a VirtualizedList is constructed on the first frame.

On the first frame, the dt is huge (ie, time since epoch).
On the second frame (which may legitimately be slow as a result of a lot to render), it will then assume there were two consecutive slow frames, and print a warning:
  "VirtualizedList: You have a large list that is slow to update..."
Closes #14393

Differential Revision: D5210467

Pulled By: sahrens

fbshipit-source-id: 2e79218c3d66a4a9df4884f328a125047ef264ed
  • Loading branch information...
mikelambert authored and facebook-github-bot committed Jun 8, 2017
1 parent 62b20ce commit 5840a9051d7a4e492e889d7162ae85d74b3c92d1
Showing with 3 additions and 1 deletion.
  1. +3 −1 Libraries/Lists/VirtualizedList.js
@@ -734,7 +734,9 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
const visibleLength = this._selectLength(e.nativeEvent.layoutMeasurement);
const contentLength = this._selectLength(e.nativeEvent.contentSize);
const offset = this._selectOffset(e.nativeEvent.contentOffset);
const dt = Math.max(1, timestamp - this._scrollMetrics.timestamp);
const dt = this._scrollMetrics.timestamp
? Math.max(1, timestamp - this._scrollMetrics.timestamp)
: 1;
if (dt > 500 && this._scrollMetrics.dt > 500 && (contentLength > (5 * visibleLength)) &&
!this._hasWarned.perf) {

0 comments on commit 5840a90

Please sign in to comment.