| Index: sky/framework/components/scrollable.dart
|
| diff --git a/sky/framework/components/scrollable.dart b/sky/framework/components/scrollable.dart
|
| index dadcf775a67fd2c445a22c267f8231a0acfe1839..a9402fda9e4c80ebc33fbe371365e641a63528cc 100644
|
| --- a/sky/framework/components/scrollable.dart
|
| +++ b/sky/framework/components/scrollable.dart
|
| @@ -17,6 +17,10 @@ double _velocityForFlingGesture(sky.GestureEvent event) {
|
| -event.velocityY)) / _kMillisecondsPerSecond;
|
| }
|
|
|
| +abstract class ScrollNotifiee {
|
| + bool ancestorScrolled(Scrollable ancestor);
|
| +}
|
| +
|
| abstract class Scrollable extends Component {
|
| ScrollBehavior scrollBehavior;
|
| double get scrollOffset => _scrollOffset;
|
| @@ -43,12 +47,43 @@ abstract class Scrollable extends Component {
|
| );
|
| }
|
|
|
| + List<ScrollNotifiee> _registeredScrollNotifiees;
|
| +
|
| + void registerScrollNotifiee(ScrollNotifiee notifiee) {
|
| + if (_registeredScrollNotifiees == null)
|
| + _registeredScrollNotifiees = new List<ScrollNotifiee>();
|
| + setState(() {
|
| + _registeredScrollNotifiees.add(notifiee);
|
| + });
|
| + }
|
| +
|
| + void unregisterScrollNotifiee(ScrollNotifiee notifiee) {
|
| + if (_registeredScrollNotifiees == null)
|
| + return;
|
| + setState(() {
|
| + _registeredScrollNotifiees.remove(notifiee);
|
| + });
|
| + }
|
| +
|
| bool scrollTo(double newScrollOffset) {
|
| if (newScrollOffset == _scrollOffset)
|
| return false;
|
| setState(() {
|
| _scrollOffset = newScrollOffset;
|
| });
|
| + if (_registeredScrollNotifiees != null) {
|
| + var newList = null;
|
| + _registeredScrollNotifiees.forEach((target) {
|
| + if (target.ancestorScrolled(this)) {
|
| + if (newList == null)
|
| + newList = new List<ScrollNotifiee>();
|
| + newList.add(target);
|
| + }
|
| + });
|
| + setState(() {
|
| + _registeredScrollNotifiees = newList;
|
| + });
|
| + }
|
| return true;
|
| }
|
|
|
|
|