Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.chrome.browser.widget; | |
| 6 | |
| 7 /** | |
| 8 * Progress bar animation logic that starts fast at the beginning and slows down approaching to the | |
| 9 * end. | |
| 10 */ | |
| 11 class ProgressAnimationFastStart implements ToolbarProgressBar.AnimationLogic { | |
| 12 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
| |
| 13 private static final float FINISHING_SPEED = 2.0f; | |
| 14 | |
| 15 private float mProgress; | |
| 16 | |
| 17 @Override | |
| 18 public void reset() { | |
| 19 mProgress = 0.0f; | |
| 20 } | |
| 21 | |
| 22 @Override | |
| 23 public float updateProgress(float targetProgress, float frameTimeSec, int re solution) { | |
| 24 assert mProgress <= targetProgress; | |
| 25 | |
| 26 float progressChange; | |
| 27 if (targetProgress == 1.0f) { | |
| 28 progressChange = FINISHING_SPEED * frameTimeSec; | |
| 29 } else { | |
| 30 progressChange = (targetProgress - mProgress) | |
| 31 * (1.0f - (float) Math.exp(-frameTimeSec * NORMALIZED_INITIA L_SPEED)); | |
| 32 } | |
| 33 | |
| 34 mProgress = Math.min(mProgress + progressChange, targetProgress); | |
| 35 if (targetProgress - mProgress < 0.5f / resolution) mProgress = targetPr ogress; | |
| 36 | |
| 37 return mProgress; | |
| 38 } | |
| 39 } | |
| OLD | NEW |