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

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: 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/ink_splash.dart
diff --git a/sky/framework/components/ink_splash.dart b/sky/framework/components/ink_splash.dart
index 335d49d22befc43877274fa6e62a48aa14ec3317..7b4caa6d52f16bd31eec08b7615f1c4bb98c9177 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();
}
+ var s;
eseidel 2015/04/20 22:45:04 What does s mean?
Hixie 2015/04/20 22:49:40 changed to "size"
+ if (_growing) {
+ s = p;
+ _lastSize = p;
+ } else {
+ s = _lastSize;
+ }
return '''
- top: ${_offsetY - p/2}px;
- left: ${_offsetX - p/2}px;
- width: ${p}px;
- height: ${p}px;
- border-radius: ${p}px;
+ top: ${_offsetY - s/2}px;
+ left: ${_offsetX - s/2}px;
+ width: ${s}px;
+ height: ${s}px;
+ border-radius: ${s}px;
opacity: ${1.0 - (p / _targetSize)};''';
});

Powered by Google App Engine
This is Rietveld 408576698