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

Unified Diff: ui/file_manager/file_manager/foreground/js/ui/scrollbar.js

Issue 2135163002: Scroll the attached view when wheel spinned on top of a scroll button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment indent Created 4 years, 5 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: ui/file_manager/file_manager/foreground/js/ui/scrollbar.js
diff --git a/ui/file_manager/file_manager/foreground/js/ui/scrollbar.js b/ui/file_manager/file_manager/foreground/js/ui/scrollbar.js
index 479c8cc72f0dd98e0a3ee89e781e91198270b1c1..a5f389869f3d1d1a00d2e6a50891558a73325fd4 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/scrollbar.js
+++ b/ui/file_manager/file_manager/foreground/js/ui/scrollbar.js
@@ -51,6 +51,7 @@ ScrollBar.prototype.decorate = function() {
this.button_.addEventListener('mousedown',
this.onButtonPressed_.bind(this));
+ this.button_.addEventListener('wheel', this.onWheel_.bind(this));
window.addEventListener('mouseup', this.onMouseUp_.bind(this));
window.addEventListener('mousemove', this.onMouseMove_.bind(this));
};
@@ -86,6 +87,27 @@ ScrollBar.prototype.attachToView = function(view) {
};
/**
+ * Handles scroll by a mouse wheel.
+ *
+ * @param {Event} event Mouse event.
+ * @private
+ */
+ScrollBar.prototype.onWheel_ = function(event) {
+ var scrollPosition = this.view_.scrollTop + event.deltaY;
+ // Ensure the scrollbar is in the view.
+ var scrollBottom =
+ Math.max(this.view_.scrollHeight - this.view_.clientHeight, 0);
+ scrollPosition = Math.max(Math.min(scrollPosition, scrollBottom), 0);
+
+ // TODO(yamaguchi): Invoke native scroll instead of setting scrollTop.
+ // This implementation will bypass the smooth scroll animation seen with
+ // native scroll.
+ this.scrollTop_ = scrollPosition;
+ this.view_.scrollTop = scrollPosition;
+ this.redraw_();
+}
+
+/**
* Scroll handler.
* @private
*/
« 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