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

Unified Diff: chrome/browser/ui/views/ash/tab_scrubber.cc

Issue 2703373009: Make the tab scrubber speed proportional with the number of tabs (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/ash/tab_scrubber.cc
diff --git a/chrome/browser/ui/views/ash/tab_scrubber.cc b/chrome/browser/ui/views/ash/tab_scrubber.cc
index 72b39b71878fffd6f2185851403fb9db477dcf75..091949dd8a3036839efbd2605b596c3eea00f640 100644
--- a/chrome/browser/ui/views/ash/tab_scrubber.cc
+++ b/chrome/browser/ui/views/ash/tab_scrubber.cc
@@ -6,6 +6,8 @@
#include <stdint.h>
+#include <algorithm>
+
#include "ash/shell.h"
#include "ash/wm/window_util.h"
#include "base/metrics/histogram_macros.h"
@@ -25,7 +27,12 @@
#include "ui/views/controls/glow_hover_controller.h"
namespace {
+
const int64_t kActivationDelayMS = 200;
+
+inline float Clamp(float value, float low, float high) {
+ return std::min(high, std::max(value, low));
+}
}
// static
@@ -306,7 +313,12 @@ void TabScrubber::UpdateSwipeX(float x_offset) {
DCHECK(tab_strip_);
DCHECK(scrubbing_);
- swipe_x_ += x_offset;
+ // Make the swipe speed inversely proportional with the number or tabs:
+ // Each added tab introduces a reduction of 2% in |x_offset|, with a value of
+ // one fourth of |x_offset| as the minimum (i.e. we need 38 tabs to reach
+ // that minimum reduction).
+ swipe_x_ += Clamp(x_offset - (tab_strip_->tab_count() * 0.02f * x_offset),
+ 0.25f * x_offset, x_offset);
// In an RTL layout, everything is mirrored, i.e. the index of the first tab
// (with the smallest X mirrored co-ordinates) is actually the index of the
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698