diff options
author | yawano <yawano@chromium.org> | 2016-03-07 23:28:58 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-08 07:30:25 +0000 |
commit | 2afcf7037d39cd4cedf82d235123d5a3efa073c9 (patch) | |
tree | c297263fc21a8c4f90fc08b38231bb7eaf0fdde4 /ui/file_manager | |
parent | 3436bb5299b3c8becec4c7033c25f3f8c70c5692 (diff) | |
download | chromium_src-2afcf7037d39cd4cedf82d235123d5a3efa073c9.zip chromium_src-2afcf7037d39cd4cedf82d235123d5a3efa073c9.tar.gz chromium_src-2afcf7037d39cd4cedf82d235123d5a3efa073c9.tar.bz2 |
Gallery: do not set zoom more than once in a frame.
BUG=591033
TEST=manually tested as described in the issue.
Review URL: https://codereview.chromium.org/1770903003
Cr-Commit-Position: refs/heads/master@{#379774}
Diffstat (limited to 'ui/file_manager')
-rw-r--r-- | ui/file_manager/gallery/js/slide_mode.js | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/ui/file_manager/gallery/js/slide_mode.js b/ui/file_manager/gallery/js/slide_mode.js index dcad955..1968409 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,28 @@ 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. This is + // a fix for https://crbug.com/591033 + requestAnimationFrame(function(operationId) { + if (this.mouseWheelZoomOperationId_ !== operationId) + return; + + viewport.setZoom(zoom); + this.slideMode_.applyViewportChange(); + }.bind(this, ++this.mouseWheelZoomOperationId_)); }; /** |