npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

shaunc-ember-collection

v0.0.1

Published

Optimized display for large lists of objects in ember.

Downloads

1

Readme

ListView

Circle CI

An efficient incremental rendering list view for large lists.

ListView works on major modern browsers and also on major mobile devices (iOS, Android). However, there are known issues with using ListView on mobile web (if you have a long list and you're touch-scrolling it very fast, you'll see that items in your list start to disappear and after some lag appear again). That happens because some mobile browsers do not emit scroll events during the momentum scroll phase that ListView needs to capture. Also, if the browser is under heavy load, it can just stop emitting some events.

If you do experience this problem. We offer an API compatible VirtualListView that does the momentum scroll entirely in JS. However, note that VirtualListView doesn't have a native scroll bar. This is something that we need to work on for future releases of ListView

Downloads

Latest:

Table of Contents

  1. Usage
  2. Subclassing
  3. Build it
  4. How it works
  5. Run unit tests
  6. Caveats

Dependencies

Both ListView and VirtualListView need jquery, handlebars, ember.js.

VirtualListView need an additional dependency: zynga scroller.

Demo

Please, take a look at our live demo and jsbin links: first and second.

Submitting bugs

Please, attach code samples or links to jsbin or jsfiddle. It would help us greatly to help you and to improve ember list view.

Installation

Install ListView with EmberCLI using this command.

ember install ember-list-view

Usage

First, let's create a template:

{{#ember-list items=model height=500 rowHeight=50 width=500}}
  {{name}}
{{/ember-list}}

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.

Subclassing

Here's an example of how to create your version of ListView.

Create a my-list.js in your project's /views directory.

// in views/my-list.js

import ListView from 'ember-list-view';
import ListItemView from 'ember-list-view/list-item-view';

// extending ListView
// customize the row views by subclassing ListItemView
// and specifying the itemViewClass property in the Ember.ListView definition
export default ListView.extend({
  height: 500,
  rowHeight: 50,
  itemViewClass: ListItemView.extend({templateName: "my-list-item"})
});

Use the {{view}} helper in your template.

{{view 'my-list' content=model}}

Create a my-list-item.hbs in your project's /templates directory.

{{name}}

Return data from your route's model hook.

// define default index route and pushing some data to content
export default Ember.Route.extend({
  model: function() {
    var items = [];
    for (var i = 0; i < 10000; i++) {
      items.push({name: "Item " + i});
    }
    return items;
  }
});

Unfortunately, if you want to customize item template, you would have to use ListItemView and create an additional template, as you see above. You cannot specify templateName parameter directly on ListView because it's derived from Ember.ContainerView and it cannot have a template.

Changing height and width of ListView during runtime

The height and width of the entire ListView can be adjusted at run-time. When this occurs the ListView will transform existing view items to the new locations, and create and position any new view items that might be needed. This is meant to make resizing as cheap as possible.

import ListView from 'ember-list-view';

export default ListView.extend({
  height: 500,
  width: 960,
  adjustLayout: function(newWidth, newHeight) {
    this.set('width', newWidth);
    this.set('height', newHeight);
  }
});

Required parameters

You must specify the height and row-Height parameters because ListView will try to fill visible area with rows. If you would like to have multiple columns, then you need to specify element-width, as well as width.

import ListView from 'ember-list-view';
import ListItemView from 'ember-list-view/list-item-view';

export default ListView.extend({
  height: 500,
  rowHeight: 50,
  elementWidth: 80,
  width: 500,
  itemViewClass: ListItemView.extend( { templateName: "row-item" } )
});

Required CSS

You must manually add the following classes to your application's CSS file. Failure to do so will lead to overlapping items.

.ember-list-view {
  overflow: auto;
  position: relative;
}
.ember-list-item-view {
  position: absolute;
}

Build It

  1. git clone https://github.com/emberjs/list-view.git
  2. cd list-view
  3. npm install (implicitly runs bower install as a postinstall)
  4. ember build

How it works

ListView 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.

Running unit tests

npm install
npm test

Caveats

Things we are aware about and are on the list to fix.

  • classNameBindings and attributeBindings won't work properly on ListItemView after view's recycle. Using it should be avoided. Demo.

Thanks

A lot of the work was sponsored by Yapp Labs.