From 4351084fe8f12838e0dcd466b8f5c2071aef049e Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Sun, 24 Mar 2019 23:35:41 -0700 Subject: [PATCH] Threshold diagonal swipe movements, reduce accidental swipe-to-archive #690 --- app/src/components/swipe-container.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/components/swipe-container.tsx b/app/src/components/swipe-container.tsx index 04efaebf8..88cf934aa 100644 --- a/app/src/components/swipe-container.tsx +++ b/app/src/components/swipe-container.tsx @@ -140,11 +140,16 @@ export default class SwipeContainer extends React.Component< return this.isEnabled; }; - _onWheel = e => { + _onWheel = (e: React.WheelEvent) => { + // Require that the wheel direction has a greater X component than Y component + const ratio = Math.abs(e.deltaX) / (Math.abs(e.deltaY) || 1); + if (this.phase !== Phase.GestureConfirmed && ratio < 1.3) return; + let velocity = e.deltaX / 3; if (SwipeInverted) { velocity = -velocity; } + this._onDragWithVelocity(velocity); if (this.phase === Phase.GestureConfirmed) {