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 ca348d57ae04cb88a595709b4ed2141d4a6c403a..de3249f4ac1f2e5d7e003b1bb5c660fe9147c4fb 100644 |
| --- a/ui/file_manager/gallery/js/slide_mode.js |
| +++ b/ui/file_manager/gallery/js/slide_mode.js |
| @@ -1385,6 +1385,8 @@ function TouchHandler(targetElement, slideMode) { |
| var onTouchEventBound = this.onTouchEvent_.bind(this); |
| targetElement.ownerDocument.addEventListener('touchmove', onTouchEventBound); |
| targetElement.ownerDocument.addEventListener('touchend', onTouchEventBound); |
| + |
| + targetElement.addEventListener('mousewheel', this.onMouseWheel_.bind(this)); |
| } |
| /** |
| @@ -1416,17 +1418,6 @@ TouchHandler.getDistance = function(event) { |
| return Math.sqrt(dx * dx + dy * dy); |
| }; |
| -TouchHandler.prototype = { |
| - /** |
| - * @param {boolean} flag New value. |
| - */ |
| - set enabled(flag) { |
| - this.enabled_ = flag; |
| - if (!this.enabled_) |
| - this.stopOperation(); |
| - } |
| -}; |
| - |
| /** |
| * Obtains the degrees of the pinch twist angle. |
| * @param {TouchEvent} event1 Start touch event. It should include more than two |
| @@ -1445,6 +1436,17 @@ TouchHandler.getTwistAngle = function(event1, event2) { |
| return Math.atan2(outerProduct, innerProduct) * 180 / Math.PI; // atan(y / x) |
| }; |
| +TouchHandler.prototype = { |
| + /** |
| + * @param {boolean} flag New value. |
| + */ |
| + set enabled(flag) { |
| + this.enabled_ = flag; |
| + if (!this.enabled_) |
| + this.stopOperation(); |
| + } |
| +}; |
| + |
| /** |
| * Stops the current touch operation. |
| */ |
| @@ -1456,13 +1458,20 @@ TouchHandler.prototype.stopOperation = function() { |
| this.lastZoom_ = 1.0; |
| }; |
| +/** |
| + * Handles touch start events. |
| + * @param {event} event Touch event. |
|
mtomasz
2014/08/08 00:21:00
event -> Event
hirono
2014/08/08 02:41:44
Done.
|
| + * @private |
| + */ |
| TouchHandler.prototype.onTouchStart_ = function(event) { |
| if (this.enabled_ && event.touches.length === 1) |
| this.touchStarted_ = true; |
| }; |
| /** |
| + * Handles touch move and touch end events. |
| * @param {event} event Touch event. |
|
mtomasz
2014/08/08 00:21:01
ditto
hirono
2014/08/08 02:41:44
Done.
|
| + * @private |
| */ |
| TouchHandler.prototype.onTouchEvent_ = function(event) { |
| // Check if the current touch operation started from the target element or |
| @@ -1547,3 +1556,19 @@ TouchHandler.prototype.onTouchEvent_ = function(event) { |
| this.lastEvent_ = event; |
| this.lastZoom_ = viewport.getZoom(); |
| }; |
| + |
| +/** |
| + * Handles mouse wheel events. |
| + * @param {MouseEvent} event Wheel event. |
| + * @private |
| + */ |
| +TouchHandler.prototype.onMouseWheel_ = function(event) { |
| + var viewport = this.slideMode_.getViewport(); |
| + if (!this.enabled_ || !viewport.isZoomed()) |
| + return; |
| + this.stopOperation(); |
| + viewport.setOffset( |
| + viewport.getOffsetX() + event.wheelDeltaX, |
|
mtomasz
2014/08/08 00:21:00
Does it work with a wheel on a separate mouse?
hirono
2014/08/08 02:41:44
Yes, when the photo is zoomed, the mouse wheel mov
|
| + viewport.getOffsetY() + event.wheelDeltaY); |
| + this.slideMode_.applyViewportChange(); |
| +}; |