Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: sky/sdk/lib/widgets/variable_height_scrollable.dart

Issue 1234863004: Remove redundant setState() calls around scroll behaviour updates. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/widgets/scrollable_viewport.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:collection'; 5 import 'dart:collection';
6 6
7 import 'package:sky/animation/scroll_behavior.dart'; 7 import 'package:sky/animation/scroll_behavior.dart';
8 import 'package:sky/widgets/basic.dart'; 8 import 'package:sky/widgets/basic.dart';
9 import 'package:sky/widgets/block_viewport.dart'; 9 import 'package:sky/widgets/block_viewport.dart';
10 import 'package:sky/widgets/scrollable.dart'; 10 import 'package:sky/widgets/scrollable.dart';
(...skipping 12 matching lines...) Expand all
23 void syncFields(VariableHeightScrollable source) { 23 void syncFields(VariableHeightScrollable source) {
24 builder = source.builder; 24 builder = source.builder;
25 token = source.token; 25 token = source.token;
26 super.syncFields(source); 26 super.syncFields(source);
27 } 27 }
28 28
29 ScrollBehavior createScrollBehavior() => new OverscrollBehavior(); 29 ScrollBehavior createScrollBehavior() => new OverscrollBehavior();
30 OverscrollBehavior get scrollBehavior => super.scrollBehavior; 30 OverscrollBehavior get scrollBehavior => super.scrollBehavior;
31 31
32 void _handleSizeChanged(Size newSize) { 32 void _handleSizeChanged(Size newSize) {
33 setState(() { 33 scrollBehavior.containerSize = newSize.height;
hansmuller 2015/07/13 19:03:53 If the viewport's size changes, don't you want to
34 scrollBehavior.containerSize = newSize.height;
35 });
36 } 34 }
37 35
38 void _handleLayoutChanged( 36 void _handleLayoutChanged(
39 int firstVisibleChildIndex, 37 int firstVisibleChildIndex,
40 int visibleChildCount, 38 int visibleChildCount,
41 UnmodifiableListView<double> childOffsets, 39 UnmodifiableListView<double> childOffsets,
42 bool didReachLastChild) { 40 bool didReachLastChild
41 ) {
43 assert(childOffsets.length > 0); 42 assert(childOffsets.length > 0);
44 scrollBehavior.contentsSize = didReachLastChild ? childOffsets.last : double .INFINITY; 43 scrollBehavior.contentsSize = didReachLastChild ? childOffsets.last : double .INFINITY;
45 if (didReachLastChild && scrollOffset > scrollBehavior.maxScrollOffset) 44 if (didReachLastChild && scrollOffset > scrollBehavior.maxScrollOffset)
46 settleScrollOffset(); 45 settleScrollOffset();
47 } 46 }
48 47
49 Widget buildContent() { 48 Widget buildContent() {
50 return new SizeObserver( 49 return new SizeObserver(
51 callback: _handleSizeChanged, 50 callback: _handleSizeChanged,
52 child: new BlockViewport( 51 child: new BlockViewport(
53 builder: builder, 52 builder: builder,
54 onLayoutChanged: _handleLayoutChanged, 53 onLayoutChanged: _handleLayoutChanged,
55 startOffset: scrollOffset, 54 startOffset: scrollOffset,
56 token: token 55 token: token
57 ) 56 )
58 ); 57 );
59 } 58 }
60 } 59 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/scrollable_viewport.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698