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_curve.dart'; | 5 import '../animation/scroll_behavior.dart'; |
6 import '../fn.dart'; | 6 import '../fn.dart'; |
7 import 'dart:math' as math; | 7 import 'dart:math' as math; |
8 import 'dart:sky' as sky; | 8 import 'dart:sky' as sky; |
9 import 'scrollable.dart'; | 9 import 'scrollable.dart'; |
10 | 10 |
11 abstract class FixedHeightScrollable extends Scrollable { | 11 abstract class FixedHeightScrollable extends Scrollable { |
12 // TODO(rafaelw): This component really shouldn't have an opinion | 12 // TODO(rafaelw): This component really shouldn't have an opinion |
13 // about how it is sized. The owning component should decide whether | 13 // about how it is sized. The owning component should decide whether |
14 // it's explicitly sized or flexible or whatever... | 14 // it's explicitly sized or flexible or whatever... |
15 static final Style _style = new Style(''' | 15 static final Style _style = new Style(''' |
16 overflow: hidden; | 16 overflow: hidden; |
17 position: relative; | 17 position: relative; |
18 flex: 1; | 18 flex: 1; |
19 will-change: transform;''' | 19 will-change: transform;''' |
20 ); | 20 ); |
21 | 21 |
22 static final Style _scrollAreaStyle = new Style(''' | 22 static final Style _scrollAreaStyle = new Style(''' |
23 position:relative; | 23 position:relative; |
24 will-change: transform;''' | 24 will-change: transform;''' |
25 ); | 25 ); |
26 | 26 |
27 double _height = 0.0; | 27 double _height = 0.0; |
28 double _itemHeight; | 28 double _itemHeight; |
29 | 29 |
30 FixedHeightScrollable({ | 30 FixedHeightScrollable({ |
31 Object key, | 31 Object key, |
32 ScrollCurve scrollCurve | 32 ScrollBehavior scrollBehavior |
33 }) : super(key: key, scrollCurve: scrollCurve); | 33 }) : super(key: key, scrollBehavior: scrollBehavior); |
34 | 34 |
35 void didMount() { | 35 void didMount() { |
36 super.didMount(); | 36 super.didMount(); |
37 var root = getRoot(); | 37 var root = getRoot(); |
38 var item = root.firstChild.firstChild; | 38 var item = root.firstChild.firstChild; |
39 sky.ClientRect scrollRect = root.getBoundingClientRect(); | 39 sky.ClientRect scrollRect = root.getBoundingClientRect(); |
40 sky.ClientRect itemRect = item.getBoundingClientRect(); | 40 sky.ClientRect itemRect = item.getBoundingClientRect(); |
41 assert(scrollRect.height > 0); | 41 assert(scrollRect.height > 0); |
42 assert(itemRect.height > 0); | 42 assert(itemRect.height > 0); |
43 | 43 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 children: [ | 78 children: [ |
79 new Container( | 79 new Container( |
80 styles: [_scrollAreaStyle], | 80 styles: [_scrollAreaStyle], |
81 inlineStyle: transformStyle, | 81 inlineStyle: transformStyle, |
82 children: buildItems(itemNumber, drawCount) | 82 children: buildItems(itemNumber, drawCount) |
83 ) | 83 ) |
84 ] | 84 ] |
85 ); | 85 ); |
86 } | 86 } |
87 } | 87 } |
OLD | NEW |