OLD | NEW |
1 part of widgets; | 1 part of widgets; |
2 | 2 |
3 abstract class FixedHeightScrollable extends Component { | 3 abstract class FixedHeightScrollable extends Component { |
4 | 4 |
5 static Style _style = new Style(''' | 5 static Style _style = new Style(''' |
6 overflow: hidden; | 6 overflow: hidden; |
7 position: relative; | 7 position: relative; |
8 will-change: transform;''' | 8 will-change: transform;''' |
9 ); | 9 ); |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 double drawStart = _scrollOffset + alignmentDelta; | 43 double drawStart = _scrollOffset + alignmentDelta; |
44 int itemNumber = (drawStart / itemHeight).floor(); | 44 int itemNumber = (drawStart / itemHeight).floor(); |
45 | 45 |
46 var transformStyle = | 46 var transformStyle = |
47 'transform: translateY(${(alignmentDelta).toStringAsFixed(2)}px)'; | 47 'transform: translateY(${(alignmentDelta).toStringAsFixed(2)}px)'; |
48 | 48 |
49 var items = renderItems(itemNumber, drawCount); | 49 var items = renderItems(itemNumber, drawCount); |
50 | 50 |
51 return new Container( | 51 return new Container( |
52 style: _style, | 52 style: _style, |
53 onFlingStart: _handleFlingStart, | |
54 onFlingCancel: _handleFlingCancel, | |
55 onScrollUpdate: _handleScrollUpdate, | |
56 onWheel: _handleWheel, | |
57 children: [ | 53 children: [ |
58 new Container( | 54 new Container( |
59 style: _scrollAreaStyle, | 55 style: _scrollAreaStyle, |
60 inlineStyle: transformStyle, | 56 inlineStyle: transformStyle, |
61 children: items | 57 children: items |
62 ) | 58 ) |
63 ] | 59 ] |
64 ); | 60 ) |
| 61 ..events.listen('gestureflingstart', _handleFlingStart) |
| 62 ..events.listen('gestureflingcancel', _handleFlingCancel) |
| 63 ..events.listen('gesturescrollupdate', _handleScrollUpdate) |
| 64 ..events.listen('wheel', _handleWheel); |
65 } | 65 } |
66 | 66 |
67 void willUnmount() { | 67 void willUnmount() { |
68 _stopFling(); | 68 _stopFling(); |
69 } | 69 } |
70 | 70 |
71 bool _scrollBy(double scrollDelta) { | 71 bool _scrollBy(double scrollDelta) { |
72 var newScrollOffset = _scrollOffset + scrollDelta; | 72 var newScrollOffset = _scrollOffset + scrollDelta; |
73 if (minOffset != null && newScrollOffset < minOffset) { | 73 if (minOffset != null && newScrollOffset < minOffset) { |
74 newScrollOffset = minOffset; | 74 newScrollOffset = minOffset; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 118 } |
119 | 119 |
120 void _handleFlingCancel(sky.Event event) { | 120 void _handleFlingCancel(sky.Event event) { |
121 _stopFling(); | 121 _stopFling(); |
122 } | 122 } |
123 | 123 |
124 void _handleWheel(sky.Event event) { | 124 void _handleWheel(sky.Event event) { |
125 _scrollBy(-event.offsetY); | 125 _scrollBy(-event.offsetY); |
126 } | 126 } |
127 } | 127 } |
OLD | NEW |