Skip to content

Instantly share code, notes, and snippets.

@sueLan
Created March 5, 2020 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sueLan/4883477e115184460ecebc0641a4882e to your computer and use it in GitHub Desktop.
Save sueLan/4883477e115184460ecebc0641a4882e to your computer and use it in GitHub Desktop.
for (let idx = first; idx <= last; idx++) {
const metrics = getFrameMetrics(idx);
if (!metrics) {
continue;
}
// The top of current item cell, relative to the screen
const top = metrics.offset - scrollOffset;
// The bottom of current item cell
const bottom = top + metrics.length;
if (top < viewportHeight && bottom > 0) {
firstVisible = idx;
if (
_isViewable(
viewAreaMode,
viewablePercentThreshold,
top,
bottom,
viewportHeight,
metrics.length,
)
) {
viewableIndices.push(idx);
}
} else if (firstVisible >= 0) {
break;
}
}
return viewableIndices;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment