Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Unified Diff: remoting/client/fling_animation.cc

Issue 2869723007: [CRD iOS] Viewport fling animation (Closed)
Patch Set: Merge branch 'master' into feat-fling-animation Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/client/fling_animation.cc
diff --git a/remoting/client/fling_animation.cc b/remoting/client/fling_animation.cc
new file mode 100644
index 0000000000000000000000000000000000000000..15a68751b7123329951611560826f5a4e22db587
--- /dev/null
+++ b/remoting/client/fling_animation.cc
@@ -0,0 +1,40 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/client/fling_animation.h"
+
+namespace remoting {
+
+FlingAnimation::FlingAnimation(float time_constant,
nicholss 2017/05/10 19:34:05 It seems like FlingTracker could be just a core cl
Yuwei 2017/05/10 23:28:24 TBH I'm not sure :) I'm just slightly against putt
+ const FlingCallback& fling_callback)
+ : fling_tracker_(time_constant), fling_callback_(fling_callback) {}
nicholss 2017/05/10 19:34:05 I am not sure this would compile, how is a float a
Yuwei 2017/05/10 23:28:24 This is essentially calling the FlingTracker(time_
+
+FlingAnimation::~FlingAnimation() {}
+
+void FlingAnimation::Reset(float velocity_x, float velocity_y) {
+ previous_position_x_ = 0.f;
+ previous_position_y_ = 0.f;
+ fling_tracker_.StartFling(velocity_x, velocity_y);
+}
+
+bool FlingAnimation::IsAnimationInProgress() const {
+ return fling_tracker_.IsFlingInProgress();
+}
+
+void FlingAnimation::Tick() {
+ float x, y;
+ bool in_progress =
+ fling_tracker_.TrackPositions(base::TimeTicks::Now(), &x, &y);
nicholss 2017/05/10 19:34:05 If this returned deltas you would not need to know
Yuwei 2017/05/10 23:28:24 Done.
+ if (in_progress) {
+ fling_callback_.Run(x - previous_position_x_, y - previous_position_y_);
+ previous_position_x_ = x;
+ previous_position_y_ = y;
+ }
+}
+
+void FlingAnimation::Abort() {
+ fling_tracker_.StopFling();
+}
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698