| OLD | NEW |
| 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:vector_math/vector_math.dart'; | 7 import 'package:vector_math/vector_math.dart'; |
| 8 | 8 |
| 9 import '../animation/scroll_behavior.dart'; | 9 import '../animation/scroll_behavior.dart'; |
| 10 import 'basic.dart'; | 10 import 'basic.dart'; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 double _height; | 44 double _height; |
| 45 void _handleSizeChanged(Size newSize) { | 45 void _handleSizeChanged(Size newSize) { |
| 46 setState(() { | 46 setState(() { |
| 47 _height = newSize.height; | 47 _height = newSize.height; |
| 48 scrollBehavior.containerHeight = _height; | 48 scrollBehavior.containerHeight = _height; |
| 49 }); | 49 }); |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool scrollTo(double newScrollOffset) { |
| 53 if (_height != null && _height > 0.0) { |
| 54 double maxScrollOffset = math.max(0.0, itemCount * itemHeight - _height); |
| 55 newScrollOffset = math.min(newScrollOffset, maxScrollOffset); |
| 56 } |
| 57 return super.scrollTo(newScrollOffset); |
| 58 } |
| 59 |
| 52 Widget buildContent() { | 60 Widget buildContent() { |
| 53 var itemShowIndex = 0; | 61 var itemShowIndex = 0; |
| 54 var itemShowCount = 0; | 62 var itemShowCount = 0; |
| 55 | 63 |
| 56 Matrix4 transform = new Matrix4.identity(); | 64 Matrix4 transform = new Matrix4.identity(); |
| 57 | 65 |
| 58 if (_height != null && _height > 0.0) { | 66 if (_height != null && _height > 0.0) { |
| 59 if (scrollOffset < 0.0) { | 67 if (scrollOffset < 0.0) { |
| 60 double visibleHeight = _height + scrollOffset; | 68 double visibleHeight = _height + scrollOffset; |
| 61 itemShowCount = (visibleHeight / itemHeight).round() + 1; | 69 itemShowCount = (visibleHeight / itemHeight).round() + 1; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 86 child: new Block(items) | 94 child: new Block(items) |
| 87 ) | 95 ) |
| 88 ) | 96 ) |
| 89 ) | 97 ) |
| 90 ); | 98 ); |
| 91 } | 99 } |
| 92 | 100 |
| 93 List<Widget> buildItems(int start, int count); | 101 List<Widget> buildItems(int start, int count); |
| 94 | 102 |
| 95 } | 103 } |
| OLD | NEW |