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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 return base::TimeDelta::FromMicroseconds(duration / kDurationDivisor * | 63 return base::TimeDelta::FromMicroseconds(duration / kDurationDivisor * |
64 base::Time::kMicrosecondsPerSecond); | 64 base::Time::kMicrosecondsPerSecond); |
65 } | 65 } |
66 | 66 |
67 static std::unique_ptr<TimingFunction> EaseOutWithInitialVelocity( | 67 static std::unique_ptr<TimingFunction> EaseOutWithInitialVelocity( |
68 double velocity) { | 68 double velocity) { |
69 // Clamp velocity to a sane value. | 69 // Clamp velocity to a sane value. |
70 velocity = std::min(std::max(velocity, -1000.0), 1000.0); | 70 velocity = std::min(std::max(velocity, -1000.0), 1000.0); |
71 | 71 |
72 // Based on EaseInOutTimingFunction::Create with first control point scaled. | 72 // Based on CubicBezierTimingFunction::EaseType::EASE_IN_OUT preset |
| 73 // with first control point scaled. |
73 const double x1 = 0.42; | 74 const double x1 = 0.42; |
74 const double y1 = velocity * x1; | 75 const double y1 = velocity * x1; |
75 return CubicBezierTimingFunction::Create(x1, y1, 0.58, 1); | 76 return CubicBezierTimingFunction::Create(x1, y1, 0.58, 1); |
76 } | 77 } |
77 | 78 |
78 } // namespace | 79 } // namespace |
79 | 80 |
80 std::unique_ptr<ScrollOffsetAnimationCurve> ScrollOffsetAnimationCurve::Create( | 81 std::unique_ptr<ScrollOffsetAnimationCurve> ScrollOffsetAnimationCurve::Create( |
81 const gfx::ScrollOffset& target_value, | 82 const gfx::ScrollOffset& target_value, |
82 std::unique_ptr<TimingFunction> timing_function, | 83 std::unique_ptr<TimingFunction> timing_function, |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 (MaximumDimension(old_delta) / MaximumDimension(new_delta)); | 227 (MaximumDimension(old_delta) / MaximumDimension(new_delta)); |
227 | 228 |
228 initial_value_ = current_position; | 229 initial_value_ = current_position; |
229 target_value_ = new_target; | 230 target_value_ = new_target; |
230 total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration); | 231 total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration); |
231 last_retarget_ = base::TimeDelta::FromSecondsD(t); | 232 last_retarget_ = base::TimeDelta::FromSecondsD(t); |
232 timing_function_ = EaseOutWithInitialVelocity(new_normalized_velocity); | 233 timing_function_ = EaseOutWithInitialVelocity(new_normalized_velocity); |
233 } | 234 } |
234 | 235 |
235 } // namespace cc | 236 } // namespace cc |
OLD | NEW |