Chromium Code Reviews| Index: ui/file_manager/gallery/js/slide_mode.js |
| diff --git a/ui/file_manager/gallery/js/slide_mode.js b/ui/file_manager/gallery/js/slide_mode.js |
| index dcad95590e71f68c346085edcd38373f177bd1de..52e9434152985ba0c705c289fd5ad3692016af1c 100644 |
| --- a/ui/file_manager/gallery/js/slide_mode.js |
| +++ b/ui/file_manager/gallery/js/slide_mode.js |
| @@ -1870,6 +1870,12 @@ function TouchHandler(targetElement, slideMode) { |
| */ |
| this.lastZoom_ = 1.0; |
| + /** |
| + * @type {number} |
| + * @private |
| + */ |
| + this.mouseWheelZoomOperationId_ = 0; |
| + |
| targetElement.addEventListener('touchstart', this.onTouchStart_.bind(this)); |
| var onTouchEventBound = this.onTouchEvent_.bind(this); |
| targetElement.ownerDocument.addEventListener('touchmove', onTouchEventBound); |
| @@ -2068,20 +2074,27 @@ TouchHandler.WHEEL_ZOOM_FACTOR = 1.05; |
| */ |
| TouchHandler.prototype.onMouseWheel_ = function(event) { |
| var event = assertInstanceof(event, MouseEvent); |
| - var viewport = this.slideMode_.getViewport(); |
| if (!this.enabled_) |
| return; |
| this.stopOperation(); |
| - this.lastZoom_ = viewport.getZoom(); |
| - var zoom = this.lastZoom_; |
| + |
| + var viewport = this.slideMode_.getViewport(); |
| + var zoom = viewport.getZoom(); |
| if (event.wheelDeltaY > 0) { |
| zoom *= TouchHandler.WHEEL_ZOOM_FACTOR; |
| } else { |
| zoom /= TouchHandler.WHEEL_ZOOM_FACTOR; |
| } |
| - viewport.setZoom(zoom); |
| - this.slideMode_.imageView_.applyViewportChange(); |
| + |
| + // Request animation frame not to set zoom more than once in a frame. |
|
fukino
2016/03/08 06:28:54
nit: please add a like for the bug this code is tr
yawano
2016/03/08 06:41:03
Done.
|
| + requestAnimationFrame(function(operationId) { |
| + if (this.mouseWheelZoomOperationId_ !== operationId) |
| + return; |
| + |
| + viewport.setZoom(zoom); |
| + this.slideMode_.applyViewportChange(); |
| + }.bind(this, ++this.mouseWheelZoomOperationId_)); |
| }; |
| /** |