OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 #include "remoting/client/fling_animation.h" |
| 6 |
| 7 namespace remoting { |
| 8 |
| 9 FlingAnimation::FlingAnimation(float time_constant, |
| 10 const FlingCallback& fling_callback) |
| 11 : fling_tracker_(time_constant), fling_callback_(fling_callback) {} |
| 12 |
| 13 FlingAnimation::~FlingAnimation() {} |
| 14 |
| 15 void FlingAnimation::Reset(float velocity_x, float velocity_y) { |
| 16 previous_position_x_ = 0.f; |
| 17 previous_position_y_ = 0.f; |
| 18 fling_tracker_.StartFling(velocity_x, velocity_y); |
| 19 } |
| 20 |
| 21 bool FlingAnimation::IsAnimationInProgress() const { |
| 22 return fling_tracker_.IsFlingInProgress(); |
| 23 } |
| 24 |
| 25 void FlingAnimation::Tick() { |
| 26 float x, y; |
| 27 bool in_progress = |
| 28 fling_tracker_.TrackPositions(base::TimeTicks::Now(), &x, &y); |
| 29 if (in_progress) { |
| 30 fling_callback_.Run(x - previous_position_x_, y - previous_position_y_); |
| 31 previous_position_x_ = x; |
| 32 previous_position_y_ = y; |
| 33 } |
| 34 } |
| 35 |
| 36 void FlingAnimation::Abort() { |
| 37 fling_tracker_.StopFling(); |
| 38 } |
| 39 |
| 40 } // namespace remoting |
OLD | NEW |