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

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

Issue 446343002: Gallery: Scroll images by two finger swipe on a track pad. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 years, 4 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 ca348d57ae04cb88a595709b4ed2141d4a6c403a..f8f7105a92e768515e91da97661ed62340a7bd6b 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 {TouchEvent} event Touch event.
+ * @private
+ */
TouchHandler.prototype.onTouchStart_ = function(event) {
if (this.enabled_ && event.touches.length === 1)
this.touchStarted_ = true;
};
/**
- * @param {event} event Touch event.
+ * Handles touch move and touch end events.
+ * @param {TouchEvent} event Touch event.
+ * @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,
+ viewport.getOffsetY() + event.wheelDeltaY);
+ this.slideMode_.applyViewportChange();
+};
« 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