tbranyen / hyperlist

A performant virtual scrolling list utility capable of rendering millions of rows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reason for having `setHeight` be a callback in `_getRow` callback

tbranyen opened this issue · comments

When using generate we now support returning an object with a height value. However, this used to be a callback and the specific use case is when the height is unknown until the element lands in the DOM.

Hmm might be slow.

  1. get element (height unknown), just append to the DOM (computes positioning based on itemHeight)
  2. get height => compute positioning again => redraw the showed element (here there will probably be a screen flick)

Or we need to:

  1. append to the DOM with opacity 0
  2. get element height from DOM
  3. compute positioning again
  4. redraw

Though, those are uneeded steps when height is known, and there will be more rendering.

What about two passes, first one lays everything out second pass sets correct offsets?

With this second approach I think it'd be doable without any HyperList code changes.

Yes indeed!