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

Unified Diff: ui/file_manager/gallery/js/slide_mode.js

Issue 1770903003: Gallery: do not set zoom more than once in a frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add link to the issue. Created 4 years, 9 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/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..1968409e0b71d164d2a96d7a0402b8ee3e50636c 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_));
};
/**
« 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