Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: sky/framework/components/scrollable.dart

Issue 1092423003: [Effen] Reduce splashes when scrolling. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698