[Effen] Prevent scrolling past the bottom of a scrollable list.

- make the ScrollBehavior instance long-lived, rather than recreating
  it each time we update the list contents.
- have OverscrollBehavior track the total height of the contents and
  the height of the scrollable region, so that it can determine when
  to stop scrolling down.
- teach OverscrollBehavior about how to determine when to stop
  scrolling down, and how to bounce when it's too far down.
- replace the 'energy' concept in Particles with a method that sets
  the energy and direction at the same time, instead of assuming that
  the direction is always positive when setting energy.
- make FixedHeightScrollable lists track the number of items in the
  list and have them update their ScrollBehavior regarding this
  information as it changes.
- track how many items are currently showing in the list stock list.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1097373002
This commit is contained in:
Hixie 2015-04-21 13:20:30 -07:00
parent 23283319bc
commit ebc879babf

View file

@ -16,12 +16,15 @@ class Stocklist extends FixedHeightScrollable {
Object key,
this.stocks,
this.query
}) : super(key: key, scrollBehavior: new OverscrollBehavior());
}) : super(key: key);
List<UINode> buildItems(int start, int count) {
return stocks
.where((stock) => query == null || stock.symbol.contains(
new RegExp(query, caseSensitive: false)))
var filteredStocks = stocks.where((stock) {
return query == null ||
stock.symbol.contains(new RegExp(query, caseSensitive: false));
});
itemCount = filteredStocks.length;
return filteredStocks
.skip(start)
.take(count)
.map((stock) => new StockRow(stock: stock))