Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/widget/ProgressAnimationFastStart.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/ProgressAnimationFastStart.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/ProgressAnimationFastStart.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d4c8f14ba3ff11808823342a6b308f6e90be61e1 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/ProgressAnimationFastStart.java |
| @@ -0,0 +1,39 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.widget; |
| + |
| +/** |
| + * Progress bar animation logic that starts fast at the beginning and slows down approaching to the |
| + * end. |
| + */ |
| +class ProgressAnimationFastStart implements ToolbarProgressBar.AnimationLogic { |
| + private static final float NORMALIZED_INITIAL_SPEED = 1.5f; |
|
David Trainor- moved to gerrit
2015/07/31 21:01:51
Can we add units to these? Are these in dp, perce
Kibeom Kim (inactive)
2015/07/31 21:42:50
This is a normalized scale, 0 to 1, and I wasn't s
|
| + private static final float FINISHING_SPEED = 2.0f; |
| + |
| + private float mProgress; |
| + |
| + @Override |
| + public void reset() { |
| + mProgress = 0.0f; |
| + } |
| + |
| + @Override |
| + public float updateProgress(float targetProgress, float frameTimeSec, int resolution) { |
| + assert mProgress <= targetProgress; |
| + |
| + float progressChange; |
| + if (targetProgress == 1.0f) { |
| + progressChange = FINISHING_SPEED * frameTimeSec; |
| + } else { |
| + progressChange = (targetProgress - mProgress) |
| + * (1.0f - (float) Math.exp(-frameTimeSec * NORMALIZED_INITIAL_SPEED)); |
| + } |
| + |
| + mProgress = Math.min(mProgress + progressChange, targetProgress); |
| + if (targetProgress - mProgress < 0.5f / resolution) mProgress = targetProgress; |
| + |
| + return mProgress; |
| + } |
| +} |