| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cc/animation/scroll_offset_animation_curve.h" | 5 #include "cc/animation/scroll_offset_animation_curve.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 initial_value_ = initial_value; | 101 initial_value_ = initial_value; |
| 102 has_set_initial_value_ = true; | 102 has_set_initial_value_ = true; |
| 103 total_animation_duration_ = SegmentDuration( | 103 total_animation_duration_ = SegmentDuration( |
| 104 target_value_.DeltaFrom(initial_value_), duration_behavior_); | 104 target_value_.DeltaFrom(initial_value_), duration_behavior_); |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool ScrollOffsetAnimationCurve::HasSetInitialValue() const { | 107 bool ScrollOffsetAnimationCurve::HasSetInitialValue() const { |
| 108 return has_set_initial_value_; | 108 return has_set_initial_value_; |
| 109 } | 109 } |
| 110 | 110 |
| 111 void ScrollOffsetAnimationCurve::ApplyAdjustment( |
| 112 const gfx::Vector2dF& adjustment) { |
| 113 initial_value_ = ScrollOffsetWithDelta(initial_value_, adjustment); |
| 114 target_value_ = ScrollOffsetWithDelta(target_value_, adjustment); |
| 115 } |
| 116 |
| 111 gfx::ScrollOffset ScrollOffsetAnimationCurve::GetValue( | 117 gfx::ScrollOffset ScrollOffsetAnimationCurve::GetValue( |
| 112 base::TimeDelta t) const { | 118 base::TimeDelta t) const { |
| 113 base::TimeDelta duration = total_animation_duration_ - last_retarget_; | 119 base::TimeDelta duration = total_animation_duration_ - last_retarget_; |
| 114 t -= last_retarget_; | 120 t -= last_retarget_; |
| 115 | 121 |
| 116 if (t <= base::TimeDelta()) | 122 if (t <= base::TimeDelta()) |
| 117 return initial_value_; | 123 return initial_value_; |
| 118 | 124 |
| 119 if (t >= duration) | 125 if (t >= duration) |
| 120 return target_value_; | 126 return target_value_; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 (MaximumDimension(old_delta) / MaximumDimension(new_delta)); | 226 (MaximumDimension(old_delta) / MaximumDimension(new_delta)); |
| 221 | 227 |
| 222 initial_value_ = current_position; | 228 initial_value_ = current_position; |
| 223 target_value_ = new_target; | 229 target_value_ = new_target; |
| 224 total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration); | 230 total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration); |
| 225 last_retarget_ = base::TimeDelta::FromSecondsD(t); | 231 last_retarget_ = base::TimeDelta::FromSecondsD(t); |
| 226 timing_function_ = EaseOutWithInitialVelocity(new_normalized_velocity); | 232 timing_function_ = EaseOutWithInitialVelocity(new_normalized_velocity); |
| 227 } | 233 } |
| 228 | 234 |
| 229 } // namespace cc | 235 } // namespace cc |
| OLD | NEW |