Skip to content

Infinity Scroll

Set query: false to bypass Query when the loader owns fetching/cache policy.

For query usage, polling, shared sources and typed configuration defaults, see Server Data Queries. For signal, context?.signal and transport cancellation, see loader parameters and cancellation. For shared sources, see sharing reads; for consistency, see server ordering; for reconcile and onStatus, see pending edits and status.

The query concepts are explained individually:

HTMLRevoGridElement (Extended from global)

Section titled “HTMLRevoGridElement (Extended from global)”
interface HTMLRevoGridElement {
infinityScroll?: Partial<InfinityScrollConfig>;
'infinity-scroll'?: Partial<InfinityScrollConfig>;
}

HTMLRevoGridElementEventMap (Extended from global)

Section titled “HTMLRevoGridElementEventMap (Extended from global)”
interface HTMLRevoGridElementEventMap {
/**
* Event for scroll change
*
* @example
* ```typescript
* grid.addEventListener(SCROLL_CHANGE_EVENT, (e) => {
* console.log(e);
* });
*/
[SCROLL_CHANGE_EVENT]: ScrollChangeEvent;
}

AdditionalData (Extended from @revolist/revogrid)

Section titled “AdditionalData (Extended from @revolist/revogrid)”
interface AdditionalData {
/**
* Additional data property for infinity scroll
* @deprecated Use `grid.infinityScroll` instead.
*
* @example
* ```typescript
* const grid = document.createElement('revo-grid');
* grid.infinityScroll = {
* chunkSize: 50,
* bufferSize: 100,
* preloadThreshold: 0.75,
* total: 1000,
* loadData: async (skip, limit) => fetch(`/api/data?skip=${skip}&limit=${limit}`).then(response => response.json()),
* };
* ```
*/
infinityScroll?: Partial<InfinityScrollConfig>;
}

The InfinityScrollPlugin enables dynamic data loading as users scroll through the RevoGrid. It efficiently manages data chunks, loading new data when needed and cleaning up unused data to optimize memory usage.

Key Features:

  • Dynamic data loading based on scroll position with buffer zones
  • Pre-loads data ahead of scroll direction
  • Efficient memory management by cleaning up off-screen data
  • Configurable chunk size and buffer sizes
  • Support for both known and unknown total data sizes
  • Visual loading state for unloaded rows
  • Optional native polling/cache/retry policies through query

Existing loadData parameters stay valid; optional { signal } is appended at position ten.

Usage Example:

import { InfinityScrollPlugin } from '@revolist/revogrid-pro/infinity-scroll';
const grid = document.createElement('revo-grid');
grid.plugins = [InfinityScrollPlugin];
grid.infinityScroll = {
chunkSize: 50,
bufferSize: 100, // How many rows to keep in buffer
preloadThreshold: 0.75, // When to start loading more data (0-1)
total: 1000, // optional
query: { refetchInterval: 5000 }, // optional native polling
loadData: async (skip, limit, order, singleConditionFilters) => {
// Fetch data from your server
const response = await fetch(
`/api/data?skip=${skip}&limit=${limit}&order=${JSON.stringify(order)}`,
);
return response.json();
},
};

@see Query usage, configuration and cancellation

  • Optional sorting-capable-plugin: Integrates with a plugin exposing sorting state for remote infinite-scroll sorting.
  • Event integration beforefilterapply, beforequickfilterapply, beforesortingapply: Integrates with filter and quick-filter events to forward remote filter state to loadData.
class InfinityScrollPlugin {
destroy();
}

interface InfinityScrollLoadDataResult {
data: T[];
hasMore?: boolean;
total?: number;
}

Existing positional loader. Optional cancellation context is appended at position ten; existing callbacks may keep their current parameters and ignore it.

@see Loader parameters and cancellation

/**
* Existing positional loader. Optional cancellation context is appended at position ten;
* existing callbacks may keep their current parameters and ignore it.
* @see [Loader parameters and cancellation](https://pro.rv-grid.com/guides/server-data-queries/#loader-parameters-and-cancellation)
*/
export type InfinityScrollLoadData<T = any> = (
skip: number,
limit: number,
order?: { [key: ColumnProp]: 'asc' | 'desc' },
singleConditionFilters?: Record<ColumnProp, FilterCollectionItem>,
multiConditionFilters?: MultiFilterItem,
quickFilter?: QuickFilter,
temporalContext?: TemporalFilterContext,
/** Canonical filter tree, including nested groups and custom structured operators. */
filterAst?: FilterAst,
/** Captured clock and timezone context used to evaluate the canonical tree. */
executionContext?: FilterExecutionContext,
/** Position ten: cancellation for the shared physical request. Pass context?.signal to fetch. */
context?: { readonly signal: AbortSignal },
) => Promise<T[] | InfinityScrollLoadDataResult<T>>;

@see Query configuration types and defaults

interface InfinityScrollConfig {
/**
* Number of items to load per chunk
*/
chunkSize: number;
/**
* Number of rows to keep in buffer before and after visible area
*/
bufferSize: number;
/**
* When to start loading more data (0-1)
* ### Example 0.75 means start loading when 75% of the current chunk is visible
*/
preloadThreshold: number;
/**
* Total number of items available (if known)
* Optional - set to undefined for unknown total
*/
total?: number;
/**
* Function to load data from server
* @param skip - Number of items to skip
* @param limit - Number of items to load
* @param order - Current remote sorting state
* @param singleConditionFilters - Filter collection with at most one condition per column
* @param multiConditionFilters - Complete advanced filter model, including multiple conditions per column
* @param quickFilter - Global quick-filter payload (position six).
* @param temporalContext - Resolved temporal filter semantics (position seven).
* @param filterAst - Canonical advanced-filter tree (position eight).
* @param executionContext - Captured clock/timezone context (position nine).
* @param context - Optional { signal } cancellation context (position ten).
* @see [Loader parameters and cancellation](https://pro.rv-grid.com/guides/server-data-queries/#loader-parameters-and-cancellation)
* @returns Promise with loaded data array
* or object with explicit pagination state
*/
loadData: InfinityScrollLoadData<T>;
/**
* Optional native polling, freshness, retry, shared-source and reconciliation options.
* @see [Query configuration types and defaults](https://pro.rv-grid.com/guides/server-data-queries/#configuration-types)
*/
query?: import('@revolist/data-query').LoadQueryOptions<
T[] | InfinityScrollLoadDataResult<T>
>;
}

ResolvedInfinityScrollConfig (Extended from index.ts)

Section titled “ResolvedInfinityScrollConfig (Extended from index.ts)”
interface ResolvedInfinityScrollConfig {
dynamicChunkSize?: boolean;
}

interface ScrollChangeEvent {
/**
* Number of items to skip
*/
skip: number;
/**
* Number of items to load
*/
limit: number;
}

SCROLL_CHANGE_EVENT: string;

INFINITY_SCROLL_ROW_SOURCE_OWNER: string;

INFINITY_SCROLL_UNLOADED_ROW: typeof INFINITY_SCROLL_UNLOADED_ROW;