2.0.0 • Published 8 years ago
scrollblum v2.0.0
ScrollBlum
A petite vanilla js virtual list. Derived from the Google Chrome Console Source.
The current state of frameworky virtual list libraries perplexed "The Blum" and was enough to make the man snap out of his perpetual medicated state, to build a tiny and performant vanilla js virtual list.
Example
const scrollBlum = require('scrollblum');
const sb = new scrollBlum('.list', {
rowsCount: 100,
rowHeight: 150,
rowRenderer: ((index) => {
return document.createElement('div')
})
});
// Used to update the row height on an index
sb.setRowHeight(10, 200);Install
npm i scrollblum --saveRun Example
npm startUsage
scrollBlum(container, options)Container The dom node container to append the list to. Could be a classname or dom node selector. (String | node)
Options:
rowsCountThe number of rows on the containerrowHeightThe height of a single rowrowRendererShould return the dom node to be rendered as a row (node)overscanCountThe number of extra elements to render above/below the visible items (inspired by react-tiny-virtual-list)
Methods:
setRowHeight(index, height)Update the row height for a row at a particular index.scrollToIndexThe index in the list to scroll to
Events:
scroll-endEmitted at end of the scroll