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

Unified Diff: cc/input/scrollbar_animation_controller_thinning.cc

Issue 2358323003: Keep expanded if mouse moves off of scrollbar while dragging (Closed)
Patch Set: style Created 4 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/input/scrollbar_animation_controller_thinning.cc
diff --git a/cc/input/scrollbar_animation_controller_thinning.cc b/cc/input/scrollbar_animation_controller_thinning.cc
index af02ad3cddb6d2ebf5b31d877bcecdba8abd8ac1..729323169262e9240487b00dee61d451e39b37d7 100644
--- a/cc/input/scrollbar_animation_controller_thinning.cc
+++ b/cc/input/scrollbar_animation_controller_thinning.cc
@@ -41,6 +41,7 @@ ScrollbarAnimationControllerThinning::ScrollbarAnimationControllerThinning(
delay_before_starting,
resize_delay_before_starting,
duration),
+ captured_(false),
mouse_is_over_scrollbar_(false),
mouse_is_near_scrollbar_(false),
thickness_change_(NONE),
@@ -65,15 +66,38 @@ void ScrollbarAnimationControllerThinning::RunAnimationFrame(float progress) {
}
}
+void ScrollbarAnimationControllerThinning::DidCaptureScrollbarBegin() {
+ captured_ = true;
+ ApplyOpacityAndThumbThicknessScale(1, 1.f);
+}
+
+void ScrollbarAnimationControllerThinning::DidCaptureScrollbarEnd() {
+ captured_ = false;
+
+ if (!mouse_is_over_scrollbar_)
+ opacity_change_ = DECREASE;
+ if (!mouse_is_near_scrollbar_)
+ thickness_change_ = DECREASE;
+ StartAnimation();
+}
+
void ScrollbarAnimationControllerThinning::DidMouseMoveOffScrollbar() {
mouse_is_over_scrollbar_ = false;
mouse_is_near_scrollbar_ = false;
+
+ if (captured_)
+ return;
+
opacity_change_ = DECREASE;
thickness_change_ = DECREASE;
StartAnimation();
}
void ScrollbarAnimationControllerThinning::DidScrollUpdate(bool on_resize) {
+ if (captured_) {
+ return;
+ }
+
ScrollbarAnimationController::DidScrollUpdate(on_resize);
ApplyOpacityAndThumbThicknessScale(
1, mouse_is_near_scrollbar_ ? 1.f : kIdleThicknessScale);
@@ -87,21 +111,27 @@ void ScrollbarAnimationControllerThinning::DidMouseMoveNear(float distance) {
bool mouse_is_near_scrollbar =
distance < mouse_move_distance_to_trigger_animation_;
- if (mouse_is_over_scrollbar == mouse_is_over_scrollbar_ &&
- mouse_is_near_scrollbar == mouse_is_near_scrollbar_)
+ if (captured_) {
+ mouse_is_near_scrollbar_ = mouse_is_near_scrollbar;
+ mouse_is_over_scrollbar_ = mouse_is_over_scrollbar;
return;
+ } else {
+ if (mouse_is_over_scrollbar == mouse_is_over_scrollbar_ &&
+ mouse_is_near_scrollbar == mouse_is_near_scrollbar_)
+ return;
+
+ if (mouse_is_over_scrollbar_ != mouse_is_over_scrollbar) {
+ mouse_is_over_scrollbar_ = mouse_is_over_scrollbar;
+ opacity_change_ = mouse_is_over_scrollbar_ ? INCREASE : DECREASE;
+ }
- if (mouse_is_over_scrollbar_ != mouse_is_over_scrollbar) {
- mouse_is_over_scrollbar_ = mouse_is_over_scrollbar;
- opacity_change_ = mouse_is_over_scrollbar_ ? INCREASE : DECREASE;
- }
+ if (mouse_is_near_scrollbar_ != mouse_is_near_scrollbar) {
+ mouse_is_near_scrollbar_ = mouse_is_near_scrollbar;
+ thickness_change_ = mouse_is_near_scrollbar_ ? INCREASE : DECREASE;
+ }
- if (mouse_is_near_scrollbar_ != mouse_is_near_scrollbar) {
- mouse_is_near_scrollbar_ = mouse_is_near_scrollbar;
- thickness_change_ = mouse_is_near_scrollbar_ ? INCREASE : DECREASE;
+ StartAnimation();
}
-
- StartAnimation();
}
float ScrollbarAnimationControllerThinning::OpacityAtAnimationProgress(
« no previous file with comments | « cc/input/scrollbar_animation_controller_thinning.h ('k') | cc/input/scrollbar_animation_controller_thinning_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698