tbranyen / hyperlist

A performant virtual scrolling list utility capable of rendering millions of rows
Other
448 stars 45 forks source link

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

Closed tbranyen closed 7 years ago

tbranyen commented 7 years ago

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.

soyuka commented 7 years ago

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.

tbranyen commented 7 years ago

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

tbranyen commented 7 years ago

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

soyuka commented 7 years ago

Yes indeed!