0.1.7 • Published 7 years ago

test-angular-infinite-list v0.1.7

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

A tiny but mighty list virtualization library for angular, with zero dependencies 💪

  • Tiny & dependency free – Only 3kb gzipped
  • Render millions of items, without breaking a sweat
  • Scroll to index or set the initial scroll offset
  • Supports fixed or variable heights/widths
  • Vertical or Horizontal lists

This library is transplanted from react-tiny-virtual-list and react-virtualized.

Check out the demo for some examples.

Getting Started

Using npm:

npm install angular-infinite-list --save

Import angular Infinite list module into your app module

import { InfiniteListModule } from 'angular-infinite-list';

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    InfiniteListModule,
    ...

Wrap Infinite list tag around list items;

<infinitelist
    [width]='"100%"' 
    [height]='500' 
    [data]='data' 
    [itemSize]='50' 
    (update)='event = $event'>
        <div *ngFor="let item of event?.items; let i=index;" [ngStyle]="event.getStyle(i)">
            item{{event.start + i}} : {{item|json}}
        </div>
</infinitelist>

Other usage;

<div infinitelist
    [width]='"100%"' 
    [height]='500' 
    [data]='data' 
    [itemSize]='50' 
    (update)='event = $event'>
        <div *ngFor="let item of event?.items; let i=index;" [ngStyle]="event.getStyle(i)">
            {{item|json}}
        </div>
</div>

Prop Types

PropertyTypeRequired?Description
widthNumber or String*Width of List. This property will determine the number of rendered items when scrollDirection is 'horizontal'.
heightNumber or String*Height of List. This property will determine the number of rendered items when scrollDirection is 'vertical'.
dataany[]The data that builds the templates within the Infinite scroll.
itemSizeEither a fixed height/width (depending on the scrollDirection), an array containing the heights of all the items in your list, or a function that returns the height of an item given its index: (index: number): number
scrollDirectionStringWhether the list should scroll vertically or horizontally. One of 'vertical' (default) or 'horizontal'.
scrollOffsetNumberCan be used to control the scroll offset; Also useful for setting an initial scroll offset
scrollToIndexNumberItem index to scroll to (by forcefully scrolling if necessary)
scrollToAlignmentStringUsed in combination with scrollToIndex, this prop controls the alignment of the scrolled to item. One of: 'start', 'center', 'end' or 'auto'. Use 'start' to always align items to the top of the container and 'end' to align them bottom. Use 'center' to align them in the middle of the container. 'auto' scrolls the least amount possible to ensure that the specified scrollToIndex item is fully visible.
overscanCountNumberNumber of extra buffer items to render above/below the visible items. Tweaking this can help reduce scroll flickering on certain browsers/devices.
estimatedItemSizeNumberUsed to estimate the total size of the list before all of its items have actually been measured. The estimated total height is progressively adjusted as items are rendered.
updateOutputThis event is fired every time when dom scroll. The event sent by the parameter is a ILEvent object.

* Width may only be a string when scrollDirection is 'vertical'. Similarly, Height may only be a string if scrollDirection is 'horizontal'

The IILEvent interface

export interface IILEvent {
    items: any[],
    offset: number,
    getStyle(index: number): any,
    data?: any[],
    start?: number,
    stop?: number
}

Reporting Issues

Found an issue? Please report it along with any relevant details to reproduce it.

Acknowledgments

This library is transplanted from react-tiny-virtual-list and react-virtualized. Thanks for the great works of author Claudéric Demers ❤️

License

is available under the MIT License.

0.1.7

7 years ago

0.1.6

7 years ago