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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Slide mode displays a single image and has a set of controls to navigate 6 * Slide mode displays a single image and has a set of controls to navigate
7 * between the images and to edit an image. 7 * between the images and to edit an image.
8 * 8 *
9 * @param {!HTMLElement} container Main container element. 9 * @param {!HTMLElement} container Main container element.
10 * @param {!HTMLElement} content Content container element. 10 * @param {!HTMLElement} content Content container element.
(...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 */ 1863 */
1864 this.lastEvent_ = null; 1864 this.lastEvent_ = null;
1865 1865
1866 /** 1866 /**
1867 * Zoom value just after last touch event. 1867 * Zoom value just after last touch event.
1868 * @type {number} 1868 * @type {number}
1869 * @private 1869 * @private
1870 */ 1870 */
1871 this.lastZoom_ = 1.0; 1871 this.lastZoom_ = 1.0;
1872 1872
1873 /**
1874 * @type {number}
1875 * @private
1876 */
1877 this.mouseWheelZoomOperationId_ = 0;
1878
1873 targetElement.addEventListener('touchstart', this.onTouchStart_.bind(this)); 1879 targetElement.addEventListener('touchstart', this.onTouchStart_.bind(this));
1874 var onTouchEventBound = this.onTouchEvent_.bind(this); 1880 var onTouchEventBound = this.onTouchEvent_.bind(this);
1875 targetElement.ownerDocument.addEventListener('touchmove', onTouchEventBound); 1881 targetElement.ownerDocument.addEventListener('touchmove', onTouchEventBound);
1876 targetElement.ownerDocument.addEventListener('touchend', onTouchEventBound); 1882 targetElement.ownerDocument.addEventListener('touchend', onTouchEventBound);
1877 1883
1878 targetElement.addEventListener('mousedown', this.onMouseDown_.bind(this)); 1884 targetElement.addEventListener('mousedown', this.onMouseDown_.bind(this));
1879 targetElement.ownerDocument.addEventListener('mousemove', 1885 targetElement.ownerDocument.addEventListener('mousemove',
1880 this.onMouseMove_.bind(this)); 1886 this.onMouseMove_.bind(this));
1881 targetElement.ownerDocument.addEventListener('mouseup', 1887 targetElement.ownerDocument.addEventListener('mouseup',
1882 this.onMouseUp_.bind(this)); 1888 this.onMouseUp_.bind(this));
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 */ 2067 */
2062 TouchHandler.WHEEL_ZOOM_FACTOR = 1.05; 2068 TouchHandler.WHEEL_ZOOM_FACTOR = 1.05;
2063 2069
2064 /** 2070 /**
2065 * Handles mouse wheel events. 2071 * Handles mouse wheel events.
2066 * @param {!Event} event Wheel event. 2072 * @param {!Event} event Wheel event.
2067 * @private 2073 * @private
2068 */ 2074 */
2069 TouchHandler.prototype.onMouseWheel_ = function(event) { 2075 TouchHandler.prototype.onMouseWheel_ = function(event) {
2070 var event = assertInstanceof(event, MouseEvent); 2076 var event = assertInstanceof(event, MouseEvent);
2071 var viewport = this.slideMode_.getViewport();
2072 if (!this.enabled_) 2077 if (!this.enabled_)
2073 return; 2078 return;
2074 2079
2075 this.stopOperation(); 2080 this.stopOperation();
2076 this.lastZoom_ = viewport.getZoom(); 2081
2077 var zoom = this.lastZoom_; 2082 var viewport = this.slideMode_.getViewport();
2083 var zoom = viewport.getZoom();
2078 if (event.wheelDeltaY > 0) { 2084 if (event.wheelDeltaY > 0) {
2079 zoom *= TouchHandler.WHEEL_ZOOM_FACTOR; 2085 zoom *= TouchHandler.WHEEL_ZOOM_FACTOR;
2080 } else { 2086 } else {
2081 zoom /= TouchHandler.WHEEL_ZOOM_FACTOR; 2087 zoom /= TouchHandler.WHEEL_ZOOM_FACTOR;
2082 } 2088 }
2083 viewport.setZoom(zoom); 2089
2084 this.slideMode_.imageView_.applyViewportChange(); 2090 // Request animation frame not to set zoom more than once in a frame. This is
2091 // a fix for https://crbug.com/591033
2092 requestAnimationFrame(function(operationId) {
2093 if (this.mouseWheelZoomOperationId_ !== operationId)
2094 return;
2095
2096 viewport.setZoom(zoom);
2097 this.slideMode_.applyViewportChange();
2098 }.bind(this, ++this.mouseWheelZoomOperationId_));
2085 }; 2099 };
2086 2100
2087 /** 2101 /**
2088 * Handles mouse down events. 2102 * Handles mouse down events.
2089 * @param {!Event} event Wheel event. 2103 * @param {!Event} event Wheel event.
2090 * @private 2104 * @private
2091 */ 2105 */
2092 TouchHandler.prototype.onMouseDown_ = function(event) { 2106 TouchHandler.prototype.onMouseDown_ = function(event) {
2093 var event = assertInstanceof(event, MouseEvent); 2107 var event = assertInstanceof(event, MouseEvent);
2094 var viewport = this.slideMode_.getViewport(); 2108 var viewport = this.slideMode_.getViewport();
(...skipping 24 matching lines...) Expand all
2119 /** 2133 /**
2120 * Handles mouse up events. 2134 * Handles mouse up events.
2121 * @param {!Event} event Wheel event. 2135 * @param {!Event} event Wheel event.
2122 * @private 2136 * @private
2123 */ 2137 */
2124 TouchHandler.prototype.onMouseUp_ = function(event) { 2138 TouchHandler.prototype.onMouseUp_ = function(event) {
2125 if (event.button !== 0) 2139 if (event.button !== 0)
2126 return; 2140 return;
2127 this.clickStarted_ = false; 2141 this.clickStarted_ = false;
2128 }; 2142 };
OLDNEW
« 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