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

Unified Diff: chrome/browser/resources/pdf/gesture_detector.js

Issue 2847893005: PDF pinch-zoom: preventDefault on 2 finger touchmoves, not touchstarts. (Closed)
Patch Set: Created 3 years, 8 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 | chrome/test/data/pdf/gesture_detector_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/pdf/gesture_detector.js
diff --git a/chrome/browser/resources/pdf/gesture_detector.js b/chrome/browser/resources/pdf/gesture_detector.js
index fde4650d92bbbc6db1d8ed7aa7259c90a9e144c3..b8b1a7b87547add04aa5ba592f8b5683a6cd0ab2 100644
--- a/chrome/browser/resources/pdf/gesture_detector.js
+++ b/chrome/browser/resources/pdf/gesture_detector.js
@@ -17,9 +17,9 @@ class GestureDetector {
this.element_ = element;
this.element_.addEventListener(
- 'touchstart', this.onTouchStart_.bind(this), { passive: false });
+ 'touchstart', this.onTouchStart_.bind(this), { passive: true });
this.element_.addEventListener(
- 'touchmove', this.onTouch_.bind(this), { passive: true });
+ 'touchmove', this.onTouch_.bind(this), { passive: false });
this.element_.addEventListener(
'touchend', this.onTouch_.bind(this), { passive: true });
this.element_.addEventListener(
@@ -64,10 +64,7 @@ class GestureDetector {
* @param {!TouchEvent} event Touch event on the element.
*/
onTouchStart_(event) {
- // We must preventDefault if there is a two finger touch. By doing so
- // native pinch-zoom does not interfere with our way of handling the event.
if (event.touches.length == 2) {
- event.preventDefault();
this.pinchStartEvent_ = event;
this.lastEvent_ = event;
this.notify_({
@@ -103,6 +100,10 @@ class GestureDetector {
return;
}
+ // We must preventDefault two finger touchmoves. By doing so native
+ // pinch-zoom does not interfere with our way of handling the event.
+ event.preventDefault();
+
let scaleRatio = GestureDetector.pinchScaleRatio_(event, this.lastEvent_);
let startScaleRatio = GestureDetector.pinchScaleRatio_(
event, this.pinchStartEvent_);
« no previous file with comments | « no previous file | chrome/test/data/pdf/gesture_detector_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698