airbnb / infinity

UITableViews for the web (DEPRECATED)
http://airbnb.io/infinity/
Other
2.8k stars 281 forks source link

Various Fixes #28

Closed grippy closed 8 years ago

grippy commented 11 years ago

I noticed an issue where ListView.prototype.append would take longer and longer if you were working with really long pages.

After digging into it:

This pull request makes it possible to do this now:

Assuming we have a list of DOM elements:

      for (var i = 0, len = $els.length, item; i < len; i++) {
        item = $($els[i]);
        if (i === 0) {
          item = infinity.convertToItem(this.listView, item);
          cache = item;
        } else {
          item = new infinity.ListItem(item);
          // pre-cache the height/width
          // so we don't spend anytime trying to compute them
          item.height = cache.height;
          item.width = cache.width;
          infinity.cacheCoordsFor(this.listView, item);
        }
        this.listView.append(item);
      }

In addition, I also added a few small enhancements to not compute the parent.height() every time hasVacancy is called.

It doesn't appear the build files were generated after merging the 2 previous pull requests.

I left some comments in there. I can take these out if you prefer.

ljharb commented 8 years ago

This project is no longer maintained, and is deprecated.