view-list
An infinite scrolling list view element built on a virtual DOM.
Example
View a live example displaying 200k rows: http://shama.github.io/view-list
Render the ViewList using virtual-dom:
var ViewList = // Create an instance of our view list in document.bodyvar viewlist = appendTo: documentbody // Create some data to add to the listvar data = 'one' 'two' 'three' // Render the dataviewlist // Listen for scroll events coming upviewlist // Every second, append a new rowvar i = 0
API
var list = new ViewList(params)
params
can be (in addition to the virtual-dom
parameters):
-
tagName
: The tag to use. Default'ul'
. -
childTagName
: The tag to use for child elements. Default'li'
. -
className
: The classes to use on main element. Default'view-list'
. -
topClassName
: The classes to use on top element. Default'.top'
. -
bottomClassName
: The classes to use on bottom element. Default'.bottom'
. -
element
: The DOM element of the list. -
height
: The total height of the container. Default500
. -
rowHeight
: The height of each row. Default30
. -
eachrow
: A function that gets called for each row to return a custom element per row. Default:function (row) { return this.html(this.childTagName, { style: { height: this.rowHeight } }, [row]) }
Events
Listen for events with list.addEventListener(name, function () {})
.
load
: Called when element has loaded.scroll
: Called when element has been scrolled.
license
(c) 2016 Kyle Robinson Young. MIT License