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

Side by Side Diff: sky/sdk/lib/widgets/fixed_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
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:math' as math; 5 import 'dart:math' as math;
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/scrollable.dart'; 9 import 'package:sky/widgets/scrollable.dart';
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 double drawStart = scrollOffset + alignmentDelta; 78 double drawStart = scrollOffset + alignmentDelta;
79 itemShowIndex = math.max(0, (drawStart / itemHeight).floor()); 79 itemShowIndex = math.max(0, (drawStart / itemHeight).floor());
80 80
81 offsetY = -alignmentDelta; 81 offsetY = -alignmentDelta;
82 } 82 }
83 } 83 }
84 84
85 List<Widget> items = buildItems(itemShowIndex, itemShowCount); 85 List<Widget> items = buildItems(itemShowIndex, itemShowCount);
86 assert(items.every((item) => item.key != null)); 86 assert(items.every((item) => item.key != null));
87 87
88 // TODO(ianh): Refactor this so that it does the building in the
89 // same frame as the size observing, similar to BlockViewport, but
90 // keeping the fixed-height optimisations.
88 return new SizeObserver( 91 return new SizeObserver(
89 callback: _handleSizeChanged, 92 callback: _handleSizeChanged,
90 child: new Viewport( 93 child: new Viewport(
91 offset: offsetY, 94 offset: offsetY,
92 child: new Container( 95 child: new Container(
93 padding: padding, 96 padding: padding,
94 child: new Block(items) 97 child: new Block(items)
95 ) 98 )
96 ) 99 )
97 ); 100 );
98 } 101 }
99 102
100 List<Widget> buildItems(int start, int count); 103 List<Widget> buildItems(int start, int count);
101 104
102 } 105 }
OLDNEW
« no previous file with comments | « no previous file | sky/sdk/lib/widgets/scrollable_viewport.dart » ('j') | sky/sdk/lib/widgets/variable_height_scrollable.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698