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

Side by Side Diff: sky/framework/components/ink_well.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 unified diff | Download patch
OLDNEW
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 '../fn.dart'; 5 import '../fn.dart';
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:sky' as sky; 7 import 'dart:sky' as sky;
8 import 'ink_splash.dart'; 8 import 'ink_splash.dart';
9 import 'scrollable.dart';
9 10
10 class InkWell extends Component { 11 class InkWell extends Component implements ScrollNotifiee {
eseidel 2015/04/20 22:45:04 ScrollClient? ScrollDelegate?
Hixie 2015/04/20 22:49:40 Changed all occurrences of Notifiee to Client.
11 static final Style _containmentStyleHack = new Style(''' 12 static final Style _containmentStyleHack = new Style('''
12 transform: translateX(0);'''); 13 transform: translateX(0);''');
13 14
14 LinkedHashSet<SplashController> _splashes; 15 LinkedHashSet<SplashController> _splashes;
15 16
16 String inlineStyle; 17 String inlineStyle;
17 List<UINode> children; 18 List<UINode> children;
18 19
19 InkWell({ Object key, this.inlineStyle, this.children }) 20 InkWell({ Object key, this.inlineStyle, this.children })
20 : super(key: key) { 21 : super(key: key) {
(...skipping 27 matching lines...) Expand all
48 49
49 void _startSplash(sky.GestureEvent event) { 50 void _startSplash(sky.GestureEvent event) {
50 setState(() { 51 setState(() {
51 if (_splashes == null) 52 if (_splashes == null)
52 _splashes = new LinkedHashSet<SplashController>(); 53 _splashes = new LinkedHashSet<SplashController>();
53 var splash; 54 var splash;
54 splash = new SplashController(_getBoundingRect(), event.x, event.y, 55 splash = new SplashController(_getBoundingRect(), event.x, event.y,
55 pointer: event.primaryPointer, 56 pointer: event.primaryPointer,
56 onDone: () { _splashDone(splash); }); 57 onDone: () { _splashDone(splash); });
57 _splashes.add(splash); 58 _splashes.add(splash);
59 var node = parent;
eseidel 2015/04/20 22:45:04 Types?
60 while (node != null) {
61 if (node is Scrollable)
62 node.registerScrollNotifiee(this);
63 node = node.parent;
64 }
58 }); 65 });
59 } 66 }
60 67
68 bool ancestorScrolled(Scrollable ancestor) {
69 _abortSplashes();
70 return false;
71 }
72
73 void handleRemoved() {
74 var node = parent;
75 while (node != null) {
76 if (node is Scrollable)
77 node.unregisterScrollNotifiee(this);
78 node = node.parent;
79 }
80 super.handleRemoved();
81 }
82
61 void _confirmSplash(sky.GestureEvent event) { 83 void _confirmSplash(sky.GestureEvent event) {
62 if (_splashes == null) 84 if (_splashes == null)
63 return; 85 return;
64 _splashes.where((splash) => splash.pointer == event.primaryPointer) 86 _splashes.where((splash) => splash.pointer == event.primaryPointer)
65 .forEach((splash) { splash.confirm(); }); 87 .forEach((splash) { splash.confirm(); });
66 } 88 }
67 89
90 void _abortSplashes() {
91 if (_splashes == null)
92 return;
93 setState(() {
94 _splashes.forEach((s) { s.abort(); });
95 });
96 }
97
68 void _cancelSplashes(sky.Event event) { 98 void _cancelSplashes(sky.Event event) {
69 if (_splashes == null) 99 if (_splashes == null)
70 return; 100 return;
71 setState(() { 101 setState(() {
72 var splashes = _splashes; 102 var splashes = _splashes;
73 _splashes = null; 103 _splashes = null;
74 splashes.forEach((s) { s.cancel(); }); 104 splashes.forEach((s) { s.cancel(); });
75 }); 105 });
76 } 106 }
77 107
78 void _splashDone(SplashController splash) { 108 void _splashDone(SplashController splash) {
79 if (_splashes == null) 109 if (_splashes == null)
80 return; 110 return;
81 setState(() { 111 setState(() {
82 _splashes.remove(splash); 112 _splashes.remove(splash);
83 if (_splashes.length == 0) 113 if (_splashes.length == 0)
84 _splashes = null; 114 _splashes = null;
85 }); 115 });
86 } 116 }
87 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698