shama / view-list

:scroll: An infinite scrolling list view element built on a virtual DOM.
http://shama.github.io/view-list
24 stars 4 forks source link

questions #5

Open vgoklani opened 9 years ago

vgoklani commented 9 years ago

Nice library! I have a few quick questions:

  1. Is there a way to prepend new items to the top, and have the elements fall off the bottom when the list size > some cutoff? like a twitter stream?
  2. Do you plan to support mobile rendering. The demo version renders on my iPhone, but it's not so smooth.
  3. How would you implement filtering? Do you filter the array first, and then re-render the table?

Thanks!

shama commented 9 years ago
  1. Modify the array and render:

    data.unshift('item on top')
    data = data.slice(0, 15)
    viewlist.render(data)
  2. It just renders DOM elements. It may not be optimized for mobile but it is supported. Rendering less or differently should produce smoother results but depends on the app.
  3. Yep, modify the array and render:

    data = data.filter(function (row) {
     return row === 'row we want'
    })
    viewlist.render(data)
vgoklani commented 9 years ago

Thanks!

Is it a simple process to extend this approach to a full table (with columns)? Also, how would you optimize for mobile?

shama commented 9 years ago

Yep! By default it uses ul/li but you can change that by setting the tagName to 'table' and childTagName to 'tr'. Then return rows with columns on eachrow.

I recommend extending this element if you're planning on something more sophisticated like that. Here is an example of someone else extending this element: https://github.com/sethvincent/data-cards

vgoklani commented 9 years ago

Almost have it, what do you mean by this: "Then return rows with columns on eachrow."