Chromium Code Reviews| 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..57d1e609b4f502df08b8598aa2aed2727f170c8e 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('mousewheel', this.onWheel_.bind(this)); |
|
fukino
2016/07/11 10:09:52
mousewheel event is deprecated, so please use the
yamaguchi
2016/07/11 10:17:20
Done.
|
| window.addEventListener('mouseup', this.onMouseUp_.bind(this)); |
| window.addEventListener('mousemove', this.onMouseMove_.bind(this)); |
| }; |
| @@ -86,6 +87,24 @@ 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); |
| + |
|
fukino
2016/07/11 10:09:52
Please add a comment about the difference between
yamaguchi
2016/07/11 10:17:20
Done.
|
| + this.scrollTop_ = scrollPosition; |
| + this.view_.scrollTop = scrollPosition; |
| + this.redraw_(); |
| +} |
| + |
| +/** |
| * Scroll handler. |
| * @private |
| */ |