DEV Community

Discussion on: Build your Own Virtual Scroll - Part I

Collapse
 
hassam7 profile image
Hassam Ali

let visibleNodesCount = Math.ceil(viewportHeight / rowHeight) + 2 * nodePadding;
Thanks for the nice write up. There is one questions: whats the + 2 for in live above?

Collapse
 
adamklein profile image
adam klein

We add padding above and below the visible viewport, hence we double the nodePadding number - 2 * nodePadding