Cómo funciona

Desplazamiento virtual (virtualización real)

  • Constant DOM size - Only ~20 items in DOM regardless of total dataset
  • Performance - Can handle millions of items smoothly
  • Fixed heights - Requires items to have consistent, known heights
  • Use case - Tables, lists with uniform row heights
  • DOM strategy - Items added/removed dynamically as you scroll

Desplazamiento infinito (carga diferida)

  • Growing DOM - All loaded items stay in DOM
  • Performance - Good for hundreds/low thousands of items
  • Variable heights - Works with dynamic content heights
  • Use case - Feeds, timelines with rich content
  • DOM strategy - Items appended, never removed

Ejemplos de desplazamiento virtual

True virtualization - constant DOM size

Línea de tiempo - 5000 elementos

Solo ~20 elementos en el DOM en todo momento

Aún no compatible

True virtual scroll (windowed rendering) requires a custom JS hook that calculates visible indices from scroll position and row height, then only renders those rows. This is planned for a future release.

Por qué es complejo en LiveView

LiveView manages the DOM server-side. True virtualization needs client-side DOM manipulation that conflicts with LiveView's diffing. A proper implementation requires a dedicated JS hook that coordinates with the server to only request visible data windows.

Tabla - 10000 filas

Desplazamiento fluido por grandes conjuntos de datos

Aún no compatible

Virtual scroll for tables requires fixed row heights and a hook that renders spacer rows above/below the visible window. This approach works in LiveView but needs careful implementation to avoid conflicts with DOM patching.

Alternativa: paginación del lado del servidor

For large datasets, use the <.pager> component with server-side queries. This is more efficient than virtual scroll for most use cases since it transfers only the visible page of data.

Ejemplo de desplazamiento infinito

Lazy loading - items accumulate in DOM. Uses PureAdminInfiniteScroll hook.

Feed de línea de tiempo - desplazamiento infinito

Loads more items automatically as you scroll (20 of 200 loaded)

Uso del hook de desplazamiento infinito

    <div
      id="scroll-sentinel"
      phx-hook="PureAdminInfiniteScroll"
      data-event="load_more"
      data-has-more={to_string(@has_more)}
      data-throttle="500"
      data-root-margin="200px"
    >
      <.loader :if={@loading} />
    </div>
  
AtributoPredeterminadoDescripción
data-event load_more LiveView event name to push
data-has-more true Set to "false" to stop observing
data-root-margin 200px Preload buffer distance
data-throttle 500 Minimum ms between triggers

John Doe

Administrator

Configuración

Press Ctrl+K to preview the palette.
Sidebar
Display
Profile Panel
Body text size. All elements scale proportionally.
Comandos
🚀
Desplegar a entorno
Desplegar una rama a un entorno
g d
👤
Asignar a usuario
Asignar un elemento a un miembro del equipo
g a
🧭
Ir a la página
Navegar a una página
g g
🎨
Cambiar tema
Cambiar el tema visual
g t
Buscar
📦
Productos
Buscar productos
:products
📋
Pedidos
Buscar pedidos
:orders
👥
Usuarios
Buscar usuarios
:users
🧾
Facturas
Buscar facturas
:invoices