| 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 base::TimeDelta t, |
| 113 const gfx::Vector2dF& adjustment) { |
| 114 initial_value_ = ScrollOffsetWithDelta(GetValue(t), adjustment); |
| 115 target_value_ = ScrollOffsetWithDelta(target_value_, adjustment); |
| 116 } |
| 117 |
| 111 gfx::ScrollOffset ScrollOffsetAnimationCurve::GetValue( | 118 gfx::ScrollOffset ScrollOffsetAnimationCurve::GetValue( |
| 112 base::TimeDelta t) const { | 119 base::TimeDelta t) const { |
| 113 base::TimeDelta duration = total_animation_duration_ - last_retarget_; | 120 base::TimeDelta duration = total_animation_duration_ - last_retarget_; |
| 114 t -= last_retarget_; | 121 t -= last_retarget_; |
| 115 | 122 |
| 116 if (t <= base::TimeDelta()) | 123 if (t <= base::TimeDelta()) |
| 117 return initial_value_; | 124 return initial_value_; |
| 118 | 125 |
| 119 if (t >= duration) | 126 if (t >= duration) |
| 120 return target_value_; | 127 return target_value_; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 (MaximumDimension(old_delta) / MaximumDimension(new_delta)); | 227 (MaximumDimension(old_delta) / MaximumDimension(new_delta)); |
| 221 | 228 |
| 222 initial_value_ = current_position; | 229 initial_value_ = current_position; |
| 223 target_value_ = new_target; | 230 target_value_ = new_target; |
| 224 total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration); | 231 total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration); |
| 225 last_retarget_ = base::TimeDelta::FromSecondsD(t); | 232 last_retarget_ = base::TimeDelta::FromSecondsD(t); |
| 226 timing_function_ = EaseOutWithInitialVelocity(new_normalized_velocity); | 233 timing_function_ = EaseOutWithInitialVelocity(new_normalized_velocity); |
| 227 } | 234 } |
| 228 | 235 |
| 229 } // namespace cc | 236 } // namespace cc |
| OLD | NEW |