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..041fb434fca51100ef311c0c62f384e03f9c5f7c 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 |
|
fukino
2016/07/11 10:19:12
nit: You don't need to indent here.
yamaguchi
2016/07/11 10:23:07
Done.
|
| + // native scroll. |
| + this.scrollTop_ = scrollPosition; |
| + this.view_.scrollTop = scrollPosition; |
| + this.redraw_(); |
| +} |
| + |
| +/** |
| * Scroll handler. |
| * @private |
| */ |