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

Unified Diff: cc/animation/scrollbar_animation_controller_linear_fade.cc

Issue 23978008: Suppress scrollbar animation if the scroll gesture does not scroll (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix LayerTreeHostImpl unit tests Created 7 years, 3 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: cc/animation/scrollbar_animation_controller_linear_fade.cc
diff --git a/cc/animation/scrollbar_animation_controller_linear_fade.cc b/cc/animation/scrollbar_animation_controller_linear_fade.cc
index 53827120a5c5a2dbb7b252249290b857e447bec2..9f2380261d1b64e3751037efc65ebe2aa2b6e33e 100644
--- a/cc/animation/scrollbar_animation_controller_linear_fade.cc
+++ b/cc/animation/scrollbar_animation_controller_linear_fade.cc
@@ -24,16 +24,13 @@ ScrollbarAnimationControllerLinearFade::ScrollbarAnimationControllerLinearFade(
: ScrollbarAnimationController(),
scroll_layer_(scroll_layer),
scroll_gesture_in_progress_(false),
+ scroll_gesture_has_scrolled_(false),
fadeout_delay_(fadeout_delay),
fadeout_length_(fadeout_length) {}
ScrollbarAnimationControllerLinearFade::
~ScrollbarAnimationControllerLinearFade() {}
-bool ScrollbarAnimationControllerLinearFade::IsScrollGestureInProgress() const {
- return scroll_gesture_in_progress_;
-}
-
bool ScrollbarAnimationControllerLinearFade::IsAnimating() const {
return !last_awaken_time_.is_null();
}
@@ -54,28 +51,35 @@ bool ScrollbarAnimationControllerLinearFade::Animate(base::TimeTicks now) {
}
void ScrollbarAnimationControllerLinearFade::DidScrollGestureBegin() {
- scroll_layer_->SetScrollbarOpacity(1.0f);
scroll_gesture_in_progress_ = true;
- last_awaken_time_ = base::TimeTicks();
+ scroll_gesture_has_scrolled_ = false;
}
void ScrollbarAnimationControllerLinearFade::DidScrollGestureEnd(
base::TimeTicks now) {
+ // The animation should not be triggered if no scrolling has occurred.
+ if (scroll_gesture_has_scrolled_)
+ last_awaken_time_ = now;
+ scroll_gesture_has_scrolled_ = false;
scroll_gesture_in_progress_ = false;
- last_awaken_time_ = now;
}
-void ScrollbarAnimationControllerLinearFade::DidProgrammaticallyUpdateScroll(
+void ScrollbarAnimationControllerLinearFade::DidScrollUpdate(
base::TimeTicks now) {
- // Don't set scroll_gesture_in_progress_ as this scroll is not from a gesture
- // and we won't receive ScrollEnd.
scroll_layer_->SetScrollbarOpacity(1.0f);
- last_awaken_time_ = now;
+ // The animation should only be activated if the scroll updated occurred
+ // programatically, outside the scope of a scroll gesture.
+ if (scroll_gesture_in_progress_) {
+ last_awaken_time_ = base::TimeTicks();
+ scroll_gesture_has_scrolled_ = true;
+ } else {
+ last_awaken_time_ = now;
+ }
}
float ScrollbarAnimationControllerLinearFade::OpacityAtTime(
base::TimeTicks now) {
- if (scroll_gesture_in_progress_)
+ if (scroll_gesture_has_scrolled_)
return 1.0f;
if (last_awaken_time_.is_null())

Powered by Google App Engine
This is Rietveld 408576698