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

Unified Diff: sky/framework/components/ink_splash.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/animation/generators.dart ('k') | sky/framework/components/ink_well.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/components/ink_splash.dart
diff --git a/sky/framework/components/ink_splash.dart b/sky/framework/components/ink_splash.dart
index 335d49d22befc43877274fa6e62a48aa14ec3317..6b897680d6ebb7d979404f105f42a3876cec7882 100644
--- a/sky/framework/components/ink_splash.dart
+++ b/sky/framework/components/ink_splash.dart
@@ -13,6 +13,8 @@ import 'dart:sky' as sky;
const double _kSplashConfirmedDuration = 350.0;
const double _kSplashUnconfirmedDuration = config.kDefaultLongPressTimeout;
+const double _kSplashAbortDuration = 100.0;
+const double _kSplashInitialDelay = 0.0; // we could delay initially in case the user scrolls
double _getSplashTargetSize(sky.ClientRect rect, double x, double y) {
return 2.0 * math.max(math.max(x - rect.left, rect.right - x),
@@ -26,11 +28,13 @@ class SplashController {
final AnimatedValue _size = new AnimatedValue(0.0);
double _offsetX;
double _offsetY;
+ double _lastSize = 0.0;
+ bool _growing = true;
double _targetSize;
Stream<String> _styleStream;
void start() {
- _size.animateTo(_targetSize, _kSplashUnconfirmedDuration, curve: easeOut);
+ _size.animateTo(_targetSize, _kSplashUnconfirmedDuration, curve: easeOut, initialDelay: _kSplashInitialDelay);
}
void confirm() {
@@ -41,6 +45,14 @@ class SplashController {
_size.animateTo(_targetSize, duration, curve: easeOut);
}
+ void abort() {
+ _growing = false;
+ double durationRemaining = _size.remainingTime;
+ if (durationRemaining <= _kSplashAbortDuration)
+ return;
+ _size.animateTo(_targetSize, _kSplashAbortDuration, curve: easeOut);
+ }
+
void cancel() {
_size.stop();
}
@@ -55,12 +67,19 @@ class SplashController {
if (p == _targetSize) {
onDone();
}
+ double size;
+ if (_growing) {
+ sise = p;
+ _lastSize = p;
+ } else {
+ size = _lastSize;
+ }
return '''
- top: ${_offsetY - p/2}px;
- left: ${_offsetX - p/2}px;
- width: ${p}px;
- height: ${p}px;
- border-radius: ${p}px;
+ top: ${_offsetY - size/2}px;
+ left: ${_offsetX - size/2}px;
+ width: ${size}px;
+ height: ${size}px;
+ border-radius: ${size}px;
opacity: ${1.0 - (p / _targetSize)};''';
});
« no previous file with comments | « sky/framework/animation/generators.dart ('k') | sky/framework/components/ink_well.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698