| 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 '../animation/scroll_behavior.dart'; | 5 import '../animation/scroll_behavior.dart'; |
| 6 import '../fn.dart'; | 6 import '../fn.dart'; |
| 7 import '../tracing.dart'; |
| 7 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 8 import 'dart:sky' as sky; | 9 import 'dart:sky' as sky; |
| 9 import 'dart:async'; | 10 import 'dart:async'; |
| 10 import 'scrollable.dart'; | 11 import 'scrollable.dart'; |
| 11 | 12 |
| 12 abstract class FixedHeightScrollable extends Scrollable { | 13 abstract class FixedHeightScrollable extends Scrollable { |
| 13 static final Style _style = new Style(''' | 14 static final Style _style = new Style(''' |
| 14 overflow: hidden; | 15 overflow: hidden; |
| 15 position: relative; | 16 position: relative; |
| 16 will-change: transform;''' | 17 will-change: transform;''' |
| 17 ); | 18 ); |
| 18 | 19 |
| 19 static final Style _scrollAreaStyle = new Style(''' | 20 static final Style _scrollAreaStyle = new Style(''' |
| 20 position:relative; | 21 position:relative; |
| 21 will-change: transform;''' | 22 will-change: transform;''' |
| 22 ); | 23 ); |
| 23 | 24 |
| 24 double _height = 0.0; | 25 double _height = 0.0; |
| 25 double _itemHeight; | 26 double _itemHeight; |
| 26 | 27 |
| 27 FixedHeightScrollable({ | 28 FixedHeightScrollable({ |
| 28 Object key, | 29 Object key, |
| 29 ScrollBehavior scrollBehavior | 30 ScrollBehavior scrollBehavior |
| 30 }) : super(key: key, scrollBehavior: scrollBehavior); | 31 }) : super(key: key, scrollBehavior: scrollBehavior); |
| 31 | 32 |
| 32 void _measureHeights() { | 33 void _measureHeights() { |
| 33 if (_itemHeight != null) | 34 trace('FixedHeightScrollable::_measureHeights', () { |
| 34 return; | 35 if (_itemHeight != null) |
| 35 var root = getRoot(); | 36 return; |
| 36 if (root == null) | 37 var root = getRoot(); |
| 37 return; | 38 if (root == null) |
| 38 var item = root.firstChild.firstChild; | 39 return; |
| 39 if (item == null) | 40 var item = root.firstChild.firstChild; |
| 40 return; | 41 if (item == null) |
| 41 sky.ClientRect scrollRect = root.getBoundingClientRect(); | 42 return; |
| 42 sky.ClientRect itemRect = item.getBoundingClientRect(); | 43 sky.ClientRect scrollRect = root.getBoundingClientRect(); |
| 43 assert(scrollRect.height > 0); | 44 sky.ClientRect itemRect = item.getBoundingClientRect(); |
| 44 assert(itemRect.height > 0); | 45 assert(scrollRect.height > 0); |
| 46 assert(itemRect.height > 0); |
| 45 | 47 |
| 46 setState(() { | 48 setState(() { |
| 47 _height = scrollRect.height; | 49 _height = scrollRect.height; |
| 48 _itemHeight = itemRect.height; | 50 _itemHeight = itemRect.height; |
| 51 }); |
| 49 }); | 52 }); |
| 50 } | 53 } |
| 51 | 54 |
| 52 Node buildContent() { | 55 Node buildContent() { |
| 53 var itemNumber = 0; | 56 var itemNumber = 0; |
| 54 var drawCount = 1; | 57 var drawCount = 1; |
| 55 var transformStyle = ''; | 58 var transformStyle = ''; |
| 56 | 59 |
| 57 if (_itemHeight == null) | 60 if (_itemHeight == null) |
| 58 new Future.microtask(_measureHeights); | 61 new Future.microtask(_measureHeights); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 83 children: [ | 86 children: [ |
| 84 new Container( | 87 new Container( |
| 85 style: _scrollAreaStyle, | 88 style: _scrollAreaStyle, |
| 86 inlineStyle: transformStyle, | 89 inlineStyle: transformStyle, |
| 87 children: buildItems(itemNumber, drawCount) | 90 children: buildItems(itemNumber, drawCount) |
| 88 ) | 91 ) |
| 89 ] | 92 ] |
| 90 ); | 93 ); |
| 91 } | 94 } |
| 92 } | 95 } |
| OLD | NEW |