From ebc879babf31dc65eaab9515a7f64038f2e9cf75 Mon Sep 17 00:00:00 2001 From: Hixie Date: Tue, 21 Apr 2015 13:20:30 -0700 Subject: [PATCH] [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 --- examples/stocks/lib/stock_list.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/stocks/lib/stock_list.dart b/examples/stocks/lib/stock_list.dart index 2e6e5bbf1d9..78a8d64c6b4 100644 --- a/examples/stocks/lib/stock_list.dart +++ b/examples/stocks/lib/stock_list.dart @@ -16,12 +16,15 @@ class Stocklist extends FixedHeightScrollable { Object key, this.stocks, this.query - }) : super(key: key, scrollBehavior: new OverscrollBehavior()); + }) : super(key: key); List 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))