An efficient incremental rendering component with support for custom layouts and large lists.
TODO - Need to publish addon.
ember install ember-collection
TODO - Create twiddles with examples. Needs the addon to be published first?
TODO - Create a base ember twiddle with EmberCollection setup.
It would help us greatly to help you and to improve ember collection.
The height of the collection is inferred from its nearest relative parent. This is so you can just use CSS to style the container.
So, first make sure the collection has a parent with position: relative
, and
then render a template:
Next, let's feed our template with some data:
// define index route and return some data from model
export default Ember.Route.extend({
model: function() {
var items = [];
for (var i = 0; i < 10000; i++) {
items.push({name: "Item " + i});
}
return items;
}
});
Shazam! You should be able to see a scrollable area with 10,000 items in it.
You can pass estimated-width
and estimated-height
to the collection, for situations where the collection cannot infer its height from its parent (e.g., when there's no DOM in FastBoot).
Once the collection has been rendered, estimated-width
and estimated-height
have no effect.
TODO - Example of extending the component and providing a new layout
.
TODO - Talk about how the width
, height
and cell-layout
properties will change the layout.
You must specify the height
, width
and cell-layout
parameters because EmberCollection will try to fill visible area with items.
git clone https://github.com/emberjs/ember-collection.git
cd ember-collection
npm install
(implicitly runsbower install
as a postinstall)ember build
EmberCollection will create enough rows to fill the visible area (as defined by the height
property). It reacts to scroll events and reuses/repositions the rows as scrolled.
Please look at the unit tests for more information.
npm install
npm test
A lot of the work was sponsored by Yapp Labs, and some work was sponsored by Tightrope Media Systems.