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

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: fix comments from eseidel 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
« no previous file with comments | « sky/framework/components/ink_well.dart ('k') | sky/framework/fn.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/components/scrollable.dart
diff --git a/sky/framework/components/scrollable.dart b/sky/framework/components/scrollable.dart
index dadcf775a67fd2c445a22c267f8231a0acfe1839..36bbaffef4c62953cb79a407ec1fa9d6d67b343a 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 ScrollClient {
+ 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<ScrollClient> _registeredScrollClients;
+
+ void registerScrollClient(ScrollClient notifiee) {
+ if (_registeredScrollClients == null)
+ _registeredScrollClients = new List<ScrollClient>();
+ setState(() {
+ _registeredScrollClients.add(notifiee);
+ });
+ }
+
+ void unregisterScrollClient(ScrollClient notifiee) {
+ if (_registeredScrollClients == null)
+ return;
+ setState(() {
+ _registeredScrollClients.remove(notifiee);
+ });
+ }
+
bool scrollTo(double newScrollOffset) {
if (newScrollOffset == _scrollOffset)
return false;
setState(() {
_scrollOffset = newScrollOffset;
});
+ if (_registeredScrollClients != null) {
+ var newList = null;
+ _registeredScrollClients.forEach((target) {
+ if (target.ancestorScrolled(this)) {
+ if (newList == null)
+ newList = new List<ScrollClient>();
+ newList.add(target);
+ }
+ });
+ setState(() {
+ _registeredScrollClients = newList;
+ });
+ }
return true;
}
« no previous file with comments | « sky/framework/components/ink_well.dart ('k') | sky/framework/fn.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698