Threshold diagonal swipe movements, reduce accidental swipe-to-archive

This commit is contained in:
Ben Gotow 2019-03-24 23:35:41 -07:00
parent 8a4e94b5f8
commit 4351084fe8

View file

@ -140,11 +140,16 @@ export default class SwipeContainer extends React.Component<
return this.isEnabled;
};
_onWheel = e => {
_onWheel = (e: React.WheelEvent<HTMLDivElement>) => {
// 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) {