OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/gfx/animation/slide_animation.h" | 5 #include "ui/gfx/animation/slide_animation.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 namespace gfx { | 9 namespace gfx { |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // If we're already hiding (or hidden), we have nothing to do. | 60 // If we're already hiding (or hidden), we have nothing to do. |
61 if (!showing_) | 61 if (!showing_) |
62 return; | 62 return; |
63 | 63 |
64 showing_ = false; | 64 showing_ = false; |
65 value_start_ = value_current_; | 65 value_start_ = value_current_; |
66 value_end_ = 0.0; | 66 value_end_ = 0.0; |
67 | 67 |
68 // Make sure we actually have something to do. | 68 // Make sure we actually have something to do. |
69 if (slide_duration_ == 0) { | 69 if (slide_duration_ == 0) { |
| 70 // TODO(bruthig): Investigate if this should really be animating to 0.0, I |
| 71 // think it should be animating to 1.0. |
70 AnimateToState(0.0); // Skip to the end of the animation. | 72 AnimateToState(0.0); // Skip to the end of the animation. |
71 return; | 73 return; |
72 } else if (value_current_ == value_end_) { | 74 } else if (value_current_ == value_end_) { |
73 return; | 75 return; |
74 } | 76 } |
75 | 77 |
76 // This will also reset the currently-occurring animation. | 78 // This will also reset the currently-occurring animation. |
77 SetDuration(static_cast<int>(slide_duration_ * value_current_)); | 79 SetDuration(static_cast<int>(slide_duration_ * value_current_)); |
78 Start(); | 80 Start(); |
79 } | 81 } |
(...skipping 21 matching lines...) Expand all Loading... |
101 | 103 |
102 // Correct for any overshoot (while state may be capped at 1.0, let's not | 104 // Correct for any overshoot (while state may be capped at 1.0, let's not |
103 // take any rounding error chances. | 105 // take any rounding error chances. |
104 if ((value_end_ >= value_start_ && value_current_ > value_end_) || | 106 if ((value_end_ >= value_start_ && value_current_ > value_end_) || |
105 (value_end_ < value_start_ && value_current_ < value_end_)) { | 107 (value_end_ < value_start_ && value_current_ < value_end_)) { |
106 value_current_ = value_end_; | 108 value_current_ = value_end_; |
107 } | 109 } |
108 } | 110 } |
109 | 111 |
110 } // namespace gfx | 112 } // namespace gfx |
OLD | NEW |